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

Side by Side Diff: tools/gn/label.cc

Issue 2504133003: Add more gn documentation (Closed)
Patch Set: Created 4 years, 1 month 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 | « tools/gn/label.h ('k') | tools/gn/ninja_build_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "tools/gn/label.h" 5 #include "tools/gn/label.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "tools/gn/err.h" 10 #include "tools/gn/err.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return Resolve(current_dir, current_toolchain, original_value, 186 return Resolve(current_dir, current_toolchain, original_value,
187 toolchain_piece, out_toolchain_dir, out_toolchain_name, 187 toolchain_piece, out_toolchain_dir, out_toolchain_name,
188 nullptr, nullptr, err); 188 nullptr, nullptr, err);
189 } 189 }
190 } 190 }
191 return true; 191 return true;
192 } 192 }
193 193
194 } // namespace 194 } // namespace
195 195
196 const char kLabels_Help[] =
197 R"*(About labels
198
199 Everything that can participate in the dependency graph (targets, configs,
200 and toolchains) are identified by labels. A common label looks like:
201
202 //base/test:test_support
203
204 This consists of a source-root-absolute path, a colon, and a name. This means
205 to look for the thing named "test_support" in "base/test/BUILD.gn".
206
207 You can also specify system absolute paths if necessary. Typically such
208 paths would be specified via a build arg so the developer can specify where
209 the component is on their system.
210
211 /usr/local/foo:bar (Posix)
212 /C:/Program Files/MyLibs:bar (Windows)
213
214 Toolchains
215
216 A canonical label includes the label of the toolchain being used. Normally,
217 the toolchain label is implicitly inherited from the current execution
218 context, but you can override this to specify cross-toolchain dependencies:
219
220 //base/test:test_support(//build/toolchain/win:msvc)
221
222 Here GN will look for the toolchain definition called "msvc" in the file
223 "//build/toolchain/win" to know how to compile this target.
224
225 Relative labels
226
227 If you want to refer to something in the same buildfile, you can omit
228 the path name and just start with a colon. This format is recommended for
229 all same-file references.
230
231 :base
232
233 Labels can be specified as being relative to the current directory.
234 Stylistically, we prefer to use absolute paths for all non-file-local
235 references unless a build file needs to be run in different contexts (like a
236 project needs to be both standalone and pulled into other projects in
237 difference places in the directory hierarchy).
238
239 source/plugin:myplugin
240 ../net:url_request
241
242 Implicit names
243
244 If a name is unspecified, it will inherit the directory name. Stylistically,
245 we prefer to omit the colon and name when possible:
246
247 //net -> //net:net
248 //tools/gn -> //tools/gn:gn
249 )*";
250
196 Label::Label() { 251 Label::Label() {
197 } 252 }
198 253
199 Label::Label(const SourceDir& dir, 254 Label::Label(const SourceDir& dir,
200 const base::StringPiece& name, 255 const base::StringPiece& name,
201 const SourceDir& toolchain_dir, 256 const SourceDir& toolchain_dir,
202 const base::StringPiece& toolchain_name) 257 const base::StringPiece& toolchain_name)
203 : dir_(dir), 258 : dir_(dir),
204 toolchain_dir_(toolchain_dir) { 259 toolchain_dir_(toolchain_dir) {
205 name_.assign(name.data(), name.size()); 260 name_.assign(name.data(), name.size());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 325 }
271 return ret; 326 return ret;
272 } 327 }
273 328
274 std::string Label::GetUserVisibleName(const Label& default_toolchain) const { 329 std::string Label::GetUserVisibleName(const Label& default_toolchain) const {
275 bool include_toolchain = 330 bool include_toolchain =
276 default_toolchain.dir() != toolchain_dir_ || 331 default_toolchain.dir() != toolchain_dir_ ||
277 default_toolchain.name() != toolchain_name_; 332 default_toolchain.name() != toolchain_name_;
278 return GetUserVisibleName(include_toolchain); 333 return GetUserVisibleName(include_toolchain);
279 } 334 }
OLDNEW
« no previous file with comments | « tools/gn/label.h ('k') | tools/gn/ninja_build_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698