OLD | NEW |
1 # GYP->GN Conversion Cookbook | 1 # GYP->GN Conversion Cookbook |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
5 ## Targets | 5 ## Targets |
6 | 6 |
7 | *GYP* | *GN*
| | 7 | *GYP* | *GN*
| |
8 |:-------------------------------------------------|:---------------------------
------------------------| | 8 |:-------------------------------------------------|:---------------------------
------------------------| |
9 | `'type': 'static_library', 'name': 'foo',` | `static_library("foo") {` o
r `source_set("foo") {` | | 9 | `'type': 'static_library', 'name': 'foo',` | `static_library("foo") {` o
r `source_set("foo") {` | |
10 | `'type': 'shared_library', 'name': 'foo',` | `shared_library("foo") {`
| | 10 | `'type': 'shared_library', 'name': 'foo',` | `shared_library("foo") {`
| |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 Other flags only apply to one `BUILD.gn` file and those flags are | 159 Other flags only apply to one `BUILD.gn` file and those flags are |
160 declared directly in that file (so other files can't use them). These | 160 declared directly in that file (so other files can't use them). These |
161 places are noted in the table below. | 161 places are noted in the table below. |
162 | 162 |
163 | *GYP* | *GN*
| *GN import* | | 163 | *GYP* | *GN*
| *GN import* | |
164 |:------------------------------------------------|:----------------------------
---------------|:-----------------------------------------------| | 164 |:------------------------------------------------|:----------------------------
---------------|:-----------------------------------------------| |
165 | `arm_float_abi` | `arm_float_abi`
| `//build/config/arm.gni` | | 165 | `arm_float_abi` | `arm_float_abi`
| `//build/config/arm.gni` | |
166 | `arm_neon` (0/1) | `arm_use_neon` (true/false)
| `//build/config/arm.gni` | | 166 | `arm_neon` (0/1) | `arm_use_neon` (true/false)
| `//build/config/arm.gni` | |
167 | `arm_neon_optional` (0/1) | `arm_optionally_use_neon` (t
rue/false) | `//build/config/arm.gni` | | 167 | `arm_neon_optional` (0/1) | `arm_optionally_use_neon` (t
rue/false) | `//build/config/arm.gni` | |
168 | `arm_version` | `arm_version`
| `//build/config/arm.gni` | | 168 | `arm_version` | `arm_version`
| `//build/config/arm.gni` | |
169 | `asan` (0/1) | `is_asan` (true/false)
| (global) | | 169 | `asan` (0/1) | `is_asan` (true/false)
| `//build/config/sanitizers/sanitizers.gni` | |
170 | `branding` ("Chromium"/"Chrome") | `is_chrome_branded` (true/fa
lse) | `//build/config/chrome_build.gni` | | 170 | `branding` ("Chromium"/"Chrome") | `is_chrome_branded` (true/fa
lse) | `//build/config/chrome_build.gni` | |
171 | `build_for_tool=="drmemory"` | `enable_iterator_debugging=f
alse` | (internal to `//build/config/BUILD.gn`) | | 171 | `build_for_tool=="drmemory"` | `enable_iterator_debugging=f
alse` | (internal to `//build/config/BUILD.gn`) | |
172 | `build_for_tool=="tsan"` | `enable_iterator_debugging=f
alse` | (internal to `//build/config/BUILD.gn`) | | 172 | `build_for_tool=="tsan"` | `enable_iterator_debugging=f
alse` | (internal to `//build/config/BUILD.gn`) | |
173 | `buildtype` ("Official"/"Dev") | `is_official_build` (true/fa
lse) | `//build/config/chrome_build.gni` | | 173 | `buildtype` ("Official"/"Dev") | `is_official_build` (true/fa
lse) | `//build/config/chrome_build.gni` | |
174 | `chrome_multiple_dll` (0/1) | `is_multi_dll_chrome` (true/
false) | `//build/config/chrome_build.gni` | | 174 | `chrome_multiple_dll` (0/1) | `is_multi_dll_chrome` (true/
false) | `//build/config/chrome_build.gni` | |
175 | `clang` (0/1) | `is_clang` (true/false)
| (global) | | 175 | `clang` (0/1) | `is_clang` (true/false)
| (global) | |
176 | `clang_use_chrome_plugins` (0/1) | `clang_use_chrome_plugins` (
true/false) | (internal to `//build/config/clang/BUILD.gn`) | | 176 | `clang_use_chrome_plugins` (0/1) | `clang_use_chrome_plugins` (
true/false) | (internal to `//build/config/clang/BUILD.gn`) | |
177 | `component` ("shared_library"/"static_library") | `is_component_build` (true/f
alse) | (global) | | 177 | `component` ("shared_library"/"static_library") | `is_component_build` (true/f
alse) | (global) | |
178 | `desktop_linux` (0/1) | `is_desktop_linux` (true/fal
se) | (global) | | 178 | `desktop_linux` (0/1) | `is_desktop_linux` (true/fal
se) | (global) | |
179 | `disable_glibcxx_debug` (0/1) | `enable_iterator_debugging`
(true/false) | (internal to `//build/config/BUILD.gn`) | | 179 | `disable_glibcxx_debug` (0/1) | `enable_iterator_debugging`
(true/false) | (internal to `//build/config/BUILD.gn`) | |
180 | `fastbuild` (0/1/2) | `symbol_level` (2/1/0 — valu
es inverted) | (global) | | 180 | `fastbuild` (0/1/2) | `symbol_level` (2/1/0 — valu
es inverted) | `//build/config/compiler/compiler.gni` | |
181 | `gomadir` | `goma_dir`
| `//build/toolchain/goma.gni` | | 181 | `gomadir` | `goma_dir`
| `//build/toolchain/goma.gni` | |
182 | `ios_deployment_target` (string) | `ios_deployment_target`
| `//build/config/ios/ios_sdk.gni` | | 182 | `ios_deployment_target` (string) | `ios_deployment_target`
| `//build/config/ios/ios_sdk.gni` | |
183 | `GYP_MSVS_OVERRIDE_PATH` environment variable | `visual_studio_path`
| `//build/config/win/visual_studio_version.gni` | | 183 | `GYP_MSVS_OVERRIDE_PATH` environment variable | `visual_studio_path`
| `//build/config/win/visual_studio_version.gni` | |
184 | `GYP_MSVS_VERSION` environment variable | (none)
| | | 184 | `GYP_MSVS_VERSION` environment variable | (none)
| | |
185 | `ios_sdk_path` | `ios_sdk_path` and `use_ios_
simulator` | `//build/config/ios/ios_sdk.gni` | | 185 | `ios_sdk_path` | `ios_sdk_path` and `use_ios_
simulator` | `//build/config/ios/ios_sdk.gni` | |
186 | `lsan` (0/1) | `is_lsan` (true/false)
| (global) | | 186 | `lsan` (0/1) | `is_lsan` (true/false)
| `//build/config/sanitizers/sanitizers.gni` | |
187 | `mac_sdk_min` | `mac_sdk_min`
| `//build/config/mac/mac_sdk.gni` | | 187 | `mac_sdk_min` | `mac_sdk_min`
| `//build/config/mac/mac_sdk.gni` | |
188 | `mac_sdk_path` | `mac_sdk_path`
| `//build/config/mac/mac_sdk.gni` | | 188 | `mac_sdk_path` | `mac_sdk_path`
| `//build/config/mac/mac_sdk.gni` | |
189 | `mac_sdk` | `mac_sdk_version`
| `//build/config/mac/mac_sdk.gni` | | 189 | `mac_sdk` | `mac_sdk_version`
| `//build/config/mac/mac_sdk.gni` | |
190 | `msan` (0/1) | `is_msan` (true/false)
| (global) | | 190 | `msan` (0/1) | `is_msan` (true/false)
| `//build/config/sanitizers/sanitizers.gni` | |
191 | `SDKROOT` (Mac) | `sysroot`
| `//build/config/sysroot.gni` | | 191 | `SDKROOT` (Mac) | `sysroot`
| `//build/config/sysroot.gni` | |
192 | `sysroot` | `sysroot`
| `//build/config/sysroot.gni` | | 192 | `sysroot` | `sysroot`
| `//build/config/sysroot.gni` | |
193 | `target_arch` ("ia32"/"x64"/"arm"/"mipsel") | `target_arch` ("x86"/"x64"/"
arm"/"mipsel") | (global) | | 193 | `target_arch` ("ia32"/"x64"/"arm"/"mipsel") | `target_arch` ("x86"/"x64"/"
arm"/"mipsel") | (global) | |
194 | `toolkit_views` (0/1) | `toolkit_views`
| `//build/config/ui.gni` | | 194 | `toolkit_views` (0/1) | `toolkit_views`
| `//build/config/ui.gni` | |
195 | `tsan` (0/1) | `is_tsan` (true/false)
| (global) | | 195 | `tsan` (0/1) | `is_tsan` (true/false)
| `//build/config/sanitizers/sanitizers.gni` | |
196 | `windows_sdk_path` | `windows_sdk_path`
| (internal to `//build/config/win/BUILD.gn`) | | 196 | `windows_sdk_path` | `windows_sdk_path`
| (internal to `//build/config/win/BUILD.gn`) | |
197 | 197 |
198 ### Feature flags | 198 ### Feature flags |
199 | 199 |
200 | *GYP* | *GN*
| *GN import* | | 200 | *GYP* | *GN*
| *GN import* | |
201 |:----------------------------------------|:------------------------------------
-----------|:------------------------------| | 201 |:----------------------------------------|:------------------------------------
-----------|:------------------------------| |
202 | `cld_version` (number) | `cld_version` (number)
| `//build/config/features.gni` | | 202 | `cld_version` (number) | `cld_version` (number)
| `//build/config/features.gni` | |
203 | `configuration_policy` (0/1) | `enable_configuration_policy` (true/
false) | `//build/config/features.gni` | | 203 | `configuration_policy` (0/1) | `enable_configuration_policy` (true/
false) | `//build/config/features.gni` | |
204 | `debug_devtools` (0/1) | `debug_devtools` (true/false)
| `//build/config/features.gni` | | 204 | `debug_devtools` (0/1) | `debug_devtools` (true/false)
| `//build/config/features.gni` | |
205 | `disable_ftp_support` (0/1) | `disable_ftp_support` (true/false)
| `//build/config/features.gni` | | 205 | `disable_ftp_support` (0/1) | `disable_ftp_support` (true/false)
| `//build/config/features.gni` | |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 565 |
566 ``` | 566 ``` |
567 'optimize': 'max', | 567 'optimize': 'max', |
568 ``` | 568 ``` |
569 | 569 |
570 only affects Windows and will optimize for speed rather than size. To | 570 only affects Windows and will optimize for speed rather than size. To |
571 get the same behavior in GN, do: | 571 get the same behavior in GN, do: |
572 | 572 |
573 ``` | 573 ``` |
574 if (!is_debug && is_win) { | 574 if (!is_debug && is_win) { |
575 configs -= [ "//build/config/compiler:optimize" ] | 575 configs -= [ "//build/config/compiler:default_optimization" ] |
576 configs += [ "//build/config/compiler:optimize_max" ] | 576 configs += [ "//build/config/compiler:optimize_max" ] |
577 } | 577 } |
578 ``` | 578 ``` |
579 | 579 |
580 The `is_win` check is needed because the `optimize_max` config also | 580 The `is_win` check is needed because the `optimize_max` config also |
581 affects Posix systems. Some components might additionally specify `-O2` | 581 affects Posix systems. Some components might additionally specify `-O2` |
582 on Posix further optimize, in which case you can remove the `is_win` | 582 on Posix further optimize, in which case you can remove the `is_win` |
583 check. | 583 check. |
584 | 584 |
585 ### Protobufs | 585 ### Protobufs |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 642 |
643 ``` | 643 ``` |
644 import("//mojo/public/tools/bindings/mojom.gni") | 644 import("//mojo/public/tools/bindings/mojom.gni") |
645 | 645 |
646 mojom("mojo_bindings") { | 646 mojom("mojo_bindings") { |
647 sources = [ | 647 sources = [ |
648 "foo.mojom", | 648 "foo.mojom", |
649 ] | 649 ] |
650 } | 650 } |
651 ``` | 651 ``` |
OLD | NEW |