Index: build/config/BUILDCONFIG.gn |
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn |
index d806a1763a4e2cb35513d9834ace1dcc99c92ab7..cd107305d6e42018c2c40879f76cc392fc04dbbb 100644 |
--- a/build/config/BUILDCONFIG.gn |
+++ b/build/config/BUILDCONFIG.gn |
@@ -16,7 +16,53 @@ |
# KEEP IN ALPHABETICAL ORDER and write a good description for everything. |
# Use "is_*" names for intrinsic platform descriptions and build modes, and |
# "use_*" names for optional features libraries, and configurations. |
+ |
+# TODO(dpranke): The os and cpu_arch variables exist for backwards |
+# compatibility and should be deleted once all of the build files and |
+# bots have been updated to use current_cpu/target_cpu and |
+# current_os/target_os instead. |
+ |
+if (target_os == "") { |
+ if (defined(os)) { |
+ # If os is defined, it was set in an args file and needs to be |
+ # used for backwards-compatibility. |
+ target_os = os |
+ } else { |
+ target_os = host_os |
+ } |
+} |
+ |
+if (target_cpu == "") { |
+ if (defined(cpu_arch)) { |
+ # If cpu_arch is defined, it was set in an args file and needs to be |
+ # used for backwards-compatibility. |
+ target_cpu = cpu_arch |
+ } else if (target_os == "android") { |
+ # If we're building for Android, we should assume that we want to |
+ # build for ARM by default, not the host_cpu (which is likely x64). |
+ # This allows us to not have to specify both target_os and target_cpu |
+ # on the command line. |
+ target_cpu = "arm" |
+ } else { |
+ target_cpu = host_cpu |
+ } |
+} |
+ |
+if (current_cpu == "") { |
+ current_cpu = target_cpu |
+} |
+if (current_os == "") { |
+ current_os = target_os |
+} |
+ |
declare_args() { |
+ # TODO(dpranke): These values are here for backwards compatibility and |
+ # should be deleted when all of the builders and configs have been updated. |
+ cpu_arch = target_cpu |
+ os = target_os |
+ build_cpu_arch = host_cpu |
+ build_os = host_os |
+ |
# 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. |
@@ -32,11 +78,12 @@ declare_args() { |
is_debug = true |
# Whether we're a traditional desktop unix. |
- is_desktop_linux = os == "linux" && os != "chromeos" |
+ is_desktop_linux = current_os == "linux" && current_os != "chromeos" |
# Set to true when compiling with the Clang compiler. Typically this is used |
# to configure warnings. |
- is_clang = os == "mac" || os == "ios" || os == "linux" || os == "chromeos" |
+ is_clang = current_os == "mac" || current_os == "ios" || |
+ current_os == "linux" || current_os == "chromeos" |
# Selects the desired build flavor. Official builds get additional |
# processing to prepare for release. Normally you will want to develop and |
@@ -60,29 +107,22 @@ declare_args() { |
# Compile for Thread Sanitizer to find threading bugs. |
is_tsan = false |
- if (os == "chromeos") { |
+ if (current_os == "chromeos") { |
# Allows the target toolchain to be injected as arguments. This is needed |
# to support the CrOS build system which supports per-build-configuration |
# toolchains. |
cros_use_custom_toolchain = false |
} |
- # TODO(cjhopman): Make target_arch work for all platforms. |
- |
- # Architecture of the target device. For Android builds, this will be equal to |
- # the cpu_arch of the default toolchain. When checking the CPU architecture |
- # for source files and build dependencies you should almost alway use cpu_arch |
- # instead. cpu_arch is the architecture of the current toolchain and allows |
- # cross-compiles (compiling the same target for multiple toolchains in the |
- # same build) to work. |
- target_arch = "arm" |
- |
# TODO(brettw) remove this flag (and therefore enable linking all targets) on |
# Windows when we have sufficient bot capacity. In the meantime, you can |
# enable linking for local compiles. |
link_chrome_on_windows = true |
} |
+# TODO(dpranke): Remove these asserts when os and cpu_arch are removed. |
+assert(current_os == os) |
+ |
# ============================================================================= |
# OS DEFINITIONS |
# ============================================================================= |
@@ -98,10 +138,10 @@ declare_args() { |
# 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. |
+# aix or one of the BSDs. If you need to check these, just check the |
+# current_os value directly. |
-if (os == "win") { |
+if (current_os == "win") { |
is_android = false |
is_chromeos = false |
is_ios = false |
@@ -110,7 +150,7 @@ if (os == "win") { |
is_nacl = false |
is_posix = false |
is_win = true |
-} else if (os == "mac") { |
+} else if (current_os == "mac") { |
is_android = false |
is_chromeos = false |
is_ios = false |
@@ -119,7 +159,7 @@ if (os == "win") { |
is_nacl = false |
is_posix = true |
is_win = false |
-} else if (os == "android") { |
+} else if (current_os == "android") { |
is_android = true |
is_chromeos = false |
is_ios = false |
@@ -128,7 +168,7 @@ if (os == "win") { |
is_nacl = false |
is_posix = true |
is_win = false |
-} else if (os == "chromeos") { |
+} else if (current_os == "chromeos") { |
is_android = false |
is_chromeos = true |
is_ios = false |
@@ -137,9 +177,10 @@ if (os == "win") { |
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. |
+} else if (current_os == "nacl") { |
+ # current_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 |
@@ -148,7 +189,7 @@ if (os == "win") { |
is_nacl = true |
is_posix = true |
is_win = false |
-} else if (os == "ios") { |
+} else if (current_os == "ios") { |
is_android = false |
is_chromeos = false |
is_ios = true |
@@ -157,7 +198,7 @@ if (os == "win") { |
is_nacl = false |
is_posix = true |
is_win = false |
-} else if (os == "linux") { |
+} else if (current_os == "linux") { |
is_android = false |
is_chromeos = false |
is_ios = false |
@@ -169,18 +210,6 @@ if (os == "win") { |
} |
# ============================================================================= |
-# CPU ARCHITECTURE |
-# ============================================================================= |
- |
-if (is_android) { |
- # TODO(cjhopman): enable this assert once bots are updated to not set |
- # cpu_arch. |
- #assert(cpu_arch == build_cpu_arch, "Android device target architecture should |
- # be set with 'target_arch', not 'cpu_arch'") |
- cpu_arch = target_arch |
-} |
- |
-# ============================================================================= |
# SOURCES FILTERS |
# ============================================================================= |
# |
@@ -441,6 +470,11 @@ if (is_win) { |
_shared_library_configs += _windows_linker_configs |
} else if (is_mac) { |
_shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] |
+} else if (is_android) { |
+ # Strip native JNI exports from shared libraries by default. Binaries that |
+ # want this can remove this config. |
+ _shared_library_configs += |
+ [ "//build/config/android:hide_native_jni_exports" ] |
} |
set_defaults("shared_library") { |
configs = _shared_library_configs |
@@ -481,28 +515,28 @@ set_defaults("test") { |
if (is_win) { |
# On windows we use the same toolchain for host and target by default. |
- # TODO(dpranke): rename the toolchains to x64 and x86 to match cpu_arch. |
- if (cpu_arch == "x64") { |
+ # TODO(dpranke): rename the toolchains to x64 and x86 to match current_cpu. |
+ if (current_cpu == "x64") { |
host_toolchain = "//build/toolchain/win:64" |
- } else if (cpu_arch == "x86") { |
+ } else if (current_cpu == "x86") { |
host_toolchain = "//build/toolchain/win:32" |
} |
set_default_toolchain("$host_toolchain") |
} else if (is_android) { |
# Use clang for the x86/64 Linux host builds. |
- if (build_cpu_arch == "x86" || build_cpu_arch == "x64") { |
- host_toolchain = "//build/toolchain/linux:clang_$build_cpu_arch" |
+ if (host_cpu == "x86" || host_cpu == "x64") { |
+ host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
} else { |
- host_toolchain = "//build/toolchain/linux:$build_cpu_arch" |
+ host_toolchain = "//build/toolchain/linux:$host_cpu" |
} |
- set_default_toolchain("//build/toolchain/android:$cpu_arch") |
+ set_default_toolchain("//build/toolchain/android:$current_cpu") |
} else if (is_linux) { |
if (is_clang) { |
- host_toolchain = "//build/toolchain/linux:clang_$build_cpu_arch" |
- set_default_toolchain("//build/toolchain/linux:clang_$cpu_arch") |
+ host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
+ set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") |
} else { |
- host_toolchain = "//build/toolchain/linux:$build_cpu_arch" |
- set_default_toolchain("//build/toolchain/linux:$cpu_arch") |
+ host_toolchain = "//build/toolchain/linux:$host_cpu" |
+ set_default_toolchain("//build/toolchain/linux:$current_cpu") |
} |
if (is_chromeos && cros_use_custom_toolchain) { |
set_default_toolchain("//build/toolchain/cros:target") |