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

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

Issue 1887533003: Add an output_dir override to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const Created 4 years, 8 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/example/build/toolchain/BUILD.gn ('k') | tools/gn/ninja_binary_target_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 <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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 " \"copy_bundle_data\": [iOS, OS X] Tool to copy files in a bundle.\n" 411 " \"copy_bundle_data\": [iOS, OS X] Tool to copy files in a bundle.\n"
412 " \"compile_xcassets\": [iOS, OS X] Tool to compile asset catalogs.\n" 412 " \"compile_xcassets\": [iOS, OS X] Tool to compile asset catalogs.\n"
413 "\n" 413 "\n"
414 "Tool variables\n" 414 "Tool variables\n"
415 "\n" 415 "\n"
416 " command [string with substitutions]\n" 416 " command [string with substitutions]\n"
417 " Valid for: all tools (required)\n" 417 " Valid for: all tools (required)\n"
418 "\n" 418 "\n"
419 " The command to run.\n" 419 " The command to run.\n"
420 "\n" 420 "\n"
421 " default_output_dir [string with substitutions]\n"
422 " Valid for: linker tools\n"
423 "\n"
424 " Default directory name for the output file relative to the\n"
425 " root_build_dir. It can contain other substitution patterns.\n"
426 " This will be the default value for the {{output_dir}} expansion\n"
427 " (discussed below) but will be overridden by the \"output_dir\"\n"
428 " variable in a target, if one is specified.\n"
429 "\n"
430 " GN doesn't do anything with this string other than pass it\n"
431 " along, potentially with target-specific overrides. It is the\n"
432 " tool's job to use the expansion so that the files will be in\n"
433 " the right place.\n"
434 "\n"
421 " default_output_extension [string]\n" 435 " default_output_extension [string]\n"
422 " Valid for: linker tools\n" 436 " Valid for: linker tools\n"
423 "\n" 437 "\n"
424 " Extension for the main output of a linkable tool. It includes\n" 438 " Extension for the main output of a linkable tool. It includes\n"
425 " the leading dot. This will be the default value for the\n" 439 " the leading dot. This will be the default value for the\n"
426 " {{output_extension}} expansion (discussed below) but will be\n" 440 " {{output_extension}} expansion (discussed below) but will be\n"
427 " overridden by by the \"output extension\" variable in a target,\n" 441 " overridden by by the \"output extension\" variable in a target,\n"
428 " if one is specified. Empty string means no extension.\n" 442 " if one is specified. Empty string means no extension.\n"
429 "\n" 443 "\n"
430 " GN doesn't actually do anything with this extension other than\n" 444 " GN doesn't actually do anything with this extension other than\n"
431 " pass it along, potentially with target-specific overrides. One\n" 445 " pass it along, potentially with target-specific overrides. One\n"
432 " would typically use the {{output_extension}} value in the\n" 446 " would typically use the {{output_extension}} value in the\n"
433 " \"outputs\" to read this value.\n" 447 " \"outputs\" to read this value.\n"
434 "\n" 448 "\n"
435 " Example: default_output_extension = \".exe\"\n" 449 " Example: default_output_extension = \".exe\"\n"
436 "\n" 450 "\n"
437 " depfile [string]\n" 451 " depfile [string with substitutions]\n"
438 " Valid for: compiler tools (optional)\n" 452 " Valid for: compiler tools (optional)\n"
439 "\n" 453 "\n"
440 " If the tool can write \".d\" files, this specifies the name of\n" 454 " If the tool can write \".d\" files, this specifies the name of\n"
441 " the resulting file. These files are used to list header file\n" 455 " the resulting file. These files are used to list header file\n"
442 " dependencies (or other implicit input dependencies) that are\n" 456 " dependencies (or other implicit input dependencies) that are\n"
443 " discovered at build time. See also \"depsformat\".\n" 457 " discovered at build time. See also \"depsformat\".\n"
444 "\n" 458 "\n"
445 " Example: depfile = \"{{output}}.d\"\n" 459 " Example: depfile = \"{{output}}.d\"\n"
446 "\n" 460 "\n"
447 " depsformat [string]\n" 461 " depsformat [string]\n"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 " runtime_link_output. Otherwise, the first entry in the\n" 503 " runtime_link_output. Otherwise, the first entry in the\n"
490 " outputs list should always be the main output which will be\n" 504 " outputs list should always be the main output which will be\n"
491 " linked to.\n" 505 " linked to.\n"
492 "\n" 506 "\n"
493 " Example for a compiler tool that produces .obj files:\n" 507 " Example for a compiler tool that produces .obj files:\n"
494 " outputs = [\n" 508 " outputs = [\n"
495 " \"{{source_out_dir}}/{{source_name_part}}.obj\"\n" 509 " \"{{source_out_dir}}/{{source_name_part}}.obj\"\n"
496 " ]\n" 510 " ]\n"
497 "\n" 511 "\n"
498 " Example for a linker tool that produces a .dll and a .lib. The\n" 512 " Example for a linker tool that produces a .dll and a .lib. The\n"
499 " use of {{output_extension}} rather than hardcoding \".dll\"\n" 513 " use of {{target_output_name}}, {{output_extension}} and\n"
500 " allows the extension of the library to be overridden on a\n" 514 " {{output_dir}} allows the target to override these values.\n"
501 " target-by-target basis, but in this example, it always\n"
502 " produces a \".lib\" import library:\n"
503 " outputs = [\n" 515 " outputs = [\n"
504 " \"{{root_out_dir}}/{{target_output_name}}" 516 " \"{{output_dir}}/{{target_output_name}}"
505 "{{output_extension}}\",\n" 517 "{{output_extension}}\",\n"
506 " \"{{root_out_dir}}/{{target_output_name}}.lib\",\n" 518 " \"{{output_dir}}/{{target_output_name}}.lib\",\n"
507 " ]\n" 519 " ]\n"
508 "\n" 520 "\n"
509 " link_output [string with substitutions]\n" 521 " link_output [string with substitutions]\n"
510 " depend_output [string with substitutions]\n" 522 " depend_output [string with substitutions]\n"
511 " runtime_link_output [string with substitutions]\n" 523 " runtime_link_output [string with substitutions]\n"
512 " Valid for: \"solink\" only (optional)\n" 524 " Valid for: \"solink\" only (optional)\n"
513 "\n" 525 "\n"
514 " These three files specify which of the outputs from the solink\n" 526 " These three files specify which of the outputs from the solink\n"
515 " tool should be used for linking and dependency tracking. These\n" 527 " tool should be used for linking and dependency tracking. These\n"
516 " should match entries in the \"outputs\". If unspecified, the\n" 528 " should match entries in the \"outputs\". If unspecified, the\n"
517 " first item in the \"outputs\" array will be used for all. See\n" 529 " first item in the \"outputs\" array will be used for all. See\n"
518 " \"Separate linking and dependencies for shared libraries\"\n" 530 " \"Separate linking and dependencies for shared libraries\"\n"
519 " below for more. If link_output is set but runtime_link_output\n" 531 " below for more. If link_output is set but runtime_link_output\n"
520 " is not set, runtime_link_output defaults to link_output.\n" 532 " is not set, runtime_link_output defaults to link_output.\n"
521 "\n" 533 "\n"
522 " On Windows, where the tools produce a .dll shared library and\n" 534 " On Windows, where the tools produce a .dll shared library and\n"
523 " a .lib import library, you will want the first two to be the\n" 535 " a .lib import library, you will want the first two to be the\n"
524 " import library and the third one to be the .dll file.\n" 536 " import library and the third one to be the .dll file.\n"
525 " On Linux, if you're not doing the separate linking/dependency\n" 537 " On Linux, if you're not doing the separate linking/dependency\n"
526 " optimization, all of these should be the .so output.\n" 538 " optimization, all of these should be the .so output.\n"
527 "\n" 539 "\n"
528 " output_prefix [string]\n" 540 " output_prefix [string]\n"
529 " Valid for: Linker tools (optional)\n" 541 " Valid for: Linker tools (optional)\n"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 " {{output}}\n" 629 " {{output}}\n"
618 " The relative path and name of the output(s) of the current\n" 630 " The relative path and name of the output(s) of the current\n"
619 " build step. If there is more than one output, this will expand\n" 631 " build step. If there is more than one output, this will expand\n"
620 " to a list of all of them.\n" 632 " to a list of all of them.\n"
621 " Example: \"out/base/my_file.o\"\n" 633 " Example: \"out/base/my_file.o\"\n"
622 "\n" 634 "\n"
623 " {{target_gen_dir}}\n" 635 " {{target_gen_dir}}\n"
624 " {{target_out_dir}}\n" 636 " {{target_out_dir}}\n"
625 " The directory of the generated file and output directories,\n" 637 " The directory of the generated file and output directories,\n"
626 " respectively, for the current target. There is no trailing\n" 638 " respectively, for the current target. There is no trailing\n"
627 " slash.\n" 639 " slash. See also {{output_dir}} for linker tools.\n"
628 " Example: \"out/base/test\"\n" 640 " Example: \"out/base/test\"\n"
629 "\n" 641 "\n"
630 " {{target_output_name}}\n" 642 " {{target_output_name}}\n"
631 " The short name of the current target with no path information,\n" 643 " The short name of the current target with no path information,\n"
632 " or the value of the \"output_name\" variable if one is specified\n" 644 " or the value of the \"output_name\" variable if one is specified\n"
633 " in the target. This will include the \"output_prefix\" if any.\n" 645 " in the target. This will include the \"output_prefix\" if any.\n"
634 " See also {{label_name}}.\n" 646 " See also {{label_name}}.\n"
635 " Example: \"libfoo\" for the target named \"foo\" and an\n" 647 " Example: \"libfoo\" for the target named \"foo\" and an\n"
636 " output prefix for the linker tool of \"lib\".\n" 648 " output prefix for the linker tool of \"lib\".\n"
637 "\n" 649 "\n"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 " {{libs}}\n" 712 " {{libs}}\n"
701 " Expands to the list of system libraries to link to. Each will\n" 713 " Expands to the list of system libraries to link to. Each will\n"
702 " be prefixed by the \"lib_prefix\".\n" 714 " be prefixed by the \"lib_prefix\".\n"
703 "\n" 715 "\n"
704 " As a special case to support Mac, libraries with names ending in\n" 716 " As a special case to support Mac, libraries with names ending in\n"
705 " \".framework\" will be added to the {{libs}} with \"-framework\"\n" 717 " \".framework\" will be added to the {{libs}} with \"-framework\"\n"
706 " preceeding it, and the lib prefix will be ignored.\n" 718 " preceeding it, and the lib prefix will be ignored.\n"
707 "\n" 719 "\n"
708 " Example: \"-lfoo -lbar\"\n" 720 " Example: \"-lfoo -lbar\"\n"
709 "\n" 721 "\n"
722 " {{output_dir}}\n"
723 " The value of the \"output_dir\" variable in the target, or the\n"
724 " the value of the \"default_output_dir\" value in the tool if the\n"
725 " target does not override the output directory. This will be\n"
726 " relative to the root_build_dir and will not end in a slash.\n"
727 " Will be \".\" for output to the root_build_dir.\n"
728 "\n"
729 " This is subtly different than {{target_out_dir}} which is\n"
730 " defined by GN based on the target's path and not overridable.\n"
731 " {{output_dir}} is for the final output, {{target_out_dir}} is\n"
732 " generally for object files and other outputs.\n"
733 "\n"
734 " Usually {{output_dir}} would be defined in terms of either\n"
735 " {{target_out_dir}} or {{root_out_dir}}\n"
736 "\n"
710 " {{output_extension}}\n" 737 " {{output_extension}}\n"
711 " The value of the \"output_extension\" variable in the target,\n" 738 " The value of the \"output_extension\" variable in the target,\n"
712 " or the value of the \"default_output_extension\" value in the\n" 739 " or the value of the \"default_output_extension\" value in the\n"
713 " tool if the target does not specify an output extension.\n" 740 " tool if the target does not specify an output extension.\n"
714 " Example: \".so\"\n" 741 " Example: \".so\"\n"
715 "\n" 742 "\n"
716 " {{solibs}}\n" 743 " {{solibs}}\n"
717 " Extra libraries from shared library dependencide not specified\n" 744 " Extra libraries from shared library dependencide not specified\n"
718 " in the {{inputs}}. This is the list of link_output files from\n" 745 " in the {{inputs}}. This is the list of link_output files from\n"
719 " shared libraries (if the solink tool specifies a \"link_output\"\n" 746 " shared libraries (if the solink tool specifies a \"link_output\"\n"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 "\n" 779 "\n"
753 " You will need to specify\n" 780 " You will need to specify\n"
754 " restat = true\n" 781 " restat = true\n"
755 " in the linker tool to make this work, so Ninja will detect if the\n" 782 " in the linker tool to make this work, so Ninja will detect if the\n"
756 " timestamp of the dependency file has changed after linking (otherwise\n" 783 " timestamp of the dependency file has changed after linking (otherwise\n"
757 " it will always assume that running a command updates the output):\n" 784 " it will always assume that running a command updates the output):\n"
758 "\n" 785 "\n"
759 " tool(\"solink\") {\n" 786 " tool(\"solink\") {\n"
760 " command = \"...\"\n" 787 " command = \"...\"\n"
761 " outputs = [\n" 788 " outputs = [\n"
762 " \"{{root_out_dir}}/{{target_output_name}}{{output_extension}}\",\n" 789 " \"{{output_dir}}/{{target_output_name}}{{output_extension}}\",\n"
763 " \"{{root_out_dir}}/{{target_output_name}}" 790 " \"{{output_dir}}/{{target_output_name}}"
764 "{{output_extension}}.TOC\",\n" 791 "{{output_extension}}.TOC\",\n"
765 " ]\n" 792 " ]\n"
766 " link_output =\n" 793 " link_output =\n"
767 " \"{{root_out_dir}}/{{target_output_name}}{{output_extension}}\"\n" 794 " \"{{output_dir}}/{{target_output_name}}{{output_extension}}\"\n"
768 " depend_output =\n" 795 " depend_output =\n"
769 " \"{{root_out_dir}}/{{target_output_name}}" 796 " \"{{output_dir}}/{{target_output_name}}"
770 "{{output_extension}}.TOC\"\n" 797 "{{output_extension}}.TOC\"\n"
771 " restat = true\n" 798 " restat = true\n"
772 " }\n" 799 " }\n"
773 "\n" 800 "\n"
774 "Example\n" 801 "Example\n"
775 "\n" 802 "\n"
776 " toolchain(\"my_toolchain\") {\n" 803 " toolchain(\"my_toolchain\") {\n"
777 " # Put these at the top to apply to all tools below.\n" 804 " # Put these at the top to apply to all tools below.\n"
778 " lib_prefix = \"-l\"\n" 805 " lib_prefix = \"-l\"\n"
779 " lib_dir_prefix = \"-L\"\n" 806 " lib_dir_prefix = \"-L\"\n"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 !ReadString(&block_scope, "lib_dir_switch", tool.get(), 886 !ReadString(&block_scope, "lib_dir_switch", tool.get(),
860 &Tool::set_lib_dir_switch, err) || 887 &Tool::set_lib_dir_switch, err) ||
861 !ReadPattern(&block_scope, "link_output", subst_validator, tool.get(), 888 !ReadPattern(&block_scope, "link_output", subst_validator, tool.get(),
862 &Tool::set_link_output, err) || 889 &Tool::set_link_output, err) ||
863 !ReadPattern(&block_scope, "depend_output", subst_validator, tool.get(), 890 !ReadPattern(&block_scope, "depend_output", subst_validator, tool.get(),
864 &Tool::set_depend_output, err) || 891 &Tool::set_depend_output, err) ||
865 !ReadPattern(&block_scope, "runtime_link_output", subst_validator, 892 !ReadPattern(&block_scope, "runtime_link_output", subst_validator,
866 tool.get(), &Tool::set_runtime_link_output, err) || 893 tool.get(), &Tool::set_runtime_link_output, err) ||
867 !ReadString(&block_scope, "output_prefix", tool.get(), 894 !ReadString(&block_scope, "output_prefix", tool.get(),
868 &Tool::set_output_prefix, err) || 895 &Tool::set_output_prefix, err) ||
896 !ReadPattern(&block_scope, "default_output_dir", subst_validator,
897 tool.get(), &Tool::set_default_output_dir, err) ||
869 !ReadPrecompiledHeaderType(&block_scope, tool.get(), err) || 898 !ReadPrecompiledHeaderType(&block_scope, tool.get(), err) ||
870 !ReadBool(&block_scope, "restat", tool.get(), &Tool::set_restat, err) || 899 !ReadBool(&block_scope, "restat", tool.get(), &Tool::set_restat, err) ||
871 !ReadPattern(&block_scope, "rspfile", subst_validator, tool.get(), 900 !ReadPattern(&block_scope, "rspfile", subst_validator, tool.get(),
872 &Tool::set_rspfile, err) || 901 &Tool::set_rspfile, err) ||
873 !ReadPattern(&block_scope, "rspfile_content", subst_validator, tool.get(), 902 !ReadPattern(&block_scope, "rspfile_content", subst_validator, tool.get(),
874 &Tool::set_rspfile_content, err)) { 903 &Tool::set_rspfile_content, err)) {
875 return Value(); 904 return Value();
876 } 905 }
877 906
878 if (tool_type != Toolchain::TYPE_COPY && 907 if (tool_type != Toolchain::TYPE_COPY &&
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 return Value(); 1042 return Value();
1014 1043
1015 Scope::KeyValueMap values; 1044 Scope::KeyValueMap values;
1016 block_scope.GetCurrentScopeValues(&values); 1045 block_scope.GetCurrentScopeValues(&values);
1017 toolchain->args() = values; 1046 toolchain->args() = values;
1018 1047
1019 return Value(); 1048 return Value();
1020 } 1049 }
1021 1050
1022 } // namespace functions 1051 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/example/build/toolchain/BUILD.gn ('k') | tools/gn/ninja_binary_target_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698