blob: eadf91808c59467fa0f1df80372bc4d086cb992e [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
# Use link time optimization (LTO).
use_lto = false
# magenta build project
magenta_project = ""
}
if (magenta_project == "") {
if (current_cpu == "arm64") {
magenta_project = "magenta-qemu-arm64"
} else if (current_cpu == "x64") {
magenta_project = "magenta-pc-x86-64"
}
}
assert(magenta_project != "", "unable to set default magenta build project")
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
}
# All binary targets will get this list of configs by default.
default_shared_binary_configs = [
"//build/config:compiler",
"//build/config:relative_paths",
"//build/config:default_include_dirs",
"//build/config:default_warnings",
"//build/config:no_exceptions",
"//build/config:no_rtti",
"//build/config:symbol_visibility_hidden",
]
if (is_debug) {
default_shared_binary_configs += [ "//build/config:debug" ]
} else {
default_shared_binary_configs += [ "//build/config:release" ]
}
if (is_fuchsia) {
default_shared_binary_configs += [
"//build/config/fuchsia:icf",
"//build/config/fuchsia:safestack",
"//build/config/fuchsia:thread_safety_annotations",
"//build/config/fuchsia:werror",
]
}
if (use_lto) {
default_shared_binary_configs += [ "//build/config:lto" ]
}
default_shared_library_configs = default_shared_binary_configs + [
"//build/config:shared_library_config",
"//build/config:symbol_no_undefined",
]
default_executable_configs = default_shared_binary_configs + [
"//build/config:executable_config",
"//build/config:default_libs",
]
if (is_pic_default) {
default_shared_binary_configs += [ "//build/config:shared_library_config" ]
}
# Apply that default list to the binary target types.
set_defaults("source_set") {
configs = default_shared_binary_configs
}
set_defaults("static_library") {
configs = default_shared_binary_configs
}
set_defaults("shared_library") {
configs = default_shared_library_configs
}
set_defaults("loadable_module") {
configs = default_shared_library_configs
}
set_defaults("executable") {
configs = default_executable_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 = default_shared_binary_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")
}
set_default_toolchain(target_toolchain)
# Some projects expect a default value for sources assigment filters.
sources_assignment_filter = []