OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # ============================================================================= | |
6 # BUILD FLAGS | |
7 # ============================================================================= | |
8 # | |
9 # This block lists input arguments to the build, along with their default | |
10 # values. GN requires listing them explicitly so it can validate input and have | |
11 # a central place to manage the build flags. | |
12 # | |
13 # If a value is specified on the command line, it will overwrite the defaults | |
14 # given here, otherwise the default will be injected into the root scope. | |
15 # | |
16 # KEEP IN ALPHABETICAL ORDER and write a good description for everything. | |
17 # Use "is_*" names for intrinsic platform descriptions and build modes, and | |
18 # "use_*" names for optional features libraries, and configurations. | |
19 | |
20 if (target_os == "") { | 5 if (target_os == "") { |
21 target_os = host_os | 6 target_os = host_os |
22 } | 7 } |
23 | 8 |
24 if (target_cpu == "") { | 9 if (target_cpu == "") { |
25 if (target_os == "android") { | 10 if (target_os == "android") { |
26 # If we're building for Android, we should assume that we want to | 11 # If we're building for Android, we should assume that we want to |
27 # build for ARM by default, not the host_cpu (which is likely x64). | 12 # build for ARM by default, not the host_cpu (which is likely x64). |
28 # This allows us to not have to specify both target_os and target_cpu | 13 # This allows us to not have to specify both target_os and target_cpu |
29 # on the command line. | 14 # on the command line. |
30 target_cpu = "arm" | 15 target_cpu = "arm" |
31 } else { | 16 } else { |
32 target_cpu = host_cpu | 17 target_cpu = host_cpu |
33 } | 18 } |
34 } | 19 } |
35 | 20 |
36 if (current_cpu == "") { | 21 if (current_cpu == "") { |
37 current_cpu = target_cpu | 22 current_cpu = target_cpu |
38 } | 23 } |
39 if (current_os == "") { | 24 if (current_os == "") { |
40 current_os = target_os | 25 current_os = target_os |
41 } | 26 } |
42 | 27 |
| 28 # ============================================================================= |
| 29 # BUILD FLAGS |
| 30 # ============================================================================= |
| 31 # |
| 32 # This block lists input arguments to the build, along with their default |
| 33 # values. |
| 34 # |
| 35 # If a value is specified on the command line, it will overwrite the defaults |
| 36 # given in a declare_args block, otherwise the default will be used. |
| 37 # |
| 38 # YOU SHOULD ALMOST NEVER NEED TO ADD FLAGS TO THIS FILE. GN allows any file in |
| 39 # the build to declare build flags. If you need a flag for a single component, |
| 40 # you can just declare it in the corresponding BUILD.gn file. If you need a |
| 41 # flag in multiple components, there are a few options: |
| 42 # |
| 43 # - If your feature is a single target, say //components/foo, and the targets |
| 44 # depending on foo need to have some define set if foo is enabled: (1) Write |
| 45 # a declare_args block in foo's BUILD.gn file listing your enable_foo build |
| 46 # flag. (2) Write a config in that file listing the define, and list that |
| 47 # config in foo's public_configs. This will propagate that define to all the |
| 48 # targets depending on foo. (3) When foo is not enabled, just make it expand |
| 49 # to an empty group (or whatever's appropriate for the "off" state of your |
| 50 # feature. |
| 51 # |
| 52 # - If a semi-random set of targets need to know about a define: (1) In the |
| 53 # lowest level of the build that knows about this feature, add a declare_args |
| 54 # block in the build file for your enable flag. (2) Write a config that adds |
| 55 # a define conditionally based on that build flags. (3) Manually add that |
| 56 # config to the "configs" applying to the targets that need the define. |
| 57 # |
| 58 # - If a semi-random set of targets need to know about the build flag (to do |
| 59 # file inclusion or exclusion, more than just defines): (1) Write a .gni file |
| 60 # in the lowest-level directory that knows about the feature. (2) Put the |
| 61 # declare_args block with your build flag in that .gni file. (3) Import that |
| 62 # .gni file from the BUILD.gn files that need the flag. |
| 63 # |
| 64 # Other advice: |
| 65 # |
| 66 # - Use boolean values when possible. If you need a default value that expands |
| 67 # to some complex thing in the default case (like the location of the |
| 68 # compiler which would be computed by a script), use a default value of -1 or |
| 69 # the empty string. Outside of the declare_args block, conditionally expand |
| 70 # the default value as necessary. |
| 71 # |
| 72 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for |
| 73 # your feature) rather than just "foo". |
| 74 # |
| 75 # - Write good comments directly above the declaration with no blank line. |
| 76 # These comments will appear as documentation in "gn args --list". |
| 77 # |
| 78 # - Don't call exec_script inside declare_args. This will execute the script |
| 79 # even if the value is overridden, which is wasteful. See first bullet. |
| 80 |
43 declare_args() { | 81 declare_args() { |
44 # How many symbols to include in the build. This affects the performance of | 82 # How many symbols to include in the build. This affects the performance of |
45 # the build since the symbols are large and dealing with them is slow. | 83 # the build since the symbols are large and dealing with them is slow. |
46 # 2 means regular build with symbols. | 84 # 2 means regular build with symbols. |
47 # 1 means minimal symbols, usually enough for backtraces only. | 85 # 1 means minimal symbols, usually enough for backtraces only. |
48 # 0 means no symbols. | 86 # 0 means no symbols. |
49 # -1 means auto-set (off in release, regular in debug). | 87 # -1 means auto-set (off in release, regular in debug). |
50 symbol_level = -1 | 88 symbol_level = -1 |
51 | 89 |
52 # Component build. | 90 # Component build. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 124 |
87 # Compile for Thread Sanitizer to find threading bugs. | 125 # Compile for Thread Sanitizer to find threading bugs. |
88 is_tsan = false | 126 is_tsan = false |
89 | 127 |
90 if (current_os == "chromeos") { | 128 if (current_os == "chromeos") { |
91 # Allows the target toolchain to be injected as arguments. This is needed | 129 # Allows the target toolchain to be injected as arguments. This is needed |
92 # to support the CrOS build system which supports per-build-configuration | 130 # to support the CrOS build system which supports per-build-configuration |
93 # toolchains. | 131 # toolchains. |
94 cros_use_custom_toolchain = false | 132 cros_use_custom_toolchain = false |
95 } | 133 } |
| 134 |
| 135 # DON'T ADD MORE FLAGS HERE. Read the comment above. |
96 } | 136 } |
97 | 137 |
98 # ============================================================================= | 138 # ============================================================================= |
99 # OS DEFINITIONS | 139 # OS DEFINITIONS |
100 # ============================================================================= | 140 # ============================================================================= |
101 # | 141 # |
102 # We set these various is_FOO booleans for convenience in writing OS-based | 142 # We set these various is_FOO booleans for convenience in writing OS-based |
103 # conditions. | 143 # conditions. |
104 # | 144 # |
105 # - is_android, is_chromeos, is_ios, and is_win should be obvious. | 145 # - is_android, is_chromeos, is_ios, and is_win should be obvious. |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 } | 766 } |
727 if (defined(invoker.testonly)) { | 767 if (defined(invoker.testonly)) { |
728 testonly = invoker.testonly | 768 testonly = invoker.testonly |
729 } | 769 } |
730 if (defined(invoker.visibility)) { | 770 if (defined(invoker.visibility)) { |
731 visibility = invoker.visibility | 771 visibility = invoker.visibility |
732 } | 772 } |
733 } | 773 } |
734 } | 774 } |
735 } | 775 } |
OLD | NEW |