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

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

Issue 350743004: Allow dependencies of toolchains in GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/builder_unittest.cc ('k') | tools/gn/ninja_copy_target_writer.cc » ('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 "tools/gn/err.h" 5 #include "tools/gn/err.h"
6 #include "tools/gn/functions.h" 6 #include "tools/gn/functions.h"
7 #include "tools/gn/parse_tree.h" 7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/scheduler.h" 8 #include "tools/gn/scheduler.h"
9 #include "tools/gn/scope.h" 9 #include "tools/gn/scope.h"
10 #include "tools/gn/settings.h" 10 #include "tools/gn/settings.h"
11 #include "tools/gn/toolchain.h" 11 #include "tools/gn/toolchain.h"
12 #include "tools/gn/value_extractors.h"
12 #include "tools/gn/variables.h" 13 #include "tools/gn/variables.h"
13 14
14 namespace functions { 15 namespace functions {
15 16
16 namespace { 17 namespace {
17 18
18 // This is jsut a unique value to take the address of to use as the key for 19 // This is jsut a unique value to take the address of to use as the key for
19 // the toolchain property on a scope. 20 // the toolchain property on a scope.
20 const int kToolchainPropertyKey = 0; 21 const int kToolchainPropertyKey = 0;
21 22
(...skipping 22 matching lines...) Expand all
44 "\n" 45 "\n"
45 " A toolchain is a set of commands and build flags used to compile the\n" 46 " A toolchain is a set of commands and build flags used to compile the\n"
46 " source code. You can have more than one toolchain in use at once in\n" 47 " source code. You can have more than one toolchain in use at once in\n"
47 " a build.\n" 48 " a build.\n"
48 "\n" 49 "\n"
49 " A toolchain specifies the commands to run for various input file\n" 50 " A toolchain specifies the commands to run for various input file\n"
50 " types via the \"tool\" call (see \"gn help tool\") and specifies\n" 51 " types via the \"tool\" call (see \"gn help tool\") and specifies\n"
51 " arguments to be passed to the toolchain build via the\n" 52 " arguments to be passed to the toolchain build via the\n"
52 " \"toolchain_args\" call (see \"gn help toolchain_args\").\n" 53 " \"toolchain_args\" call (see \"gn help toolchain_args\").\n"
53 "\n" 54 "\n"
55 " In addition, a toolchain can specify dependencies via the \"deps\"\n"
56 " variable like a target. These dependencies will be resolved before any\n"
57 " target in the toolchain is compiled. To avoid circular dependencies\n"
58 " these must be targets defined in another toolchain.\n"
59 "\n"
54 "Invoking targets in toolchains:\n" 60 "Invoking targets in toolchains:\n"
55 "\n" 61 "\n"
56 " By default, when a target depends on another, there is an implicit\n" 62 " By default, when a target depends on another, there is an implicit\n"
57 " toolchain label that is inherited, so the dependee has the same one\n" 63 " toolchain label that is inherited, so the dependee has the same one\n"
58 " as the dependent.\n" 64 " as the dependent.\n"
59 "\n" 65 "\n"
60 " You can override this and refer to any other toolchain by explicitly\n" 66 " You can override this and refer to any other toolchain by explicitly\n"
61 " labeling the toolchain to use. For example:\n" 67 " labeling the toolchain to use. For example:\n"
62 " datadeps = [ \"//plugins:mine(//toolchains:plugin_toolchain)\" ]\n" 68 " datadeps = [ \"//plugins:mine(//toolchains:plugin_toolchain)\" ]\n"
63 " The string \"//build/toolchains:plugin_toolchain\" is a label that\n" 69 " The string \"//build/toolchains:plugin_toolchain\" is a label that\n"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 toolchain->set_defined_from(function); 115 toolchain->set_defined_from(function);
110 toolchain->visibility().SetPublic(); 116 toolchain->visibility().SetPublic();
111 117
112 Scope block_scope(scope); 118 Scope block_scope(scope);
113 block_scope.SetProperty(&kToolchainPropertyKey, toolchain.get()); 119 block_scope.SetProperty(&kToolchainPropertyKey, toolchain.get());
114 block->ExecuteBlockInScope(&block_scope, err); 120 block->ExecuteBlockInScope(&block_scope, err);
115 block_scope.SetProperty(&kToolchainPropertyKey, NULL); 121 block_scope.SetProperty(&kToolchainPropertyKey, NULL);
116 if (err->has_error()) 122 if (err->has_error())
117 return Value(); 123 return Value();
118 124
125 // Read deps (if any).
126 const Value* deps_value = block_scope.GetValue(variables::kDeps, true);
127 if (deps_value) {
128 ExtractListOfLabels(
129 *deps_value, block_scope.GetSourceDir(),
130 ToolchainLabelForScope(&block_scope), &toolchain->deps(), err);
131 if (err->has_error())
132 return Value();
133 }
134
135
119 if (!block_scope.CheckForUnusedVars(err)) 136 if (!block_scope.CheckForUnusedVars(err))
120 return Value(); 137 return Value();
121 138
122 // Save this target for the file. 139 // Save this toolchain.
123 Scope::ItemVector* collector = scope->GetItemCollector(); 140 Scope::ItemVector* collector = scope->GetItemCollector();
124 if (!collector) { 141 if (!collector) {
125 *err = Err(function, "Can't define a toolchain in this context."); 142 *err = Err(function, "Can't define a toolchain in this context.");
126 return Value(); 143 return Value();
127 } 144 }
128 collector->push_back(new scoped_ptr<Item>(toolchain.PassAs<Item>())); 145 collector->push_back(new scoped_ptr<Item>(toolchain.PassAs<Item>()));
129 return Value(); 146 return Value();
130 } 147 }
131 148
132 // tool ------------------------------------------------------------------------ 149 // tool ------------------------------------------------------------------------
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return Value(); 324 return Value();
308 325
309 Scope::KeyValueMap values; 326 Scope::KeyValueMap values;
310 block_scope.GetCurrentScopeValues(&values); 327 block_scope.GetCurrentScopeValues(&values);
311 toolchain->args() = values; 328 toolchain->args() = values;
312 329
313 return Value(); 330 return Value();
314 } 331 }
315 332
316 } // namespace functions 333 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/builder_unittest.cc ('k') | tools/gn/ninja_copy_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698