OLD | NEW |
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 bool IsCompilerTool(Toolchain::ToolType type) { | 187 bool IsCompilerTool(Toolchain::ToolType type) { |
188 return type == Toolchain::TYPE_CC || | 188 return type == Toolchain::TYPE_CC || |
189 type == Toolchain::TYPE_CXX || | 189 type == Toolchain::TYPE_CXX || |
190 type == Toolchain::TYPE_OBJC || | 190 type == Toolchain::TYPE_OBJC || |
191 type == Toolchain::TYPE_OBJCXX || | 191 type == Toolchain::TYPE_OBJCXX || |
192 type == Toolchain::TYPE_RC || | 192 type == Toolchain::TYPE_RC || |
193 type == Toolchain::TYPE_ASM; | 193 type == Toolchain::TYPE_ASM; |
194 } | 194 } |
195 | 195 |
196 bool IsLinkerTool(Toolchain::ToolType type) { | 196 bool IsLinkerTool(Toolchain::ToolType type) { |
197 return type == Toolchain::TYPE_ALINK || | 197 // "alink" is not counted as in the generic "linker" tool list. |
198 type == Toolchain::TYPE_SOLINK || | 198 return type == Toolchain::TYPE_SOLINK || |
199 type == Toolchain::TYPE_SOLINK_MODULE || | 199 type == Toolchain::TYPE_SOLINK_MODULE || |
200 type == Toolchain::TYPE_LINK; | 200 type == Toolchain::TYPE_LINK; |
201 } | 201 } |
202 | 202 |
203 bool IsPatternInOutputList(const SubstitutionList& output_list, | 203 bool IsPatternInOutputList(const SubstitutionList& output_list, |
204 const SubstitutionPattern& pattern) { | 204 const SubstitutionPattern& pattern) { |
205 for (const auto& cur : output_list.list()) { | 205 for (const auto& cur : output_list.list()) { |
206 if (pattern.ranges().size() == cur.ranges().size() && | 206 if (pattern.ranges().size() == cur.ranges().size() && |
207 std::equal(pattern.ranges().begin(), pattern.ranges().end(), | 207 std::equal(pattern.ranges().begin(), pattern.ranges().end(), |
208 cur.ranges().begin())) | 208 cur.ranges().begin())) |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 "\n" | 683 "\n" |
684 " {{source_gen_dir}}\n" | 684 " {{source_gen_dir}}\n" |
685 " {{source_out_dir}}\n" | 685 " {{source_out_dir}}\n" |
686 " The directory in the generated file and output directories,\n" | 686 " The directory in the generated file and output directories,\n" |
687 " respectively, for the current input file. If the source file\n" | 687 " respectively, for the current input file. If the source file\n" |
688 " is in the same directory as the target is declared in, they will\n" | 688 " is in the same directory as the target is declared in, they will\n" |
689 " will be the same as the \"target\" versions above.\n" | 689 " will be the same as the \"target\" versions above.\n" |
690 " Example: \"gen/base/test\"\n" | 690 " Example: \"gen/base/test\"\n" |
691 "\n" | 691 "\n" |
692 " Linker tools have multiple inputs and (potentially) multiple outputs\n" | 692 " Linker tools have multiple inputs and (potentially) multiple outputs\n" |
| 693 " The static library tool (\"alink\") is not considered a linker tool.\n" |
693 " The following expansions are available:\n" | 694 " The following expansions are available:\n" |
694 "\n" | 695 "\n" |
695 " {{inputs}}\n" | 696 " {{inputs}}\n" |
696 " {{inputs_newline}}\n" | 697 " {{inputs_newline}}\n" |
697 " Expands to the inputs to the link step. This will be a list of\n" | 698 " Expands to the inputs to the link step. This will be a list of\n" |
698 " object files and static libraries.\n" | 699 " object files and static libraries.\n" |
699 " Example: \"obj/foo.o obj/bar.o obj/somelibrary.a\"\n" | 700 " Example: \"obj/foo.o obj/bar.o obj/somelibrary.a\"\n" |
700 "\n" | 701 "\n" |
701 " The \"_newline\" version will separate the input files with\n" | 702 " The \"_newline\" version will separate the input files with\n" |
702 " newlines instead of spaces. This is useful in response files:\n" | 703 " newlines instead of spaces. This is useful in response files:\n" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 "\n" | 743 "\n" |
743 " {{solibs}}\n" | 744 " {{solibs}}\n" |
744 " Extra libraries from shared library dependencide not specified\n" | 745 " Extra libraries from shared library dependencide not specified\n" |
745 " in the {{inputs}}. This is the list of link_output files from\n" | 746 " in the {{inputs}}. This is the list of link_output files from\n" |
746 " shared libraries (if the solink tool specifies a \"link_output\"\n" | 747 " shared libraries (if the solink tool specifies a \"link_output\"\n" |
747 " variable separate from the \"depend_output\").\n" | 748 " variable separate from the \"depend_output\").\n" |
748 "\n" | 749 "\n" |
749 " These should generally be treated the same as libs by your tool.\n" | 750 " These should generally be treated the same as libs by your tool.\n" |
750 " Example: \"libfoo.so libbar.so\"\n" | 751 " Example: \"libfoo.so libbar.so\"\n" |
751 "\n" | 752 "\n" |
| 753 " The static library (\"alink\") tool allows {{arflags}} plus the common\n" |
| 754 " tool substitutions.\n" |
| 755 "\n" |
752 " The copy tool allows the common compiler/linker substitutions, plus\n" | 756 " The copy tool allows the common compiler/linker substitutions, plus\n" |
753 " {{source}} which is the source of the copy. The stamp tool allows\n" | 757 " {{source}} which is the source of the copy. The stamp tool allows\n" |
754 " only the common tool substitutions.\n" | 758 " only the common tool substitutions.\n" |
755 "\n" | 759 "\n" |
756 " The copy_bundle_data and compile_xcassets tools only allows the common\n" | 760 " The copy_bundle_data and compile_xcassets tools only allows the common\n" |
757 " tool substitutions. Both tools are required to create iOS/OS X bundles\n" | 761 " tool substitutions. Both tools are required to create iOS/OS X bundles\n" |
758 " and need only be defined on those platforms.\n" | 762 " and need only be defined on those platforms.\n" |
759 "\n" | 763 "\n" |
760 " The copy_bundle_data tool will be called with one source and needs to\n" | 764 " The copy_bundle_data tool will be called with one source and needs to\n" |
761 " copy (optionally optimizing the data representation) to its output. It\n" | 765 " copy (optionally optimizing the data representation) to its output. It\n" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 // tool type. There are different validators for the "outputs" than for the | 856 // tool type. There are different validators for the "outputs" than for the |
853 // rest of the strings. | 857 // rest of the strings. |
854 bool (*subst_validator)(SubstitutionType) = nullptr; | 858 bool (*subst_validator)(SubstitutionType) = nullptr; |
855 bool (*subst_output_validator)(SubstitutionType) = nullptr; | 859 bool (*subst_output_validator)(SubstitutionType) = nullptr; |
856 if (IsCompilerTool(tool_type)) { | 860 if (IsCompilerTool(tool_type)) { |
857 subst_validator = &IsValidCompilerSubstitution; | 861 subst_validator = &IsValidCompilerSubstitution; |
858 subst_output_validator = &IsValidCompilerOutputsSubstitution; | 862 subst_output_validator = &IsValidCompilerOutputsSubstitution; |
859 } else if (IsLinkerTool(tool_type)) { | 863 } else if (IsLinkerTool(tool_type)) { |
860 subst_validator = &IsValidLinkerSubstitution; | 864 subst_validator = &IsValidLinkerSubstitution; |
861 subst_output_validator = &IsValidLinkerOutputsSubstitution; | 865 subst_output_validator = &IsValidLinkerOutputsSubstitution; |
| 866 } else if (tool_type == Toolchain::TYPE_ALINK) { |
| 867 subst_validator = &IsValidALinkSubstitution; |
| 868 // ALink uses the standard output file patterns as other linker tools. |
| 869 subst_output_validator = &IsValidLinkerOutputsSubstitution; |
862 } else if (tool_type == Toolchain::TYPE_COPY || | 870 } else if (tool_type == Toolchain::TYPE_COPY || |
863 tool_type == Toolchain::TYPE_COPY_BUNDLE_DATA) { | 871 tool_type == Toolchain::TYPE_COPY_BUNDLE_DATA) { |
864 subst_validator = &IsValidCopySubstitution; | 872 subst_validator = &IsValidCopySubstitution; |
865 subst_output_validator = &IsValidCopySubstitution; | 873 subst_output_validator = &IsValidCopySubstitution; |
866 } else if (tool_type == Toolchain::TYPE_COMPILE_XCASSETS) { | 874 } else if (tool_type == Toolchain::TYPE_COMPILE_XCASSETS) { |
867 subst_validator = &IsValidCompileXCassetsSubstitution; | 875 subst_validator = &IsValidCompileXCassetsSubstitution; |
868 subst_output_validator = &IsValidCompileXCassetsSubstitution; | 876 subst_output_validator = &IsValidCompileXCassetsSubstitution; |
869 } else { | 877 } else { |
870 subst_validator = &IsValidToolSubstitution; | 878 subst_validator = &IsValidToolSubstitution; |
871 subst_output_validator = &IsValidToolSubstitution; | 879 subst_output_validator = &IsValidToolSubstitution; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 return Value(); | 1050 return Value(); |
1043 | 1051 |
1044 Scope::KeyValueMap values; | 1052 Scope::KeyValueMap values; |
1045 block_scope.GetCurrentScopeValues(&values); | 1053 block_scope.GetCurrentScopeValues(&values); |
1046 toolchain->args() = values; | 1054 toolchain->args() = values; |
1047 | 1055 |
1048 return Value(); | 1056 return Value(); |
1049 } | 1057 } |
1050 | 1058 |
1051 } // namespace functions | 1059 } // namespace functions |
OLD | NEW |