Tweak "Typical sources and deps modifications" section.
The current example, while a literal translation of the gyp version, is
misleading people: https://codereview.chromium.org/1906283002/#msg7
BUG=none
Review URL: https://codereview.chromium.org/1904383002
Cr-Original-Commit-Position: refs/heads/master@{#389077}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: fae1035167c4f29a410485d8bdaa928046c4aa22
diff --git a/tools/gn/docs/cookbook.md b/tools/gn/docs/cookbook.md
index 92bfeb5..cdd6a03 100644
--- a/tools/gn/docs/cookbook.md
+++ b/tools/gn/docs/cookbook.md
@@ -122,6 +122,7 @@
'sources': [
'a.cc',
'b.cc',
+ 'c.cc',
],
'dependencies': [
'<(DEPTH)/base/base.gyp:foo',
@@ -149,22 +150,26 @@
```
sources = [
- "a.cc",
- "b.cc",
+ "c.cc",
]
deps = [
"//base:foo",
]
if (is_win) {
- sources -= [ "a.cc" ]
- sources += [ "foo.cc" ]
+ sources += [
+ "b.cc",
+ "foo.cc',
+ ]
deps += [ "//base:bar" ]
} else {
- sources -= [ "b.cc" ]
+ sources += [ "a.cc" ]
}
```
+Note that in GN we prefer to only add files when needed, and don't add all of
+them at first only to remove them later like in gyp.
+
## Variable mappings
### Build configuration