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

Side by Side Diff: tools/gn/docs/cookbook.md

Issue 1683123002: Mention how to convert "copies" from gyp to gn in the cookbook. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NEWLINE Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 Unlike GYP, where an action is a part of a target, GN actions are 57 Unlike GYP, where an action is a part of a target, GN actions are
58 separate targets that you then depend on via deps from other targets: 58 separate targets that you then depend on via deps from other targets:
59 59
60 ``` 60 ```
61 action("foo") { 61 action("foo") {
62 script = "bar.py" 62 script = "bar.py"
63 outputs = [ "$target_gen_dir/bar.out" ] 63 outputs = [ "$target_gen_dir/bar.out" ]
64 args = [ "--la_dee_da" ] 64 args = [ "--la_dee_da" ]
65 } 65 }
66 66
67 executable('foo.exe') { 67 executable("foo.exe") {
68 ... 68 ...
69 deps = [ ":foo" ] # Depend on the action to make sure it runs. 69 deps = [ ":foo" ] # Depend on the action to make sure it runs.
70 } 70 }
71 ``` 71 ```
72 72
73 Rules in GYP become `action_foreach` in GN which work like actions but 73 Rules in GYP become `action_foreach` in GN which work like actions but
74 iterate over a set of sources. 74 iterate over a set of sources.
75 75
76 ### Copies
77
78 GYP
79
80 ```
81 'copies': [
82 {
83 'destination': '<(PRODUCT_DIR)/',
84 'files': [
85 '../build/win/dbghelp_xp/dbghelp.dll',
86 ],
87 },
88 ],
89 ```
90
91 Unlike GYP, where copies are part of a target, GN copies are
92 separate targets that you then depend on via deps from other targets:
93
94 ```
95 copy("bar") {
96 sources = [ "../path/to/secret.dll" ]
97 outputs = [ "$root_out_dir/{{source_file_part}}" ]
98 }
99
100 component("base") {
101 ...
102 deps = [ "bar" } # Depend on the copy to make sure it runs.
103 }
104 ```
105
76 ## Platform checking 106 ## Platform checking
77 107
78 | *GYP* | *GN* | 108 | *GYP* | *GN* |
79 |:-------------------------------------|:---------------------| 109 |:-------------------------------------|:---------------------|
80 | `'conditions': [['OS=="win"', {` | `if (is_win) {` | 110 | `'conditions': [['OS=="win"', {` | `if (is_win) {` |
81 | `'conditions': [['OS=="linux"', {` | `if (is_linux) {` | 111 | `'conditions': [['OS=="linux"', {` | `if (is_linux) {` |
82 | `'conditions': [['OS=="android"', {` | `if (is_android) {` | 112 | `'conditions': [['OS=="android"', {` | `if (is_android) {` |
83 | `'conditions': [['OS=="mac"', {` | `if (is_mac) {` | 113 | `'conditions': [['OS=="mac"', {` | `if (is_mac) {` |
84 | `'conditions': [['OS=="ios"', {` | `if (is_ios) {` | 114 | `'conditions': [['OS=="ios"', {` | `if (is_ios) {` |
85 | `'conditions': [['chromeos==1', {` | `if (is_chromeos) {` | 115 | `'conditions': [['chromeos==1', {` | `if (is_chromeos) {` |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 670
641 ``` 671 ```
642 import("//mojo/public/tools/bindings/mojom.gni") 672 import("//mojo/public/tools/bindings/mojom.gni")
643 673
644 mojom("mojo_bindings") { 674 mojom("mojo_bindings") {
645 sources = [ 675 sources = [
646 "foo.mojom", 676 "foo.mojom",
647 ] 677 ]
648 } 678 }
649 ``` 679 ```
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698