blob: b3356caa89ca626284604de4d7c6570469e1d415 [file] [log] [blame]
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//starboard/build/platforms.gni")
declare_args() {
is_clang = true
build_type = "devel"
target_platform = "stub"
is_starboard = true
cobalt_fastbuild = getenv("IS_CI") == 1
is_internal_build = false
# TODO: Remove this flag when the affected targets can be built.
can_build_evergreen_loader_apps = true
}
is_debug = build_type == "debug"
is_devel = build_type == "devel"
is_qa = build_type == "qa"
is_gold = build_type == "gold"
assert(is_debug || is_devel || is_qa || is_gold)
declare_args() {
use_tsan = getenv("USE_TSAN") == 1
}
declare_args() {
use_asan = (is_debug || is_devel || getenv("USE_ASAN") == 1) && !use_tsan
}
assert(!(use_tsan && use_asan), "ASAN and TSAN are mutually exclusive.")
# Set some variables we never want to change.
sb_allows_memory_tracking = !is_gold
host_byteorder = "little"
is_official_build = false # Chromium's build files expect this to be set.
# The os/cpu definitions are here to set the current platform type in
# os_definitions.gni below.
if (target_os == "") {
target_os = host_os
}
if (target_cpu == "") {
target_cpu = host_cpu
}
if (current_os == "") {
current_os = target_os
}
if (current_cpu == "") {
current_cpu = target_cpu
}
import("//starboard/build/config/os_definitions.gni")
# Get the path to the starboard implementation and include its GN
# configuration.
foreach(platform, platforms) {
if (platform.name == target_platform) {
starboard_path = platform.path
}
}
assert(defined(starboard_path),
"Please port your platform to starboard/build/platforms.gni")
host_toolchain = "//$starboard_path/toolchain:host"
_default_toolchain = "//$starboard_path/toolchain:target"
set_default_toolchain(_default_toolchain)
import("//$starboard_path/platform_configuration/configuration.gni")
import("//starboard/build/config/build_assertions.gni")
# =============================================================================
# TARGET DEFAULTS
# =============================================================================
#
# Set up the default configuration for every build target of the given type.
# The values configured here will be automatically set on the scope of the
# corresponding target. Target definitions can add or remove to the settings
# here as needed.
#
# WHAT GOES HERE?
#
# Other than the main compiler and linker configs, the only reason for a config
# to be in this list is if some targets need to explicitly override that config
# by removing it. This is how targets opt-out of flags. If you don't have that
# requirement and just need to add a config everywhere, reference it as a
# sub-config of an existing one, most commonly the main "compiler" one.
default_compiler_configs = [
"//build/config/compiler:default_include_dirs",
"//build/config/compiler:no_exceptions",
"//$starboard_path/platform_configuration",
"//starboard/build/config:base",
"//starboard/build/config:host",
"//starboard/build/config:size",
"//starboard/build/config:target",
"//starboard/build/config:no_pedantic_warnings",
]
if (is_starboard) {
default_compiler_configs += [ "//starboard/build/config:starboard" ]
}
set_defaults("static_library") {
configs = default_compiler_configs + static_library_configs
}
set_defaults("source_set") {
configs = default_compiler_configs + source_set_configs
}
set_defaults("loadable_module") {
configs = default_compiler_configs + loadable_module_configs
}
set_defaults("executable") {
configs = default_compiler_configs + executable_configs
}
set_defaults("shared_library") {
configs = default_compiler_configs + shared_library_configs
}
# Set up the method of generating the install targets as defined by the
# platform.
import("$install_target_path")
template("executable") {
executable(target_name) {
forward_variables_from(invoker, "*", [ "install_target" ])
}
if (!defined(invoker.install_target) || invoker.install_target) {
executable_target_name = target_name
install_target(target_name + "_install") {
forward_variables_from(invoker,
[
"content",
"testonly",
])
installable_target_name = executable_target_name
type = "executable"
}
}
}
template("shared_library") {
shared_library(target_name) {
forward_variables_from(invoker, "*", [ "install_target" ])
}
if (!defined(invoker.install_target) || invoker.install_target) {
shared_library_target_name = target_name
install_target(target_name + "_install") {
forward_variables_from(invoker,
[
"content",
"testonly",
])
installable_target_name = shared_library_target_name
type = "shared_library"
}
}
}
# Import this down here as it relies on variables set during configuration.
import("//starboard/build/config/components.gni")