Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: build/config/BUILDCONFIG.gn

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/config/BUILD.gn ('k') | build/config/allocator.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/BUILDCONFIG.gn
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index ee32088dfcdee63f409cff05760d4a8261d92680..10d9d3fb189ed8f756ac51f13813eaa4807ed887 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -2,21 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# =============================================================================
-# BUILD FLAGS
-# =============================================================================
-#
-# This block lists input arguments to the build, along with their default
-# values. GN requires listing them explicitly so it can validate input and have
-# a central place to manage the build flags.
-#
-# If a value is specified on the command line, it will overwrite the defaults
-# given here, otherwise the default will be injected into the root scope.
-#
-# 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.
-
if (target_os == "") {
target_os = host_os
}
@@ -40,6 +25,59 @@ if (current_os == "") {
current_os = target_os
}
+# =============================================================================
+# BUILD FLAGS
+# =============================================================================
+#
+# This block lists input arguments to the build, along with their default
+# values.
+#
+# If a value is specified on the command line, it will overwrite the defaults
+# given in a declare_args block, otherwise the default will be used.
+#
+# YOU SHOULD ALMOST NEVER NEED TO ADD FLAGS TO THIS FILE. GN allows any file in
+# the build to declare build flags. If you need a flag for a single component,
+# you can just declare it in the corresponding BUILD.gn file. If you need a
+# flag in multiple components, there are a few options:
+#
+# - If your feature is a single target, say //components/foo, and the targets
+# depending on foo need to have some define set if foo is enabled: (1) Write
+# a declare_args block in foo's BUILD.gn file listing your enable_foo build
+# flag. (2) Write a config in that file listing the define, and list that
+# config in foo's public_configs. This will propagate that define to all the
+# targets depending on foo. (3) When foo is not enabled, just make it expand
+# to an empty group (or whatever's appropriate for the "off" state of your
+# feature.
+#
+# - If a semi-random set of targets need to know about a define: (1) In the
+# lowest level of the build that knows about this feature, add a declare_args
+# block in the build file for your enable flag. (2) Write a config that adds
+# a define conditionally based on that build flags. (3) Manually add that
+# config to the "configs" applying to the targets that need the define.
+#
+# - If a semi-random set of targets need to know about the build flag (to do
+# file inclusion or exclusion, more than just defines): (1) Write a .gni file
+# in the lowest-level directory that knows about the feature. (2) Put the
+# declare_args block with your build flag in that .gni file. (3) Import that
+# .gni file from the BUILD.gn files that need the flag.
+#
+# Other advice:
+#
+# - Use boolean values when possible. If you need a default value that expands
+# to some complex thing in the default case (like the location of the
+# compiler which would be computed by a script), use a default value of -1 or
+# the empty string. Outside of the declare_args block, conditionally expand
+# the default value as necessary.
+#
+# - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for
+# your feature) rather than just "foo".
+#
+# - Write good comments directly above the declaration with no blank line.
+# These comments will appear as documentation in "gn args --list".
+#
+# - Don't call exec_script inside declare_args. This will execute the script
+# even if the value is overridden, which is wasteful. See first bullet.
+
declare_args() {
# 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.
@@ -93,6 +131,8 @@ declare_args() {
# toolchains.
cros_use_custom_toolchain = false
}
+
+ # DON'T ADD MORE FLAGS HERE. Read the comment above.
}
# =============================================================================
@@ -213,6 +253,7 @@ if (!is_win) {
"*_win.h",
"*_win_unittest.cc",
"*\bwin/*",
+ "*.def",
"*.rc",
]
}
@@ -320,7 +361,6 @@ _native_compiler_configs = [
"//build/config/compiler:compiler_arm_fpu",
"//build/config/compiler:chromium_code",
"//build/config/compiler:default_include_dirs",
- "//build/config/compiler:default_warnings",
"//build/config/compiler:no_rtti",
"//build/config/compiler:runtime_library",
]
@@ -373,6 +413,9 @@ if (symbol_level == -1) {
# Mac and Windows have them separate, so in Release Linux, default them off.
if (is_debug || !is_linux) {
symbol_level = 2
+ } else if (is_asan || is_lsan || is_tsan || is_msan) {
+ # Sanitizers require symbols for filename suppressions to work.
+ symbol_level = 1
} else {
symbol_level = 0
}
@@ -480,11 +523,10 @@ 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 current_cpu.
- if (current_cpu == "x64") {
- host_toolchain = "//build/toolchain/win:64"
- } else if (current_cpu == "x86") {
- host_toolchain = "//build/toolchain/win:32"
+ if (is_clang) {
+ host_toolchain = "//build/toolchain/win:clang_$current_cpu"
+ } else {
+ host_toolchain = "//build/toolchain/win:$current_cpu"
}
set_default_toolchain("$host_toolchain")
} else if (is_android) {
« no previous file with comments | « build/config/BUILD.gn ('k') | build/config/allocator.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698