blob: 262724f4572c69967ef726bcec146e76f199a0e1 [file] [log] [blame]
# Copyright 2016 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
declare_args() {
# Debug build.
is_debug = true
}
if (target_os == "") {
target_os = "fuchsia"
}
if (target_cpu == "") {
target_cpu = host_cpu
}
if (current_cpu == "") {
current_cpu = target_cpu
}
if (current_os == "") {
current_os = target_os
}
declare_args() {
# This should not be set as a build argument.
target_toolchain = ""
# This should not be set as a build argument.
host_toolchain = ""
# Whether the toolchain defaults to PIC.
is_pic_default = false
}
# All binary targets will get this list of configs by default.
_shared_binary_target_configs = [
"//build/config:compiler",
"//build/config:debug_prefix_map",
"//build/config:default_include_dirs",
"//build/config:default_warnings",
"//build/config:no_exceptions",
"//build/config:no_rtti",
]
if (is_debug) {
_shared_binary_target_configs += [ "//build/config:debug" ]
} else {
_shared_binary_target_configs += [ "//build/config:release" ]
}
_shared_library_target_configs = _shared_binary_target_configs + [
"//build/config:shared_library_config",
"//build/config:symbol_visibility_hidden",
]
_executable_target_configs =
_shared_binary_target_configs + [ "//build/config:executable_config" ]
if (is_pic_default) {
_shared_binary_target_configs += [ "//build/config:shared_library_config" ]
}
# Apply that default list to the binary target types.
set_defaults("source_set") {
configs = _shared_binary_target_configs
}
set_defaults("static_library") {
configs = _shared_binary_target_configs
}
set_defaults("shared_library") {
configs = _shared_library_target_configs
}
set_defaults("executable") {
configs = _executable_target_configs
}
# Some targets we share with Chromium declare themselves to be components,
# which means they can build either as shared libraries or as static libraries.
# We build them as static libraries.
template("component") {
if (!defined(invoker.sources)) {
# When there are no sources defined, use a source set to avoid creating
# an empty static library (which generally don't work).
_component_mode = "source_set"
} else {
_component_mode = "static_library"
}
target(_component_mode, target_name) {
# Explicitly forward visibility, implicitly forward everything else.
# Forwarding "*" doesn't recurse into nested scopes (to avoid copying all
# globals into each template invocation), so won't pick up file-scoped
# variables. Normally this isn't too bad, but visibility is commonly
# defined at the file scope. Explicitly forwarding visibility and then
# excluding it from the "*" set works around this problem.
# See http://crbug.com/594610
forward_variables_from(invoker, [ "visibility" ])
forward_variables_from(invoker, "*", [ "visibility" ])
}
}
set_defaults("component") {
configs = _shared_binary_target_configs
}
if (target_os == "fuchsia") {
target_toolchain = "//build/toolchain/fuchsia:${target_cpu}"
} else {
assert(false, "Target OS not supported")
}
if (host_os == "linux" || host_os == "mac") {
host_toolchain = "//build/toolchain:host_${host_cpu}"
} else {
assert(false, "Host OS not supported")
}
is_android = false
is_fuchsia = false
is_fuchsia_host = false
is_ios = false
is_linux = false
is_mac = false
is_win = false
is_clang = true
is_component_build = false
is_official_build = false
if (current_os == "fuchsia") {
is_fuchsia = true
} else if (current_os == "linux") {
is_linux = true
is_fuchsia_host = true
} else if (current_os == "mac") {
is_mac = true
is_fuchsia_host = true
}
set_default_toolchain(target_toolchain)