Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Build Arguments | |
|
nyquist
2016/03/08 22:42:35
Should this page be linked to from somewhere?
Jess
2016/03/09 00:39:32
Done.
| |
| 2 | |
| 3 [Build arguments](../../tools/gn/docs/language.md#Build-arguments) | |
| 4 can be passed via the command line or an args.gn file to control the build. | |
|
nyquist
2016/03/08 22:42:35
Nit: could you do `args.gn`?
Jess
2016/03/09 00:39:32
Done.
| |
| 5 | |
| 6 This document addresses the creation of new build arguments for Blimp. See | |
| 7 [building](build.md) for developer GN args setup. | |
| 8 | |
| 9 ## Best Practices | |
| 10 | |
| 11 ### Scope | |
| 12 | |
| 13 Build arguments should be scoped to a unit of behavior, e.g. enabling a feature. | |
| 14 There are historic examples in core code that do not conform (e.g. target_os), | |
| 15 but the build team recommends this convention for all new arguments. | |
| 16 | |
| 17 Typically an argument would be declared in an imported file to share it with | |
| 18 the subset of the build that could make use of it. | |
| 19 | |
| 20 ### Type | |
| 21 | |
| 22 Arguments support all the | |
| 23 [GN language types](../../tools/gn/docs/language.md#Language). | |
| 24 | |
| 25 In the vast majority of cases boolean is the preferred type, since most | |
| 26 arguments are enabling or disabling features or includes. | |
| 27 | |
| 28 String are typically used for filepaths. They are also used for enumerated | |
|
nyquist
2016/03/08 22:42:35
Nit: Could you add ` around String to make it clea
Jess
2016/03/09 00:39:32
Done.
| |
| 29 options though integers and even sets of booleans are often used instead. | |
| 30 | |
| 31 ### Naming conventions | |
| 32 | |
| 33 While there are no hard and fast rules around argument naming there are | |
| 34 many common conventions. If you ever want to see the current list of argument | |
| 35 names and default values for your current checkout use | |
| 36 `gn args out/Debug --list --short`. | |
| 37 | |
| 38 `use_foo` - indicates dependencies or major codepaths to include (e.g. | |
| 39 `use_open_ssl`, `use_ozone`, `use_cups`) | |
| 40 | |
| 41 `enable_foo` - indicates feature or tools to be enabled (e.g. | |
| 42 `enable_google_now`, `enable_nacl`, `enable_remoting`, `enable_pdf`) | |
| 43 | |
| 44 `disable_foo` - _NOT_ recommended, use `enable_foo` instead with swapped default | |
| 45 value | |
| 46 | |
| 47 `is_foo` - usually a global state descriptor (e.g. `is_chrome_branded`, | |
| 48 `is_desktop_linux`); poor choice for non-globals | |
| 49 | |
| 50 `foo_use_bar` - prefixes can be used to indicate a limited scope for an argument | |
| 51 (e.g. `rtc_use_h264`, `v8_use_snapshot`) | |
| 52 | |
| 53 ## Declaring Build Args | |
| 54 | |
| 55 You declare which arguments you accept and specify default values via | |
| 56 `declare_args`. See `gn help buildargs` for an overview of how this works. | |
| 57 See `gn help declare_args` for specifics on declaring them. | |
| 58 | |
| 59 It is an error to declare a given argument more than once in a given scope, so | |
| 60 care should be used in scoping and naming arguments. | |
| 61 | |
| 62 ## Build Args for Behavior | |
| 63 | |
| 64 While build args directly affect build behavior and values they can not be | |
| 65 directly referenced in code. This can be handled with an entry in the | |
| 66 [defines](../../tools/gn/docs/reference.md#defines_C-preprocessor-defines) | |
| 67 set that can then be used in code. | |
| 68 | |
| 69 ## Updating Args Templates | |
| 70 | |
| 71 Blimp has default argument templates for the | |
| 72 [build/args/blimp_client.gn](../../build/args/blimp_client.gn) and | |
|
nyquist
2016/03/08 22:42:35
Could you make these paths surrounded by quotes?
L
Jess
2016/03/09 00:39:32
Done.
| |
| 73 [build/args/blimp_engine.gn](../../build/args/blimp_engine.gn). | |
|
nyquist
2016/03/08 22:42:35
Should we also describe here how to import them in
Jess
2016/03/09 00:39:32
Done.
| |
| 74 | |
| 75 If you create a new argument where the default behavior for the rest of chrome | |
| 76 does not match the default behavior of typical blimp build, | |
| 77 you should update the respective blimp argument template(s). | |
| OLD | NEW |