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

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

Issue 2211593002: Cleanup references to concurrent_links in gn binary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@concurrent_links
Patch Set: Fix unittests. Created 4 years, 4 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 | « tools/gn/docs/reference.md ('k') | tools/gn/ninja_build_writer.cc » ('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 <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 #include <utility> 7 #include <utility>
8 8
9 #include "tools/gn/err.h" 9 #include "tools/gn/err.h"
10 #include "tools/gn/functions.h" 10 #include "tools/gn/functions.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 " dependencies these must be targets defined in another toolchain.\n" 325 " dependencies these must be targets defined in another toolchain.\n"
326 "\n" 326 "\n"
327 " This is expressed as a list of targets, and generally these targets\n" 327 " This is expressed as a list of targets, and generally these targets\n"
328 " will always specify a toolchain:\n" 328 " will always specify a toolchain:\n"
329 " deps = [ \"//foo/bar:baz(//build/toolchain:bootstrap)\" ]\n" 329 " deps = [ \"//foo/bar:baz(//build/toolchain:bootstrap)\" ]\n"
330 "\n" 330 "\n"
331 " This concept is somewhat inefficient to express in Ninja (it\n" 331 " This concept is somewhat inefficient to express in Ninja (it\n"
332 " requires a lot of duplicate of rules) so should only be used when\n" 332 " requires a lot of duplicate of rules) so should only be used when\n"
333 " absolutely necessary.\n" 333 " absolutely necessary.\n"
334 "\n" 334 "\n"
335 " concurrent_links\n"
336 " In integer expressing the number of links that Ninja will perform in\n"
337 " parallel. GN will create a pool for shared library and executable\n"
338 " link steps with this many processes. Since linking is memory- and\n"
339 " I/O-intensive, projects with many large targets may want to limit\n"
340 " the number of parallel steps to avoid overloading the computer.\n"
341 " Since creating static libraries is generally not as intensive\n"
342 " there is no limit to \"alink\" steps.\n"
343 "\n"
344 " Defaults to 0 which Ninja interprets as \"no limit\".\n"
345 "\n"
346 " The value used will be the one from the default toolchain of the\n"
347 " current build.\n"
348 "\n"
349 "Invoking targets in toolchains:\n" 335 "Invoking targets in toolchains:\n"
350 "\n" 336 "\n"
351 " By default, when a target depends on another, there is an implicit\n" 337 " By default, when a target depends on another, there is an implicit\n"
352 " toolchain label that is inherited, so the dependee has the same one\n" 338 " toolchain label that is inherited, so the dependee has the same one\n"
353 " as the dependent.\n" 339 " as the dependent.\n"
354 "\n" 340 "\n"
355 " You can override this and refer to any other toolchain by explicitly\n" 341 " You can override this and refer to any other toolchain by explicitly\n"
356 " labeling the toolchain to use. For example:\n" 342 " labeling the toolchain to use. For example:\n"
357 " data_deps = [ \"//plugins:mine(//toolchains:plugin_toolchain)\" ]\n" 343 " data_deps = [ \"//plugins:mine(//toolchains:plugin_toolchain)\" ]\n"
358 " The string \"//build/toolchains:plugin_toolchain\" is a label that\n" 344 " The string \"//build/toolchains:plugin_toolchain\" is a label that\n"
359 " identifies the toolchain declaration for compiling the sources.\n" 345 " identifies the toolchain declaration for compiling the sources.\n"
360 "\n" 346 "\n"
361 " To load a file in an alternate toolchain, GN does the following:\n" 347 " To load a file in an alternate toolchain, GN does the following:\n"
362 "\n" 348 "\n"
363 " 1. Loads the file with the toolchain definition in it (as determined\n" 349 " 1. Loads the file with the toolchain definition in it (as determined\n"
364 " by the toolchain label).\n" 350 " by the toolchain label).\n"
365 " 2. Re-runs the master build configuration file, applying the\n" 351 " 2. Re-runs the master build configuration file, applying the\n"
366 " arguments specified by the toolchain_args section of the toolchain\n" 352 " arguments specified by the toolchain_args section of the toolchain\n"
367 " definition (see \"gn help toolchain_args\").\n" 353 " definition (see \"gn help toolchain_args\").\n"
368 " 3. Loads the destination build file in the context of the\n" 354 " 3. Loads the destination build file in the context of the\n"
369 " configuration file in the previous step.\n" 355 " configuration file in the previous step.\n"
370 "\n" 356 "\n"
371 "Example:\n" 357 "Example:\n"
372 " toolchain(\"plugin_toolchain\") {\n" 358 " toolchain(\"plugin_toolchain\") {\n"
373 " concurrent_links = 8\n"
374 "\n"
375 " tool(\"cc\") {\n" 359 " tool(\"cc\") {\n"
376 " command = \"gcc {{source}}\"\n" 360 " command = \"gcc {{source}}\"\n"
377 " ...\n" 361 " ...\n"
378 " }\n" 362 " }\n"
379 "\n" 363 "\n"
380 " toolchain_args() {\n" 364 " toolchain_args() {\n"
381 " is_plugin = true\n" 365 " is_plugin = true\n"
382 " is_32bit = true\n" 366 " is_32bit = true\n"
383 " is_64bit = false\n" 367 " is_64bit = false\n"
384 " }\n" 368 " }\n"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // Read deps (if any). 405 // Read deps (if any).
422 const Value* deps_value = block_scope.GetValue(variables::kDeps, true); 406 const Value* deps_value = block_scope.GetValue(variables::kDeps, true);
423 if (deps_value) { 407 if (deps_value) {
424 ExtractListOfLabels( 408 ExtractListOfLabels(
425 *deps_value, block_scope.GetSourceDir(), 409 *deps_value, block_scope.GetSourceDir(),
426 ToolchainLabelForScope(&block_scope), &toolchain->deps(), err); 410 ToolchainLabelForScope(&block_scope), &toolchain->deps(), err);
427 if (err->has_error()) 411 if (err->has_error())
428 return Value(); 412 return Value();
429 } 413 }
430 414
431 // Read concurrent_links (if any).
432 const Value* concurrent_links_value =
433 block_scope.GetValue("concurrent_links", true);
434 if (concurrent_links_value) {
435 if (!concurrent_links_value->VerifyTypeIs(Value::INTEGER, err))
436 return Value();
437 if (concurrent_links_value->int_value() < 0 ||
438 concurrent_links_value->int_value() > std::numeric_limits<int>::max()) {
439 *err = Err(*concurrent_links_value, "Value out of range.");
440 return Value();
441 }
442 toolchain->set_concurrent_links(
443 static_cast<int>(concurrent_links_value->int_value()));
444 }
445
446 if (!block_scope.CheckForUnusedVars(err)) 415 if (!block_scope.CheckForUnusedVars(err))
447 return Value(); 416 return Value();
448 417
449 // Save this toolchain. 418 // Save this toolchain.
450 toolchain->ToolchainSetupComplete(); 419 toolchain->ToolchainSetupComplete();
451 Scope::ItemVector* collector = scope->GetItemCollector(); 420 Scope::ItemVector* collector = scope->GetItemCollector();
452 if (!collector) { 421 if (!collector) {
453 *err = Err(function, "Can't define a toolchain in this context."); 422 *err = Err(function, "Can't define a toolchain in this context.");
454 return Value(); 423 return Value();
455 } 424 }
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 return Value(); 1085 return Value();
1117 1086
1118 Scope::KeyValueMap values; 1087 Scope::KeyValueMap values;
1119 block_scope.GetCurrentScopeValues(&values); 1088 block_scope.GetCurrentScopeValues(&values);
1120 toolchain->args() = values; 1089 toolchain->args() = values;
1121 1090
1122 return Value(); 1091 return Value();
1123 } 1092 }
1124 1093
1125 } // namespace functions 1094 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/docs/reference.md ('k') | tools/gn/ninja_build_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698