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

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

Issue 2481423002: Convert gn docstrings to C++11 raw strings. (Closed)
Patch Set: More 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
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 295 }
296 296
297 } // namespace 297 } // namespace
298 298
299 // toolchain ------------------------------------------------------------------- 299 // toolchain -------------------------------------------------------------------
300 300
301 const char kToolchain[] = "toolchain"; 301 const char kToolchain[] = "toolchain";
302 const char kToolchain_HelpShort[] = 302 const char kToolchain_HelpShort[] =
303 "toolchain: Defines a toolchain."; 303 "toolchain: Defines a toolchain.";
304 const char kToolchain_Help[] = 304 const char kToolchain_Help[] =
305 "toolchain: Defines a toolchain.\n" 305 R"*(toolchain: Defines a toolchain.
306 "\n" 306
307 " A toolchain is a set of commands and build flags used to compile the\n" 307 A toolchain is a set of commands and build flags used to compile the source
308 " source code. You can have more than one toolchain in use at once in\n" 308 code. You can have more than one toolchain in use at once in a build.
309 " a build.\n" 309
310 "\n" 310 Functions and variables
311 "Functions and variables\n" 311
312 "\n" 312 tool()
313 " tool()\n" 313 The tool() function call specifies the commands commands to run for a given
314 " The tool() function call specifies the commands commands to run for\n" 314 step. See "gn help tool".
315 " a given step. See \"gn help tool\".\n" 315
316 "\n" 316 toolchain_args
317 " toolchain_args\n" 317 Overrides for build arguments to pass to the toolchain when invoking it.
318 " Overrides for build arguments to pass to the toolchain when invoking\n" 318 This is a variable of type "scope" where the variable names correspond to
319 " it. This is a variable of type \"scope\" where the variable names\n" 319 variables in declare_args() blocks.
320 " correspond to variables in declare_args() blocks.\n" 320
321 "\n" 321 When you specify a target using an alternate toolchain, the master build
322 " When you specify a target using an alternate toolchain, the master\n" 322 configuration file is re-interpreted in the context of that toolchain.
323 " build configuration file is re-interpreted in the context of that\n" 323 toolchain_args allows you to control the arguments passed into this
324 " toolchain. toolchain_args allows you to control the arguments\n" 324 alternate invocation of the build.
325 " passed into this alternate invocation of the build.\n" 325
326 "\n" 326 Any default system arguments or arguments passed in via "gn args" will also
327 " Any default system arguments or arguments passed in via \"gn args\"\n" 327 be passed to the alternate invocation unless explicitly overridden by
328 " will also be passed to the alternate invocation unless explicitly\n" 328 toolchain_args.
329 " overridden by toolchain_args.\n" 329
330 "\n" 330 The toolchain_args will be ignored when the toolchain being defined is the
331 " The toolchain_args will be ignored when the toolchain being defined\n" 331 default. In this case, it's expected you want the default argument values.
332 " is the default. In this case, it's expected you want the default\n" 332
333 " argument values.\n" 333 See also "gn help buildargs" for an overview of these arguments.
334 "\n" 334
335 " See also \"gn help buildargs\" for an overview of these arguments.\n" 335 deps
336 "\n" 336 Dependencies of this toolchain. These dependencies will be resolved before
337 " deps\n" 337 any target in the toolchain is compiled. To avoid circular dependencies
338 " Dependencies of this toolchain. These dependencies will be resolved\n" 338 these must be targets defined in another toolchain.
339 " before any target in the toolchain is compiled. To avoid circular\n" 339
340 " dependencies these must be targets defined in another toolchain.\n" 340 This is expressed as a list of targets, and generally these targets will
341 "\n" 341 always specify a toolchain:
342 " This is expressed as a list of targets, and generally these targets\n" 342 deps = [ "//foo/bar:baz(//build/toolchain:bootstrap)" ]
343 " will always specify a toolchain:\n" 343
344 " deps = [ \"//foo/bar:baz(//build/toolchain:bootstrap)\" ]\n" 344 This concept is somewhat inefficient to express in Ninja (it requires a lot
345 "\n" 345 of duplicate of rules) so should only be used when absolutely necessary.
346 " This concept is somewhat inefficient to express in Ninja (it\n" 346
347 " requires a lot of duplicate of rules) so should only be used when\n" 347 Invoking targets in toolchains
348 " absolutely necessary.\n" 348
349 "\n" 349 By default, when a target depends on another, there is an implicit toolchain
350 "Invoking targets in toolchains:\n" 350 label that is inherited, so the dependee has the same one as the dependent.
351 "\n" 351
352 " By default, when a target depends on another, there is an implicit\n" 352 You can override this and refer to any other toolchain by explicitly
353 " toolchain label that is inherited, so the dependee has the same one\n" 353 labeling the toolchain to use. For example:
354 " as the dependent.\n" 354 data_deps = [ "//plugins:mine(//toolchains:plugin_toolchain)" ]
355 "\n" 355 The string "//build/toolchains:plugin_toolchain" is a label that identifies
356 " You can override this and refer to any other toolchain by explicitly\n" 356 the toolchain declaration for compiling the sources.
357 " labeling the toolchain to use. For example:\n" 357
358 " data_deps = [ \"//plugins:mine(//toolchains:plugin_toolchain)\" ]\n" 358 To load a file in an alternate toolchain, GN does the following:
359 " The string \"//build/toolchains:plugin_toolchain\" is a label that\n" 359
360 " identifies the toolchain declaration for compiling the sources.\n" 360 1. Loads the file with the toolchain definition in it (as determined by the
361 "\n" 361 toolchain label).
362 " To load a file in an alternate toolchain, GN does the following:\n" 362 2. Re-runs the master build configuration file, applying the arguments
363 "\n" 363 specified by the toolchain_args section of the toolchain definition.
364 " 1. Loads the file with the toolchain definition in it (as determined\n" 364 3. Loads the destination build file in the context of the configuration file
365 " by the toolchain label).\n" 365 in the previous step.
366 " 2. Re-runs the master build configuration file, applying the\n" 366
367 " arguments specified by the toolchain_args section of the toolchain\n" 367 Example
368 " definition.\n" 368
369 " 3. Loads the destination build file in the context of the\n" 369 toolchain("plugin_toolchain") {
370 " configuration file in the previous step.\n" 370 tool("cc") {
371 "\n" 371 command = "gcc {{source}}"
372 "Example\n" 372 ...
373 "\n" 373 }
374 " toolchain(\"plugin_toolchain\") {\n" 374
375 " tool(\"cc\") {\n" 375 toolchain_args = {
376 " command = \"gcc {{source}}\"\n" 376 is_plugin = true
377 " ...\n" 377 is_32bit = true
378 " }\n" 378 is_64bit = false
379 "\n" 379 }
380 " toolchain_args = {\n" 380 };)*";
scottmg 2016/11/08 01:01:46 here
381 " is_plugin = true\n"
382 " is_32bit = true\n"
383 " is_64bit = false\n"
384 " }\n"
385 " }\n";
386 381
387 Value RunToolchain(Scope* scope, 382 Value RunToolchain(Scope* scope,
388 const FunctionCallNode* function, 383 const FunctionCallNode* function,
389 const std::vector<Value>& args, 384 const std::vector<Value>& args,
390 BlockNode* block, 385 BlockNode* block,
391 Err* err) { 386 Err* err) {
392 NonNestableBlock non_nestable(scope, function, "toolchain"); 387 NonNestableBlock non_nestable(scope, function, "toolchain");
393 if (!non_nestable.Enter(err)) 388 if (!non_nestable.Enter(err))
394 return Value(); 389 return Value();
395 390
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 collector->push_back(toolchain.release()); 447 collector->push_back(toolchain.release());
453 return Value(); 448 return Value();
454 } 449 }
455 450
456 // tool ------------------------------------------------------------------------ 451 // tool ------------------------------------------------------------------------
457 452
458 const char kTool[] = "tool"; 453 const char kTool[] = "tool";
459 const char kTool_HelpShort[] = 454 const char kTool_HelpShort[] =
460 "tool: Specify arguments to a toolchain tool."; 455 "tool: Specify arguments to a toolchain tool.";
461 const char kTool_Help[] = 456 const char kTool_Help[] =
462 "tool: Specify arguments to a toolchain tool.\n" 457 R"(tool: Specify arguments to a toolchain tool.
463 "\n" 458
464 "Usage:\n" 459 Usage
465 "\n" 460
466 " tool(<tool type>) {\n" 461 tool(<tool type>) {
467 " <tool variables...>\n" 462 <tool variables...>
468 " }\n" 463 }
469 "\n" 464
470 "Tool types\n" 465 Tool types
471 "\n" 466
472 " Compiler tools:\n" 467 Compiler tools:
473 " \"cc\": C compiler\n" 468 "cc": C compiler
474 " \"cxx\": C++ compiler\n" 469 "cxx": C++ compiler
475 " \"objc\": Objective C compiler\n" 470 "objc": Objective C compiler
476 " \"objcxx\": Objective C++ compiler\n" 471 "objcxx": Objective C++ compiler
477 " \"rc\": Resource compiler (Windows .rc files)\n" 472 "rc": Resource compiler (Windows .rc files)
478 " \"asm\": Assembler\n" 473 "asm": Assembler
479 "\n" 474
480 " Linker tools:\n" 475 Linker tools:
481 " \"alink\": Linker for static libraries (archives)\n" 476 "alink": Linker for static libraries (archives)
482 " \"solink\": Linker for shared libraries\n" 477 "solink": Linker for shared libraries
483 " \"link\": Linker for executables\n" 478 "link": Linker for executables
484 "\n" 479
485 " Other tools:\n" 480 Other tools:
486 " \"stamp\": Tool for creating stamp files\n" 481 "stamp": Tool for creating stamp files
487 " \"copy\": Tool to copy files.\n" 482 "copy": Tool to copy files.
488 "\n" 483
489 " Platform specific tools:\n" 484 Platform specific tools:
490 " \"copy_bundle_data\": [iOS, OS X] Tool to copy files in a bundle.\n" 485 "copy_bundle_data": [iOS, OS X] Tool to copy files in a bundle.
491 " \"compile_xcassets\": [iOS, OS X] Tool to compile asset catalogs.\n" 486 "compile_xcassets": [iOS, OS X] Tool to compile asset catalogs.
492 "\n" 487
493 "Tool variables\n" 488 Tool variables
494 "\n" 489
495 " command [string with substitutions]\n" 490 command [string with substitutions]
496 " Valid for: all tools (required)\n" 491 Valid for: all tools (required)
497 "\n" 492
498 " The command to run.\n" 493 The command to run.
499 "\n" 494
500 " default_output_dir [string with substitutions]\n" 495 default_output_dir [string with substitutions]
501 " Valid for: linker tools\n" 496 Valid for: linker tools
502 "\n" 497
503 " Default directory name for the output file relative to the\n" 498 Default directory name for the output file relative to the
504 " root_build_dir. It can contain other substitution patterns.\n" 499 root_build_dir. It can contain other substitution patterns. This will
505 " This will be the default value for the {{output_dir}} expansion\n" 500 be the default value for the {{output_dir}} expansion (discussed below)
506 " (discussed below) but will be overridden by the \"output_dir\"\n" 501 but will be overridden by the "output_dir" variable in a target, if one
507 " variable in a target, if one is specified.\n" 502 is specified.
508 "\n" 503
509 " GN doesn't do anything with this string other than pass it\n" 504 GN doesn't do anything with this string other than pass it along,
510 " along, potentially with target-specific overrides. It is the\n" 505 potentially with target-specific overrides. It is the tool's job to use
511 " tool's job to use the expansion so that the files will be in\n" 506 the expansion so that the files will be in the right place.
512 " the right place.\n" 507
513 "\n" 508 default_output_extension [string]
514 " default_output_extension [string]\n" 509 Valid for: linker tools
515 " Valid for: linker tools\n" 510
516 "\n" 511 Extension for the main output of a linkable tool. It includes the
517 " Extension for the main output of a linkable tool. It includes\n" 512 leading dot. This will be the default value for the
518 " the leading dot. This will be the default value for the\n" 513 {{output_extension}} expansion (discussed below) but will be overridden
519 " {{output_extension}} expansion (discussed below) but will be\n" 514 by by the "output extension" variable in a target, if one is specified.
520 " overridden by by the \"output extension\" variable in a target,\n" 515 Empty string means no extension.
521 " if one is specified. Empty string means no extension.\n" 516
522 "\n" 517 GN doesn't actually do anything with this extension other than pass it
523 " GN doesn't actually do anything with this extension other than\n" 518 along, potentially with target-specific overrides. One would typically
524 " pass it along, potentially with target-specific overrides. One\n" 519 use the {{output_extension}} value in the "outputs" to read this value.
525 " would typically use the {{output_extension}} value in the\n" 520
526 " \"outputs\" to read this value.\n" 521 Example: default_output_extension = ".exe"
527 "\n" 522
528 " Example: default_output_extension = \".exe\"\n" 523 depfile [string with substitutions]
529 "\n" 524 Valid for: compiler tools (optional)
530 " depfile [string with substitutions]\n" 525
531 " Valid for: compiler tools (optional)\n" 526 If the tool can write ".d" files, this specifies the name of the
532 "\n" 527 resulting file. These files are used to list header file dependencies
533 " If the tool can write \".d\" files, this specifies the name of\n" 528 (or other implicit input dependencies) that are discovered at build
534 " the resulting file. These files are used to list header file\n" 529 time. See also "depsformat".
535 " dependencies (or other implicit input dependencies) that are\n" 530
536 " discovered at build time. See also \"depsformat\".\n" 531 Example: depfile = "{{output}}.d"
537 "\n" 532
538 " Example: depfile = \"{{output}}.d\"\n" 533 depsformat [string]
539 "\n" 534 Valid for: compiler tools (when depfile is specified)
540 " depsformat [string]\n" 535
541 " Valid for: compiler tools (when depfile is specified)\n" 536 Format for the deps outputs. This is either "gcc" or "msvc". See the
542 "\n" 537 ninja documentation for "deps" for more information.
543 " Format for the deps outputs. This is either \"gcc\" or \"msvc\".\n" 538
544 " See the ninja documentation for \"deps\" for more information.\n" 539 Example: depsformat = "gcc"
545 "\n" 540
546 " Example: depsformat = \"gcc\"\n" 541 description [string with substitutions, optional]
547 "\n" 542 Valid for: all tools
548 " description [string with substitutions, optional]\n" 543
549 " Valid for: all tools\n" 544 What to print when the command is run.
550 "\n" 545
551 " What to print when the command is run.\n" 546 Example: description = "Compiling {{source}}"
552 "\n" 547
553 " Example: description = \"Compiling {{source}}\"\n" 548 lib_switch [string, optional, link tools only]
554 "\n" 549 lib_dir_switch [string, optional, link tools only]
555 " lib_switch [string, optional, link tools only]\n" 550 Valid for: Linker tools except "alink"
556 " lib_dir_switch [string, optional, link tools only]\n" 551
557 " Valid for: Linker tools except \"alink\"\n" 552 These strings will be prepended to the libraries and library search
558 "\n" 553 directories, respectively, because linkers differ on how specify them.
559 " These strings will be prepended to the libraries and library\n" 554 If you specified:
560 " search directories, respectively, because linkers differ on how\n" 555 lib_switch = "-l"
561 " specify them. If you specified:\n" 556 lib_dir_switch = "-L"
562 " lib_switch = \"-l\"\n" 557 then the "{{libs}}" expansion for [ "freetype", "expat"] would be
563 " lib_dir_switch = \"-L\"\n" 558 "-lfreetype -lexpat".
564 " then the \"{{libs}}\" expansion for [ \"freetype\", \"expat\"]\n" 559
565 " would be \"-lfreetype -lexpat\".\n" 560 outputs [list of strings with substitutions]
566 "\n" 561 Valid for: Linker and compiler tools (required)
567 " outputs [list of strings with substitutions]\n" 562
568 " Valid for: Linker and compiler tools (required)\n" 563 An array of names for the output files the tool produces. These are
569 "\n" 564 relative to the build output directory. There must always be at least
570 " An array of names for the output files the tool produces. These\n" 565 one output file. There can be more than one output (a linker might
571 " are relative to the build output directory. There must always be\n" 566 produce a library and an import library, for example).
572 " at least one output file. There can be more than one output (a\n" 567
573 " linker might produce a library and an import library, for\n" 568 This array just declares to GN what files the tool will produce. It is
574 " example).\n" 569 your responsibility to specify the tool command that actually produces
575 "\n" 570 these files.
576 " This array just declares to GN what files the tool will\n" 571
577 " produce. It is your responsibility to specify the tool command\n" 572 If you specify more than one output for shared library links, you
578 " that actually produces these files.\n" 573 should consider setting link_output, depend_output, and
579 "\n" 574 runtime_outputs.
580 " If you specify more than one output for shared library links,\n" 575
581 " you should consider setting link_output, depend_output, and\n" 576 Example for a compiler tool that produces .obj files:
582 " runtime_outputs.\n" 577 outputs = [
583 "\n" 578 "{{source_out_dir}}/{{source_name_part}}.obj"
584 " Example for a compiler tool that produces .obj files:\n" 579 ]
585 " outputs = [\n" 580
586 " \"{{source_out_dir}}/{{source_name_part}}.obj\"\n" 581 Example for a linker tool that produces a .dll and a .lib. The use of
587 " ]\n" 582 {{target_output_name}}, {{output_extension}} and {{output_dir}} allows
588 "\n" 583 the target to override these values.
589 " Example for a linker tool that produces a .dll and a .lib. The\n" 584 outputs = [
590 " use of {{target_output_name}}, {{output_extension}} and\n" 585 "{{output_dir}}/{{target_output_name}}"
591 " {{output_dir}} allows the target to override these values.\n" 586 "{{output_extension}}",
592 " outputs = [\n" 587 "{{output_dir}}/{{target_output_name}}.lib",
593 " \"{{output_dir}}/{{target_output_name}}" 588 ]
594 "{{output_extension}}\",\n" 589
595 " \"{{output_dir}}/{{target_output_name}}.lib\",\n" 590 pool [label, optional]
596 " ]\n" 591
597 "\n" 592 Label of the pool to use for the tool. Pools are used to limit the
598 " pool [label, optional]\n" 593 number of tasks that can execute concurrently during the build.
599 "\n" 594
600 " Label of the pool to use for the tool. Pools are used to limit\n" 595 See also "gn help pool".
601 " the number of tasks that can execute concurrently during the\n" 596
602 " build.\n" 597 link_output [string with substitutions]
603 "\n" 598 depend_output [string with substitutions]
604 " See also \"gn help pool\".\n" 599 Valid for: "solink" only (optional)
605 "\n" 600
606 " link_output [string with substitutions]\n" 601 These two files specify which of the outputs from the solink tool
607 " depend_output [string with substitutions]\n" 602 should be used for linking and dependency tracking. These should match
608 " Valid for: \"solink\" only (optional)\n" 603 entries in the "outputs". If unspecified, the first item in the
609 "\n" 604 "outputs" array will be used for all. See "Separate linking and
610 " These two files specify which of the outputs from the solink\n" 605 dependencies for shared libraries" below for more.
611 " tool should be used for linking and dependency tracking. These\n" 606
612 " should match entries in the \"outputs\". If unspecified, the\n" 607 On Windows, where the tools produce a .dll shared library and a .lib
613 " first item in the \"outputs\" array will be used for all. See\n" 608 import library, you will want the first two to be the import library
614 " \"Separate linking and dependencies for shared libraries\"\n" 609 and the third one to be the .dll file. On Linux, if you're not doing
615 " below for more.\n" 610 the separate linking/dependency optimization, all of these should be
616 "\n" 611 the .so output.
617 " On Windows, where the tools produce a .dll shared library and\n" 612
618 " a .lib import library, you will want the first two to be the\n" 613 output_prefix [string]
619 " import library and the third one to be the .dll file.\n" 614 Valid for: Linker tools (optional)
620 " On Linux, if you're not doing the separate linking/dependency\n" 615
621 " optimization, all of these should be the .so output.\n" 616 Prefix to use for the output name. Defaults to empty. This prefix will
622 "\n" 617 be prepended to the name of the target (or the output_name if one is
623 " output_prefix [string]\n" 618 manually specified for it) if the prefix is not already there. The
624 " Valid for: Linker tools (optional)\n" 619 result will show up in the {{output_name}} substitution pattern.
625 "\n" 620
626 " Prefix to use for the output name. Defaults to empty. This\n" 621 Individual targets can opt-out of the output prefix by setting:
627 " prefix will be prepended to the name of the target (or the\n" 622 output_prefix_override = true
628 " output_name if one is manually specified for it) if the prefix\n" 623 (see "gn help output_prefix_override").
629 " is not already there. The result will show up in the\n" 624
630 " {{output_name}} substitution pattern.\n" 625 This is typically used to prepend "lib" to libraries on
631 "\n" 626 Posix systems:
632 " Individual targets can opt-out of the output prefix by setting:\n" 627 output_prefix = "lib"
633 " output_prefix_override = true\n" 628
634 " (see \"gn help output_prefix_override\").\n" 629 precompiled_header_type [string]
635 "\n" 630 Valid for: "cc", "cxx", "objc", "objcxx"
636 " This is typically used to prepend \"lib\" to libraries on\n" 631
637 " Posix systems:\n" 632 Type of precompiled headers. If undefined or the empty string,
638 " output_prefix = \"lib\"\n" 633 precompiled headers will not be used for this tool. Otherwise use "gcc"
639 "\n" 634 or "msvc".
640 " precompiled_header_type [string]\n" 635
641 " Valid for: \"cc\", \"cxx\", \"objc\", \"objcxx\"\n" 636 For precompiled headers to be used for a given target, the target (or a
642 "\n" 637 config applied to it) must also specify a "precompiled_header" and, for
643 " Type of precompiled headers. If undefined or the empty string,\n" 638 "msvc"-style headers, a "precompiled_source" value. If the type is
644 " precompiled headers will not be used for this tool. Otherwise\n" 639 "gcc", then both "precompiled_header" and "precompiled_source" must
645 " use \"gcc\" or \"msvc\".\n" 640 resolve to the same file, despite the different formats required for
646 "\n" 641 each."
647 " For precompiled headers to be used for a given target, the\n" 642
648 " target (or a config applied to it) must also specify a\n" 643 See "gn help precompiled_header" for more.
649 " \"precompiled_header\" and, for \"msvc\"-style headers, a\n" 644
650 " \"precompiled_source\" value. If the type is \"gcc\", then both\n" 645 restat [boolean]
651 " \"precompiled_header\" and \"precompiled_source\" must resolve\n" 646 Valid for: all tools (optional, defaults to false)
652 " to the same file, despite the different formats required for each." 647
653 "\n" 648 Requests that Ninja check the file timestamp after this tool has run to
654 " See \"gn help precompiled_header\" for more.\n" 649 determine if anything changed. Set this if your tool has the ability to
655 "\n" 650 skip writing output if the output file has not changed.
656 " restat [boolean]\n" 651
657 " Valid for: all tools (optional, defaults to false)\n" 652 Normally, Ninja will assume that when a tool runs the output be new and
658 "\n" 653 downstream dependents must be rebuild. When this is set to trye, Ninja
659 " Requests that Ninja check the file timestamp after this tool has\n" 654 can skip rebuilding downstream dependents for input changes that don't
660 " run to determine if anything changed. Set this if your tool has\n" 655 actually affect the output.
661 " the ability to skip writing output if the output file has not\n" 656
662 " changed.\n" 657 Example:
663 "\n" 658 restat = true
664 " Normally, Ninja will assume that when a tool runs the output\n" 659
665 " be new and downstream dependents must be rebuild. When this is\n" 660 rspfile [string with substitutions]
666 " set to trye, Ninja can skip rebuilding downstream dependents for\n" 661 Valid for: all tools (optional)
667 " input changes that don't actually affect the output.\n" 662
668 "\n" 663 Name of the response file. If empty, no response file will be
669 " Example:\n" 664 used. See "rspfile_content".
670 " restat = true\n" 665
671 "\n" 666 rspfile_content [string with substitutions]
672 " rspfile [string with substitutions]\n" 667 Valid for: all tools (required when "rspfile" is specified)
673 " Valid for: all tools (optional)\n" 668
674 "\n" 669 The contents to be written to the response file. This may include all
675 " Name of the response file. If empty, no response file will be\n" 670 or part of the command to send to the tool which allows you to get
676 " used. See \"rspfile_content\".\n" 671 around OS command-line length limits.
677 "\n" 672
678 " rspfile_content [string with substitutions]\n" 673 This example adds the inputs and libraries to a response file, but
679 " Valid for: all tools (required when \"rspfile\" is specified)\n" 674 passes the linker flags directly on the command line:
680 "\n" 675 tool("link") {
681 " The contents to be written to the response file. This may\n" 676 command = "link -o {{output}} {{ldflags}} @{{output}}.rsp"
682 " include all or part of the command to send to the tool which\n" 677 rspfile = "{{output}}.rsp"
683 " allows you to get around OS command-line length limits.\n" 678 rspfile_content = "{{inputs}} {{solibs}} {{libs}}"
684 "\n" 679 }
685 " This example adds the inputs and libraries to a response file,\n" 680
686 " but passes the linker flags directly on the command line:\n" 681 runtime_outputs [string list with substitutions]
687 " tool(\"link\") {\n" 682 Valid for: linker tools
688 " command = \"link -o {{output}} {{ldflags}} @{{output}}.rsp\"\n" 683
689 " rspfile = \"{{output}}.rsp\"\n" 684 If specified, this list is the subset of the outputs that should be
690 " rspfile_content = \"{{inputs}} {{solibs}} {{libs}}\"\n" 685 added to runtime deps (see "gn help runtime_deps"). By default (if
691 " }\n" 686 runtime_outputs is empty or unspecified), it will be the link_output.
692 "\n" 687
693 " runtime_outputs [string list with substitutions]\n" 688 Expansions for tool variables
694 " Valid for: linker tools\n" 689
695 "\n" 690 All paths are relative to the root build directory, which is the current
696 " If specified, this list is the subset of the outputs that should\n" 691 directory for running all tools. These expansions are available to all tools:
697 " be added to runtime deps (see \"gn help runtime_deps\"). By\n" 692
698 " default (if runtime_outputs is empty or unspecified), it will be\n" 693 {{label}}
699 " the link_output.\n" 694 The label of the current target. This is typically used in the
700 "\n" 695 "description" field for link tools. The toolchain will be omitted from
701 "Expansions for tool variables\n" 696 the label for targets in the default toolchain, and will be included
702 "\n" 697 for targets in other toolchains.
703 " All paths are relative to the root build directory, which is the\n" 698
704 " current directory for running all tools. These expansions are\n" 699 {{label_name}}
705 " available to all tools:\n" 700 The short name of the label of the target. This is the part after the
706 "\n" 701 colon. For "//foo/bar:baz" this will be "baz". Unlike
707 " {{label}}\n" 702 {{target_output_name}}, this is not affected by the "output_prefix" in
708 " The label of the current target. This is typically used in the\n" 703 the tool or the "output_name" set on the target.
709 " \"description\" field for link tools. The toolchain will be\n" 704
710 " omitted from the label for targets in the default toolchain, and\n" 705 {{output}}
711 " will be included for targets in other toolchains.\n" 706 The relative path and name of the output(s) of the current build step.
712 "\n" 707 If there is more than one output, this will expand to a list of all of
713 " {{label_name}}\n" 708 them. Example: "out/base/my_file.o"
714 " The short name of the label of the target. This is the part\n" 709
715 " after the colon. For \"//foo/bar:baz\" this will be \"baz\".\n" 710 {{target_gen_dir}}
716 " Unlike {{target_output_name}}, this is not affected by the\n" 711 {{target_out_dir}}
717 " \"output_prefix\" in the tool or the \"output_name\" set\n" 712 The directory of the generated file and output directories,
718 " on the target.\n" 713 respectively, for the current target. There is no trailing slash. See
719 "\n" 714 also {{output_dir}} for linker tools. Example: "out/base/test"
720 " {{output}}\n" 715
721 " The relative path and name of the output(s) of the current\n" 716 {{target_output_name}}
722 " build step. If there is more than one output, this will expand\n" 717 The short name of the current target with no path information, or the
723 " to a list of all of them.\n" 718 value of the "output_name" variable if one is specified in the target.
724 " Example: \"out/base/my_file.o\"\n" 719 This will include the "output_prefix" if any. See also {{label_name}}.
725 "\n" 720
726 " {{target_gen_dir}}\n" 721 Example: "libfoo" for the target named "foo" and an output prefix for
727 " {{target_out_dir}}\n" 722 the linker tool of "lib".
728 " The directory of the generated file and output directories,\n" 723
729 " respectively, for the current target. There is no trailing\n" 724 )" // String break to prevent overflowing the 16K max VC string length.
scottmg 2016/11/08 01:01:46 lolz
730 " slash. See also {{output_dir}} for linker tools.\n" 725 R"( Compiler tools have the notion of a single input and a single output, along
731 " Example: \"out/base/test\"\n" 726 with a set of compiler-specific flags. The following expansions are
732 "\n" 727 available:
733 " {{target_output_name}}\n" 728
734 " The short name of the current target with no path information,\n" 729 {{asmflags}}
735 " or the value of the \"output_name\" variable if one is specified\n" 730 {{cflags}}
736 " in the target. This will include the \"output_prefix\" if any.\n" 731 {{cflags_c}}
737 " See also {{label_name}}.\n" 732 {{cflags_cc}}
738 " Example: \"libfoo\" for the target named \"foo\" and an\n" 733 {{cflags_objc}}
739 " output prefix for the linker tool of \"lib\".\n" 734 {{cflags_objcc}}
740 "\n" 735 {{defines}}
741 " Compiler tools have the notion of a single input and a single output,\n" 736 {{include_dirs}}
742 " along with a set of compiler-specific flags. The following expansions\n" 737 Strings correspond that to the processed flags/defines/include
743 " are available:\n" 738 directories specified for the target.
744 "\n" 739 Example: "--enable-foo --enable-bar"
745 " {{asmflags}}\n" 740
746 " {{cflags}}\n" 741 Defines will be prefixed by "-D" and include directories will be
747 " {{cflags_c}}\n" 742 prefixed by "-I" (these work with Posix tools as well as Microsoft
748 " {{cflags_cc}}\n" 743 ones).
749 " {{cflags_objc}}\n" 744
750 " {{cflags_objcc}}\n" 745 {{source}}
751 " {{defines}}\n" 746 The relative path and name of the current input file.
752 " {{include_dirs}}\n" 747 Example: "../../base/my_file.cc"
753 " Strings correspond that to the processed flags/defines/include\n" 748
754 " directories specified for the target.\n" 749 {{source_file_part}}
755 " Example: \"--enable-foo --enable-bar\"\n" 750 The file part of the source including the extension (with no directory
756 "\n" 751 information).
757 " Defines will be prefixed by \"-D\" and include directories will\n" 752 Example: "foo.cc"
758 " be prefixed by \"-I\" (these work with Posix tools as well as\n" 753
759 " Microsoft ones).\n" 754 {{source_name_part}}
760 "\n" 755 The filename part of the source file with no directory or extension.
761 " {{source}}\n" 756 Example: "foo"
762 " The relative path and name of the current input file.\n" 757
763 " Example: \"../../base/my_file.cc\"\n" 758 {{source_gen_dir}}
764 "\n" 759 {{source_out_dir}}
765 " {{source_file_part}}\n" 760 The directory in the generated file and output directories,
766 " The file part of the source including the extension (with no\n" 761 respectively, for the current input file. If the source file is in the
767 " directory information).\n" 762 same directory as the target is declared in, they will will be the same
768 " Example: \"foo.cc\"\n" 763 as the "target" versions above. Example: "gen/base/test"
769 "\n" 764
770 " {{source_name_part}}\n" 765 Linker tools have multiple inputs and (potentially) multiple outputs The
771 " The filename part of the source file with no directory or\n" 766 static library tool ("alink") is not considered a linker tool. The following
772 " extension.\n" 767 expansions are available:
773 " Example: \"foo\"\n" 768
774 "\n" 769 {{inputs}}
775 " {{source_gen_dir}}\n" 770 {{inputs_newline}}
776 " {{source_out_dir}}\n" 771 Expands to the inputs to the link step. This will be a list of object
777 " The directory in the generated file and output directories,\n" 772 files and static libraries.
778 " respectively, for the current input file. If the source file\n" 773 Example: "obj/foo.o obj/bar.o obj/somelibrary.a"
779 " is in the same directory as the target is declared in, they will\n" 774
780 " will be the same as the \"target\" versions above.\n" 775 The "_newline" version will separate the input files with newlines
781 " Example: \"gen/base/test\"\n" 776 instead of spaces. This is useful in response files: some linkers can
782 "\n" 777 take a "-filelist" flag which expects newline separated files, and some
783 " Linker tools have multiple inputs and (potentially) multiple outputs\n" 778 Microsoft tools have a fixed-sized buffer for parsing each line of a
784 " The static library tool (\"alink\") is not considered a linker tool.\n" 779 response file.
785 " The following expansions are available:\n" 780
786 "\n" 781 {{ldflags}}
787 " {{inputs}}\n" 782 Expands to the processed set of ldflags and library search paths
788 " {{inputs_newline}}\n" 783 specified for the target.
789 " Expands to the inputs to the link step. This will be a list of\n" 784 Example: "-m64 -fPIC -pthread -L/usr/local/mylib"
790 " object files and static libraries.\n" 785
791 " Example: \"obj/foo.o obj/bar.o obj/somelibrary.a\"\n" 786 {{libs}}
792 "\n" 787 Expands to the list of system libraries to link to. Each will be
793 " The \"_newline\" version will separate the input files with\n" 788 prefixed by the "lib_prefix".
794 " newlines instead of spaces. This is useful in response files:\n" 789
795 " some linkers can take a \"-filelist\" flag which expects newline\n" 790 As a special case to support Mac, libraries with names ending in
796 " separated files, and some Microsoft tools have a fixed-sized\n" 791 ".framework" will be added to the {{libs}} with "-framework" preceeding
797 " buffer for parsing each line of a response file.\n" 792 it, and the lib prefix will be ignored.
798 "\n" 793
799 " {{ldflags}}\n" 794 Example: "-lfoo -lbar"
800 " Expands to the processed set of ldflags and library search paths\n" 795
801 " specified for the target.\n" 796 {{output_dir}}
802 " Example: \"-m64 -fPIC -pthread -L/usr/local/mylib\"\n" 797 The value of the "output_dir" variable in the target, or the the value
803 "\n" 798 of the "default_output_dir" value in the tool if the target does not
804 " {{libs}}\n" 799 override the output directory. This will be relative to the
805 " Expands to the list of system libraries to link to. Each will\n" 800 root_build_dir and will not end in a slash. Will be "." for output to
806 " be prefixed by the \"lib_prefix\".\n" 801 the root_build_dir.
807 "\n" 802
808 " As a special case to support Mac, libraries with names ending in\n" 803 This is subtly different than {{target_out_dir}} which is defined by GN
809 " \".framework\" will be added to the {{libs}} with \"-framework\"\n" 804 based on the target's path and not overridable. {{output_dir}} is for
810 " preceeding it, and the lib prefix will be ignored.\n" 805 the final output, {{target_out_dir}} is generally for object files and
811 "\n" 806 other outputs.
812 " Example: \"-lfoo -lbar\"\n" 807
813 "\n" 808 Usually {{output_dir}} would be defined in terms of either
814 " {{output_dir}}\n" 809 {{target_out_dir}} or {{root_out_dir}}
815 " The value of the \"output_dir\" variable in the target, or the\n" 810
816 " the value of the \"default_output_dir\" value in the tool if the\n" 811 {{output_extension}}
817 " target does not override the output directory. This will be\n" 812 The value of the "output_extension" variable in the target, or the
818 " relative to the root_build_dir and will not end in a slash.\n" 813 value of the "default_output_extension" value in the tool if the target
819 " Will be \".\" for output to the root_build_dir.\n" 814 does not specify an output extension.
820 "\n" 815 Example: ".so"
821 " This is subtly different than {{target_out_dir}} which is\n" 816
822 " defined by GN based on the target's path and not overridable.\n" 817 {{solibs}}
823 " {{output_dir}} is for the final output, {{target_out_dir}} is\n" 818 Extra libraries from shared library dependencide not specified in the
824 " generally for object files and other outputs.\n" 819 {{inputs}}. This is the list of link_output files from shared libraries
825 "\n" 820 (if the solink tool specifies a "link_output" variable separate from
826 " Usually {{output_dir}} would be defined in terms of either\n" 821 the "depend_output").
827 " {{target_out_dir}} or {{root_out_dir}}\n" 822
828 "\n" 823 These should generally be treated the same as libs by your tool.
829 " {{output_extension}}\n" 824
830 " The value of the \"output_extension\" variable in the target,\n" 825 Example: "libfoo.so libbar.so"
831 " or the value of the \"default_output_extension\" value in the\n" 826
832 " tool if the target does not specify an output extension.\n" 827 )" // String break to prevent overflowing the 16K max VC string length.
833 " Example: \".so\"\n" 828 R"( The static library ("alink") tool allows {{arflags}} plus the common tool
834 "\n" 829 substitutions.
835 " {{solibs}}\n" 830
836 " Extra libraries from shared library dependencide not specified\n" 831 The copy tool allows the common compiler/linker substitutions, plus
837 " in the {{inputs}}. This is the list of link_output files from\n" 832 {{source}} which is the source of the copy. The stamp tool allows only the
838 " shared libraries (if the solink tool specifies a \"link_output\"\n" 833 common tool substitutions.
839 " variable separate from the \"depend_output\").\n" 834
840 "\n" 835 The copy_bundle_data and compile_xcassets tools only allows the common tool
841 " These should generally be treated the same as libs by your tool.\n" 836 substitutions. Both tools are required to create iOS/OS X bundles and need
842 " Example: \"libfoo.so libbar.so\"\n" 837 only be defined on those platforms.
843 "\n" 838
844 " The static library (\"alink\") tool allows {{arflags}} plus the common\n" 839 The copy_bundle_data tool will be called with one source and needs to copy
845 " tool substitutions.\n" 840 (optionally optimizing the data representation) to its output. It may be
846 "\n" 841 called with a directory as input and it needs to be recursively copied.
847 " The copy tool allows the common compiler/linker substitutions, plus\n" 842
848 " {{source}} which is the source of the copy. The stamp tool allows\n" 843 The compile_xcassets tool will be called with one or more source (each an
849 " only the common tool substitutions.\n" 844 asset catalog) that needs to be compiled to a single output. The following
850 "\n" 845 substitutions are avaiable:
851 " The copy_bundle_data and compile_xcassets tools only allows the common\n" 846
852 " tool substitutions. Both tools are required to create iOS/OS X bundles\n" 847 {{inputs}}
853 " and need only be defined on those platforms.\n" 848 Expands to the list of .xcassets to use as input to compile the asset
854 "\n" 849 catalog.
855 " The copy_bundle_data tool will be called with one source and needs to\n" 850
856 " copy (optionally optimizing the data representation) to its output. It\n" 851 {{bundle_product_type}}
857 " may be called with a directory as input and it needs to be recursively\n" 852 Expands to the product_type of the bundle that will contain the
858 " copied.\n" 853 compiled asset catalog. Usually corresponds to the product_type
859 "\n" 854 property of the corresponding create_bundle target.
860 " The compile_xcassets tool will be called with one or more source (each\n" 855
861 " an asset catalog) that needs to be compiled to a single output. The\n" 856 Separate linking and dependencies for shared libraries
862 " following substitutions are avaiable:\n" 857
863 "\n" 858 Shared libraries are special in that not all changes to them require that
864 " {{inputs}}\n" 859 dependent targets be re-linked. If the shared library is changed but no
865 " Expands to the list of .xcassets to use as input to compile the\n" 860 imports or exports are different, dependent code needn't be relinked, which
866 " asset catalog.\n" 861 can speed up the build.
867 "\n" 862
868 " {{bundle_product_type}}\n" 863 If your link step can output a list of exports from a shared library and
869 " Expands to the product_type of the bundle that will contain the\n" 864 writes the file only if the new one is different, the timestamp of this file
870 " compiled asset catalog. Usually corresponds to the product_type\n" 865 can be used for triggering re-links, while the actual shared library would be
871 " property of the corresponding create_bundle target.\n" 866 used for linking.
872 "\n" 867
873 "Separate linking and dependencies for shared libraries\n" 868 You will need to specify
874 "\n" 869 restat = true
875 " Shared libraries are special in that not all changes to them require\n" 870 in the linker tool to make this work, so Ninja will detect if the timestamp
876 " that dependent targets be re-linked. If the shared library is changed\n" 871 of the dependency file has changed after linking (otherwise it will always
877 " but no imports or exports are different, dependent code needn't be\n" 872 assume that running a command updates the output):
878 " relinked, which can speed up the build.\n" 873
879 "\n" 874 tool("solink") {
880 " If your link step can output a list of exports from a shared library\n" 875 command = "..."
881 " and writes the file only if the new one is different, the timestamp of\n" 876 outputs = [
882 " this file can be used for triggering re-links, while the actual shared\n" 877 "{{output_dir}}/{{target_output_name}}{{output_extension}}",
883 " library would be used for linking.\n" 878 "{{output_dir}}/{{target_output_name}}"
884 "\n" 879 "{{output_extension}}.TOC",
885 " You will need to specify\n" 880 ]
886 " restat = true\n" 881 link_output =
887 " in the linker tool to make this work, so Ninja will detect if the\n" 882 "{{output_dir}}/{{target_output_name}}{{output_extension}}"
888 " timestamp of the dependency file has changed after linking (otherwise\n" 883 depend_output =
889 " it will always assume that running a command updates the output):\n" 884 "{{output_dir}}/{{target_output_name}}"
890 "\n" 885 "{{output_extension}}.TOC"
891 " tool(\"solink\") {\n" 886 restat = true
892 " command = \"...\"\n" 887 }
893 " outputs = [\n" 888
894 " \"{{output_dir}}/{{target_output_name}}{{output_extension}}\",\n" 889 Example
895 " \"{{output_dir}}/{{target_output_name}}" 890
896 "{{output_extension}}.TOC\",\n" 891 toolchain("my_toolchain") {
897 " ]\n" 892 # Put these at the top to apply to all tools below.
898 " link_output =\n" 893 lib_prefix = "-l"
899 " \"{{output_dir}}/{{target_output_name}}{{output_extension}}\"\n" 894 lib_dir_prefix = "-L"
900 " depend_output =\n" 895
901 " \"{{output_dir}}/{{target_output_name}}" 896 tool("cc") {
902 "{{output_extension}}.TOC\"\n" 897 command = "gcc {{source}} -o {{output}}"
903 " restat = true\n" 898 outputs = [ "{{source_out_dir}}/{{source_name_part}}.o" ]
904 " }\n" 899 description = "GCC {{source}}"
905 "\n" 900 }
906 "Example\n" 901 tool("cxx") {
907 "\n" 902 command = "g++ {{source}} -o {{output}}"
908 " toolchain(\"my_toolchain\") {\n" 903 outputs = [ "{{source_out_dir}}/{{source_name_part}}.o" ]
909 " # Put these at the top to apply to all tools below.\n" 904 description = "G++ {{source}}"
910 " lib_prefix = \"-l\"\n" 905 }
911 " lib_dir_prefix = \"-L\"\n" 906 };)";
scottmg 2016/11/08 01:01:46 \n
912 "\n"
913 " tool(\"cc\") {\n"
914 " command = \"gcc {{source}} -o {{output}}\"\n"
915 " outputs = [ \"{{source_out_dir}}/{{source_name_part}}.o\" ]\n"
916 " description = \"GCC {{source}}\"\n"
917 " }\n"
918 " tool(\"cxx\") {\n"
919 " command = \"g++ {{source}} -o {{output}}\"\n"
920 " outputs = [ \"{{source_out_dir}}/{{source_name_part}}.o\" ]\n"
921 " description = \"G++ {{source}}\"\n"
922 " }\n"
923 " }\n";
924 907
925 Value RunTool(Scope* scope, 908 Value RunTool(Scope* scope,
926 const FunctionCallNode* function, 909 const FunctionCallNode* function,
927 const std::vector<Value>& args, 910 const std::vector<Value>& args,
928 BlockNode* block, 911 BlockNode* block,
929 Err* err) { 912 Err* err) {
930 // Find the toolchain definition we're executing inside of. The toolchain 913 // Find the toolchain definition we're executing inside of. The toolchain
931 // function will set a property pointing to it that we'll pick up. 914 // function will set a property pointing to it that we'll pick up.
932 Toolchain* toolchain = reinterpret_cast<Toolchain*>( 915 Toolchain* toolchain = reinterpret_cast<Toolchain*>(
933 scope->GetProperty(&kToolchainPropertyKey, nullptr)); 916 scope->GetProperty(&kToolchainPropertyKey, nullptr));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 1029
1047 // Make sure there weren't any vars set in this tool that were unused. 1030 // Make sure there weren't any vars set in this tool that were unused.
1048 if (!block_scope.CheckForUnusedVars(err)) 1031 if (!block_scope.CheckForUnusedVars(err))
1049 return Value(); 1032 return Value();
1050 1033
1051 toolchain->SetTool(tool_type, std::move(tool)); 1034 toolchain->SetTool(tool_type, std::move(tool));
1052 return Value(); 1035 return Value();
1053 } 1036 }
1054 1037
1055 } // namespace functions 1038 } // namespace functions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698