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

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

Issue 1386783003: [GN]: Support for loadable modules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/functions.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 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_SOLINK || 197 type == Toolchain::TYPE_SOLINK ||
198 type == Toolchain::TYPE_SOLINK_MODULE ||
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()))
207 return true; 208 return true;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 " Compiler tools:\n" 392 " Compiler tools:\n"
392 " \"cc\": C compiler\n" 393 " \"cc\": C compiler\n"
393 " \"cxx\": C++ compiler\n" 394 " \"cxx\": C++ compiler\n"
394 " \"objc\": Objective C compiler\n" 395 " \"objc\": Objective C compiler\n"
395 " \"objcxx\": Objective C++ compiler\n" 396 " \"objcxx\": Objective C++ compiler\n"
396 " \"rc\": Resource compiler (Windows .rc files)\n" 397 " \"rc\": Resource compiler (Windows .rc files)\n"
397 " \"asm\": Assembler\n" 398 " \"asm\": Assembler\n"
398 "\n" 399 "\n"
399 " Linker tools:\n" 400 " Linker tools:\n"
400 " \"alink\": Linker for static libraries (archives)\n" 401 " \"alink\": Linker for static libraries (archives)\n"
401 " \"solink\": Linker for shared libraries\n" 402 " \"solink\": Linker for shared libraries\n"
Nico 2016/02/11 00:32:52 this didn't add solink_module to the documentation
Bons 2016/02/12 16:09:22 since you’re in the this code already why not add
Nico 2016/02/12 16:20:00 I don't know what to write :-) I looked at the doc
402 " \"link\": Linker for executables\n" 403 " \"link\": Linker for executables\n"
403 "\n" 404 "\n"
404 " Other tools:\n" 405 " Other tools:\n"
405 " \"stamp\": Tool for creating stamp files\n" 406 " \"stamp\": Tool for creating stamp files\n"
406 " \"copy\": Tool to copy files.\n" 407 " \"copy\": Tool to copy files.\n"
407 "\n" 408 "\n"
408 "Tool variables\n" 409 "Tool variables\n"
409 "\n" 410 "\n"
410 " command [string with substitutions]\n" 411 " command [string with substitutions]\n"
411 " Valid for: all tools (required)\n" 412 " Valid for: all tools (required)\n"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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_SOLINK_MODULE) {
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 solink_module 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_SOLINK_MODULE) {
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 solink_module 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
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
OLDNEW
« no previous file with comments | « tools/gn/docs/reference.md ('k') | tools/gn/functions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698