-# Copyright (c) 2014 The NativeClient Authors. All rights reserved.
+# Copyright (c) 2014 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Use "is_*" names for intrinsic platform descriptions and build modes, and
# "use_*" names for optional features libraries, and configurations.
declare_args() {
+ # The current NaCl libc and preps stage, none for trusted toolchains.
+ nacl_libc = "none"
+ nacl_prep = "none"
+
+ use_newlib = true
+ use_glibc = false
+ use_pnacl = false
+
+ use_nacl_x86 = (cpu_arch == "x86")
+ use_nacl_x64 = ((cpu_arch == "x64") || (os == "win"))
+ use_nacl_arm = (cpu_arch == "arm")
+
+ is_android_webview_build = false
+
# How many symbols to include in the build. This affects the performance of
# the build since the symbols are large and dealing with them is slow.
# 2 means regular build with symbols.
# 0 means no symbols.
symbol_level = 2
+ # Component build.
+ is_component_build = false
# Debug build.
is_debug = true
# to configure warnings.
is_clang = false
- # Various build configuration
+ # Forces a 64-bit build on Windows. Does nothing on other platforms. Normally
+ # we build 32-bit on Windows regardless of the current host OS bit depth.
+ # Setting this flag will override this logic and generate 64-bit toolchains.
+ #
+ # Normally this would get set automatically when you specify a target using
+ # the 64-bit toolchain. You can also set this on the command line to convert
+ # the default toolchain to 64-bit.
+ force_win64 = false
+
+ # Selects the desired build flavor. Official builds get additional
+ # processing to prepare for release. Normally you will want to develop and
+ # test with this flag off.
+ is_official_build = false
+
+ # Select the desired branding flavor. False means normal Chromium branding,
+ # true means official Google Chrome branding (requires extra Google-internal
+ # resources).
+ is_chrome_branded = false
+
+ # Compile for Address Sanitizer to find memory bugs.
is_asan = false
+
+ # Compile for Leak Sanitizer to find leaks.
is_lsan = false
+
+ # Compile for Memory Sanitizer to find uninitialized reads.
is_msan = false
+
+ # Compile for Thread Sanitizer to find threading bugs.
is_tsan = false
}
-
# =============================================================================
# OS DEFINITIONS
# =============================================================================
# We set these various is_FOO booleans for convenience in writing OS-based
# conditions.
#
+# - is_android, is_chromeos, is_ios, and is_win should be obvious.
+# - is_mac is set only for desktop Mac. It is not set on iOS.
+# - is_posix is true for mac and any Unix-like system (basically everything
+# except Windows).
+# - is_linux is true for desktop Linux and ChromeOS, but not Android (which is
+# generally too different despite being based on the Linux kernel).
+#
# Do not add more is_* variants here for random lesser-used Unix systems like
# aix or one of the BSDs. If you need to check these, just check the os value
# directly.
if (os == "win") {
+ is_android = false
+ is_chromeos = false
+ is_ios = false
is_linux = false
is_mac = false
+ is_nacl = false
is_posix = false
is_win = true
} else if (os == "mac") {
+ is_android = false
+ is_chromeos = false
+ is_ios = false
is_linux = false
is_mac = true
+ is_nacl = false
is_posix = true
is_win = false
if (!is_clang) {
is_clang = true # Always use clang on Mac.
}
+} else if (os == "android") {
+ is_android = true
+ is_chromeos = false
+ is_ios = false
+ is_linux = false
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else if (os == "chromeos") {
+ is_android = false
+ is_chromeos = true
+ is_ios = false
+ is_linux = true
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else if (os == "nacl") {
+ # os == "nacl" will be passed by the nacl toolchain definition. It is not
+ # set by default or on the command line. We treat is as a Posix variant.
+ is_android = false
+ is_chromeos = false
+ is_ios = false
+ is_linux = false
+ is_mac = false
+ is_nacl = true
+ is_posix = true
+ is_win = false
+} else if (os == "ios") {
+ is_android = false
+ is_chromeos = false
+ is_ios = true
+ is_linux = false
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+ if (!is_gyp_xcode_generator) {
+ # Always use clang on iOS when using ninja
+ is_clang = true
+ }
} else if (os == "linux") {
+ is_android = false
+ is_chromeos = false
+ is_ios = false
is_linux = true
is_mac = false
+ is_nacl = false
is_posix = true
is_win = false
}
-# We do not use assignment filters
-set_sources_assignment_filter([])
+is_desktop_linux = is_linux && !is_chromeos
+
+# =============================================================================
+# CPU ARCHITECTURE
+# =============================================================================
+
+if (is_win) {
+ # Always use 32-bit on Windows, even when compiling on a 64-bit host OS,
+ # unless the override flag is specified.
+ if (force_win64) {
+ cpu_arch = "x64"
+ } else {
+ cpu_arch = "x86"
+ }
+}
+
+# =============================================================================
+# SOURCES FILTERS
+# =============================================================================
+#
+# These patterns filter out platform-specific files when assigning to the
+# sources variable. The magic variable |sources_assignment_filter| is applied
+# to each assignment or appending to the sources variable and matches are
+# automatcally removed.
+#
+# Note that the patterns are NOT regular expressions. Only "*" and "\b" (path
+# boundary = end of string or slash) are supported, and the entire string
+# muct match the pattern (so you need "*.cc" to match all .cc files, for
+# example).
+
+# DO NOT ADD MORE PATTERNS TO THIS LIST, see set_sources_assignment_filter call
+# below.
+sources_assignment_filter = []
+if (!is_posix) {
+ sources_assignment_filter += [
+ "*_posix.h",
+ "*_posix.cc",
+ "*_posix_unittest.h",
+ "*_posix_unittest.cc",
+ "*\bposix/*",
+ ]
+}
+if (!is_win) {
+ sources_assignment_filter += [
+ "*_win.cc",
+ "*_win.h",
+ "*_win_unittest.cc",
+ "*\bwin/*",
+ "*.rc",
+ ]
+}
+if (!is_mac) {
+ sources_assignment_filter += [
+ "*_mac.h",
+ "*_mac.cc",
+ "*_mac.mm",
+ "*_mac_unittest.h",
+ "*_mac_unittest.cc",
+ "*_mac_unittest.mm",
+ "*\bmac/*",
+ "*_cocoa.h",
+ "*_cocoa.cc",
+ "*_cocoa.mm",
+ "*_cocoa_unittest.h",
+ "*_cocoa_unittest.cc",
+ "*_cocoa_unittest.mm",
+ "*\bcocoa/*",
+ ]
+}
+if (!is_ios) {
+ sources_assignment_filter += [
+ "*_ios.h",
+ "*_ios.cc",
+ "*_ios.mm",
+ "*_ios_unittest.h",
+ "*_ios_unittest.cc",
+ "*_ios_unittest.mm",
+ "*\bios/*",
+ ]
+}
+if (!is_mac && !is_ios) {
+ sources_assignment_filter += [
+ "*.mm",
+ ]
+}
+if (!is_linux) {
+ sources_assignment_filter += [
+ "*_linux.h",
+ "*_linux.cc",
+ "*_linux_unittest.h",
+ "*_linux_unittest.cc",
+ "*\blinux/*",
+ ]
+}
+if (!is_android) {
+ sources_assignment_filter += [
+ "*_android.h",
+ "*_android.cc",
+ "*_android_unittest.h",
+ "*_android_unittest.cc",
+ "*\bandroid/*",
+ ]
+}
+if (!is_chromeos) {
+ sources_assignment_filter += [
+ "*_chromeos.h",
+ "*_chromeos.cc",
+ "*_chromeos_unittest.h",
+ "*_chromeos_unittest.cc",
+ "*\bchromeos/*",
+ ]
+}
+# DO NOT ADD MORE PATTERNS TO THIS LIST, see set_sources_assignment_filter call
+# below.
+
+# Actually save this list.
+#
+# These patterns are executed for every file in the source tree of every run.
+# Therefore, adding more patterns slows down the build for everybody. We should
+# only add automatic patterns for configurations affecting hundreds of files
+# across many projects in the tree.
+#
+# Therefore, we only add rules to this list corresponding to platforms on the
+# Chromium waterfall. This is not for non-officially-supported platforms
+# (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases,
+# write a conditional in the target to remove the file(s) from the list when
+# your platform/toolkit/feature doesn't apply.
+set_sources_assignment_filter(sources_assignment_filter)
# =============================================================================
# BUILD OPTIONS
# =============================================================================
+if (is_component_build) {
+ component_mode = "shared_library"
+} else {
+ component_mode = "source_set"
+}
+
# These Sanitizers all imply using the Clang compiler. On Windows they either
# don't work or work differently.
if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) {
is_clang = true
}
+# ==============================================================================
+# TOOLCHAIN SETUP
+# ==============================================================================
+#
+# Here we set the default toolchain, as well as the variable host_toolchain
+# which will identify the toolchain corresponding to the local system when
+# doing cross-compiles. When not cross-compiling, this will be the same as the
+# default toolchain.
+
+if (is_nacl) {
+ if (build_os == "mac") {
+ host_toolchain = "//native_client/build/toolchain/mac:clang"
+ }
+ else {
+ host_toolchain = "//native_client/build/toolchain/${build_os}:${build_cpu_arch}"
+ }
+} else if (is_win) {
+ # TODO(brettw) name the toolchains the same as cpu_arch as with Linux below
+ # to eliminate these conditionals.
+ if (build_cpu_arch == "x64") {
+ host_toolchain = "//native_client/build/toolchain/win:64"
+ } else if (build_cpu_arch == "x86") {
+ host_toolchain = "//native_client/build/toolchain/win:32"
+ }
+
+ if (cpu_arch == "x64") {
+ set_default_toolchain("//native_client/build/toolchain/win:64")
+ } else if (cpu_arch == "x86") {
+ set_default_toolchain("//native_client/build/toolchain/win:32")
+ }
+} else if (is_linux) {
+ host_toolchain = "//native_client/build/toolchain/linux:$build_cpu_arch"
+ set_default_toolchain("//native_client/build/toolchain/linux:$cpu_arch")
+} else if (is_mac) {
+ host_toolchain = "//native_client/build/toolchain/mac:clang"
+ set_default_toolchain(host_toolchain)
+} else if (is_ios) {
+ host_toolchain = "//native_client/build/toolchain/mac:host_clang"
+ set_default_toolchain("//native_client/build/toolchain/mac:clang")
+}
+
# =============================================================================
# TARGET DEFAULTS
# =============================================================================
# corresponding target. Target definitions can add or remove to the settings
# here as needed.
+#
+# For NaCl targets, we inject a dependency on prepping the library for cooked
+# toolchain targets. For raw targets we inject a dependency on untarring.
+#
+_nacl_compiler_configs = [
+ "//native_client/build/config/nacl:nacl_defines",
+ "//native_client/build/config/nacl:nexe_defines",
+ "//native_client/build/config/compiler:chromium_code",
+]
+
# Holds all configs used for making native executables and libraries, to avoid
# duplication in each target below.
-native_compiler_configs = [
- "//native_client/build/config:nacl_defines",
+_native_compiler_configs = [
+ "//native_client/build/config/nacl:nacl_defines",
"//native_client/build/config/compiler:compiler",
"//native_client/build/config/compiler:default_warnings",
"//native_client/build/config/compiler:no_rtti",
]
if (is_clang) {
- native_compiler_configs += [ "//native_client/build/config/clang:find_bad_constructs" ]
+ _native_compiler_configs += [ "//native_client/build/config/clang:find_bad_constructs" ]
}
# Optimizations and debug checking.
if (is_debug) {
- native_compiler_configs += [ "//native_client/build/config:debug" ]
- default_optimization_config = "//native_client/build/config/compiler:no_optimize"
+ _native_compiler_configs += [ "//native_client/build/config:debug" ]
+ _default_optimization_config = "//native_client/build/config/compiler:no_optimize"
} else {
- native_compiler_configs += [ "//native_client/build/config:release" ]
- default_optimization_config = "//native_client/build/config/compiler:optimize"
+ _native_compiler_configs += [ "//native_client/build/config:release" ]
+ _default_optimization_config = "//native_client/build/config/compiler:optimize"
}
-native_compiler_configs += [ default_optimization_config ]
+_native_compiler_configs += [ _default_optimization_config ]
# Symbol setup.
if (is_clang && is_linux) {
} else {
assert(false, "Bad value for symbol_level.")
}
-native_compiler_configs += [ default_symbols_config ]
-
+_native_compiler_configs += [ default_symbols_config ]
# Windows linker setup for EXEs and DLLs.
if (is_win) {
- windows_linker_configs = [
- default_incremental_linking_config,
+ if (is_debug) {
+ _default_incremental_linking_config =
+ "//native_client/build/config/win:incremental_linking"
+ } else {
+ _default_incremental_linking_config =
+ "//native_client/build/config/win:no_incremental_linking"
+ }
+ _windows_linker_configs = [
+ _default_incremental_linking_config,
"//native_client/build/config/win:sdk_link",
"//native_client/build/config/win:common_linker_setup",
+ # Default to console-mode apps. Most of our targets are tests and such
+ # that shouldn't use the windows subsystem.
+ "//native_client/build/config/win:console",
]
}
set_defaults("executable") {
- configs = native_compiler_configs + [
- "//build/config:default_libs",
- ]
- if (is_win) {
- configs += windows_linker_configs
- } else if (is_mac) {
- configs += [
- "///native_clientbuild/config/mac:mac_dynamic_flags",
- "//native_client/build/config/mac:mac_executable_flags" ]
- } else if (is_linux) {
- configs += [ "//native_client/build/config/linux:executable_ldconfig" ]
+ configs = []
+ if (os != "nacl") {
+ configs = _native_compiler_configs + [
+ "//native_client/build/config:default_libs",
+ ]
+ if (is_win) {
+ configs += _windows_linker_configs
+ } else if (is_mac) {
+ # configs += [
+ # "///native_clientbuild/config/mac:mac_dynamic_flags",
+ # "//native_client/build/config/mac:mac_executable_flags" ]
+ } else if (is_linux) {
+ # configs += [ "//native_client/build/config/linux:executable_ldconfig" ]
+ }
+ } else {
+ configs = _nacl_compiler_configs
}
}
set_defaults("static_library") {
- configs = native_compiler_configs
+ configs = []
+ if (os != "nacl") {
+ configs += _native_compiler_configs
+ } else {
+ configs += _nacl_compiler_configs
+ }
}
set_defaults("shared_library") {
- configs = native_compiler_configs + [
- "//build/config:default_libs",
- ]
- if (is_win) {
- configs += windows_linker_configs
- } else if (is_mac) {
- configs += [ "//build/config/mac:mac_dynamic_flags" ]
+ configs = []
+ if (os != "nacl") {
+ configs += _native_compiler_configs + [
+ "//native_client/build/config:default_libs",
+ ]
+ if (is_win) {
+ configs += _windows_linker_configs
+ } else if (is_mac) {
+ configs += [ "//native_client/build/config/mac:mac_dynamic_flags" ]
+ }
+ } else {
+ configs = _nacl_compiler_configs
}
}
set_defaults("source_set") {
- configs = native_compiler_configs
+ configs = []
+ if (os != "nacl") {
+ configs = _native_compiler_configs
+ } else {
+ configs = _nacl_compiler_configs
+ }
}
-# ==============================================================================
-# TOOLCHAIN SETUP
-# ==============================================================================
-#
-# Here we set the default toolchain, as well as the variable host_toolchain
-# which will identify the toolchain corresponding to the local system when
-# doing cross-compiles. When not cross-compiling, this will be the same as the
-# default toolchain.
-if (is_win) {
- # TODO(brettw) name the toolchains the same as cpu_arch as with Linux below
- # to eliminate these conditionals.
- if (build_cpu_arch == "x64") {
- host_toolchain = "//native_client/build/toolchain/win:64"
- } else if (build_cpu_arch == "x86") {
- host_toolchain = "//native_client/build/toolchain/win:32"
- }
-
- if (cpu_arch == "x64") {
- set_default_toolchain("//native_client/build/toolchain/win:64")
- } else if (cpu_arch == "x86") {
- set_default_toolchain("//native_client/build/toolchain/win:32")
- }
-} else if (is_linux) {
- host_toolchain = "//native_client/build/toolchain/linux:$build_cpu_arch"
- set_default_toolchain("//native_client/build/toolchain/linux:$cpu_arch")
-} else if (is_mac) {
- host_toolchain = "//native_client/build/toolchain/mac:clang"
- set_default_toolchain(host_toolchain)
-} else if (is_ios) {
- host_toolchain = "//native_client/build/toolchain/mac:host_clang"
- set_default_toolchain("//native_client/build/toolchain/mac:clang")
-}