| 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 | 7 | 
| 8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" | 
| 9 #include "tools/gn/functions.h" | 9 #include "tools/gn/functions.h" | 
| 10 #include "tools/gn/parse_tree.h" | 10 #include "tools/gn/parse_tree.h" | 
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 187   return type == Toolchain::TYPE_CC || | 187   return type == Toolchain::TYPE_CC || | 
| 188          type == Toolchain::TYPE_CXX || | 188          type == Toolchain::TYPE_CXX || | 
| 189          type == Toolchain::TYPE_OBJC || | 189          type == Toolchain::TYPE_OBJC || | 
| 190          type == Toolchain::TYPE_OBJCXX || | 190          type == Toolchain::TYPE_OBJCXX || | 
| 191          type == Toolchain::TYPE_RC || | 191          type == Toolchain::TYPE_RC || | 
| 192          type == Toolchain::TYPE_ASM; | 192          type == Toolchain::TYPE_ASM; | 
| 193 } | 193 } | 
| 194 | 194 | 
| 195 bool IsLinkerTool(Toolchain::ToolType type) { | 195 bool IsLinkerTool(Toolchain::ToolType type) { | 
| 196   return type == Toolchain::TYPE_ALINK || | 196   return type == Toolchain::TYPE_ALINK || | 
|  | 197          type == Toolchain::TYPE_DYLINK || | 
| 197          type == Toolchain::TYPE_SOLINK || | 198          type == Toolchain::TYPE_SOLINK || | 
| 198          type == Toolchain::TYPE_LINK; | 199          type == Toolchain::TYPE_LINK; | 
| 199 } | 200 } | 
| 200 | 201 | 
| 201 bool IsPatternInOutputList(const SubstitutionList& output_list, | 202 bool IsPatternInOutputList(const SubstitutionList& output_list, | 
| 202                            const SubstitutionPattern& pattern) { | 203                            const SubstitutionPattern& pattern) { | 
| 203   for (const auto& cur : output_list.list()) { | 204   for (const auto& cur : output_list.list()) { | 
| 204     if (pattern.ranges().size() == cur.ranges().size() && | 205     if (pattern.ranges().size() == cur.ranges().size() && | 
| 205         std::equal(pattern.ranges().begin(), pattern.ranges().end(), | 206         std::equal(pattern.ranges().begin(), pattern.ranges().end(), | 
| 206                    cur.ranges().begin())) | 207                    cur.ranges().begin())) | 
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 496     "          outputs = [\n" | 497     "          outputs = [\n" | 
| 497     "            \"{{root_out_dir}}/{{target_output_name}}" | 498     "            \"{{root_out_dir}}/{{target_output_name}}" | 
| 498                      "{{output_extension}}\",\n" | 499                      "{{output_extension}}\",\n" | 
| 499     "            \"{{root_out_dir}}/{{target_output_name}}.lib\",\n" | 500     "            \"{{root_out_dir}}/{{target_output_name}}.lib\",\n" | 
| 500     "          ]\n" | 501     "          ]\n" | 
| 501     "\n" | 502     "\n" | 
| 502     "    link_output  [string with substitutions]\n" | 503     "    link_output  [string with substitutions]\n" | 
| 503     "    depend_output  [string with substitutions]\n" | 504     "    depend_output  [string with substitutions]\n" | 
| 504     "        Valid for: \"solink\" only (optional)\n" | 505     "        Valid for: \"solink\" only (optional)\n" | 
| 505     "\n" | 506     "\n" | 
| 506     "        These two files specify whch of the outputs from the solink\n" | 507     "        These two files specify which of the outputs from the solink\n" | 
| 507     "        tool should be used for linking and dependency tracking. These\n" | 508     "        tool should be used for linking and dependency tracking. These\n" | 
| 508     "        should match entries in the \"outputs\". If unspecified, the\n" | 509     "        should match entries in the \"outputs\". If unspecified, the\n" | 
| 509     "        first item in the \"outputs\" array will be used for both. See\n" | 510     "        first item in the \"outputs\" array will be used for both. See\n" | 
| 510     "        \"Separate linking and dependencies for shared libraries\"\n" | 511     "        \"Separate linking and dependencies for shared libraries\"\n" | 
| 511     "        below for more.\n" | 512     "        below for more.\n" | 
| 512     "\n" | 513     "\n" | 
| 513     "        On Windows, where the tools produce a .dll shared library and\n" | 514     "        On Windows, where the tools produce a .dll shared library and\n" | 
| 514     "        a .lib import library, you will want both of these to be the\n" | 515     "        a .lib import library, you will want both of these to be the\n" | 
| 515     "        import library. On Linux, if you're not doing the separate\n" | 516     "        import library. On Linux, if you're not doing the separate\n" | 
| 516     "        linking/dependency optimization, both of these should be the\n" | 517     "        linking/dependency optimization, both of these should be the\n" | 
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 840     // All tools except the copy and stamp tools should have outputs. The copy | 841     // All tools except the copy and stamp tools should have outputs. The copy | 
| 841     // and stamp tool's outputs are generated internally. | 842     // and stamp tool's outputs are generated internally. | 
| 842     if (!ReadOutputs(&block_scope, function, subst_output_validator, | 843     if (!ReadOutputs(&block_scope, function, subst_output_validator, | 
| 843                      tool.get(), err)) | 844                      tool.get(), err)) | 
| 844       return Value(); | 845       return Value(); | 
| 845   } | 846   } | 
| 846 | 847 | 
| 847   // Validate that the link_output and depend_output refer to items in the | 848   // Validate that the link_output and depend_output refer to items in the | 
| 848   // outputs and aren't defined for irrelevant tool types. | 849   // outputs and aren't defined for irrelevant tool types. | 
| 849   if (!tool->link_output().empty()) { | 850   if (!tool->link_output().empty()) { | 
| 850     if (tool_type != Toolchain::TYPE_SOLINK) { | 851     if (tool_type != Toolchain::TYPE_SOLINK && | 
|  | 852         tool_type != Toolchain::TYPE_DYLINK) { | 
| 851       *err = Err(function, "This tool specifies a link_output.", | 853       *err = Err(function, "This tool specifies a link_output.", | 
| 852           "This is only valid for solink tools."); | 854           "This is only valid for solink and dylink tools."); | 
| 853       return Value(); | 855       return Value(); | 
| 854     } | 856     } | 
| 855     if (!IsPatternInOutputList(tool->outputs(), tool->link_output())) { | 857     if (!IsPatternInOutputList(tool->outputs(), tool->link_output())) { | 
| 856       *err = Err(function, "This tool's link_output is bad.", | 858       *err = Err(function, "This tool's link_output is bad.", | 
| 857                  "It must match one of the outputs."); | 859                  "It must match one of the outputs."); | 
| 858       return Value(); | 860       return Value(); | 
| 859     } | 861     } | 
| 860   } | 862   } | 
| 861   if (!tool->depend_output().empty()) { | 863   if (!tool->depend_output().empty()) { | 
| 862     if (tool_type != Toolchain::TYPE_SOLINK) { | 864     if (tool_type != Toolchain::TYPE_SOLINK && | 
|  | 865         tool_type != Toolchain::TYPE_DYLINK) { | 
| 863       *err = Err(function, "This tool specifies a depend_output.", | 866       *err = Err(function, "This tool specifies a depend_output.", | 
| 864           "This is only valid for solink tools."); | 867           "This is only valid for solink and dylink tools."); | 
| 865       return Value(); | 868       return Value(); | 
| 866     } | 869     } | 
| 867     if (!IsPatternInOutputList(tool->outputs(), tool->depend_output())) { | 870     if (!IsPatternInOutputList(tool->outputs(), tool->depend_output())) { | 
| 868       *err = Err(function, "This tool's depend_output is bad.", | 871       *err = Err(function, "This tool's depend_output is bad.", | 
| 869                  "It must match one of the outputs."); | 872                  "It must match one of the outputs."); | 
| 870       return Value(); | 873       return Value(); | 
| 871     } | 874     } | 
| 872   } | 875   } | 
| 873   if ((!tool->link_output().empty() && tool->depend_output().empty()) || | 876   if ((!tool->link_output().empty() && tool->depend_output().empty()) || | 
| 874       (tool->link_output().empty() && !tool->depend_output().empty())) { | 877       (tool->link_output().empty() && !tool->depend_output().empty())) { | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 955     return Value(); | 958     return Value(); | 
| 956 | 959 | 
| 957   Scope::KeyValueMap values; | 960   Scope::KeyValueMap values; | 
| 958   block_scope.GetCurrentScopeValues(&values); | 961   block_scope.GetCurrentScopeValues(&values); | 
| 959   toolchain->args() = values; | 962   toolchain->args() = values; | 
| 960 | 963 | 
| 961   return Value(); | 964   return Value(); | 
| 962 } | 965 } | 
| 963 | 966 | 
| 964 }  // namespace functions | 967 }  // namespace functions | 
| OLD | NEW | 
|---|