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 "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" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 *dest = v->string_value(); | 30 *dest = v->string_value(); |
31 return true; | 31 return true; |
32 } | 32 } |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 // toolchain ------------------------------------------------------------------- | 36 // toolchain ------------------------------------------------------------------- |
37 | 37 |
38 const char kToolchain[] = "toolchain"; | 38 const char kToolchain[] = "toolchain"; |
39 const char kToolchain_Help[] = | 39 const char kToolchain_Help[] = |
40 "TODO(brettw) write this."; | 40 "toolchain: Defines a toolchain.\n" |
41 "\n" | |
42 " A toolchain is a set of commands and build flags use to compile the\n" | |
koz (OOO until 15th September)
2013/09/16 23:05:42
nit: use -> used
| |
43 " source code. You can have more than one toolchain in use at once in\n" | |
44 " a build.\n" | |
45 "\n" | |
46 " A toolchain specifies the commands to run for various input files\n" | |
koz (OOO until 15th September)
2013/09/16 23:05:42
"input files types" -> "input file types" ?
| |
47 " types via the \"tool\" call (see \"gn help tool\") and specifies\n" | |
48 " arguments to be passed to the toolchain build via the\n" | |
49 " \"toolchain_args\" call (see \"gn help toolchain_args\").\n" | |
50 "\n" | |
51 "Invoking targets in toolchains:\n" | |
52 "\n" | |
53 " By default, when a target depends on another, there is an implicit\n" | |
54 " toolchain label that is inherited, so the dependee has the same one\n" | |
55 " as the dependant.\n" | |
56 "\n" | |
57 " You can override this and refer to any other toolchain by explicitly\n" | |
58 " labeling the toolchain to use. For example:\n" | |
59 " datadeps = [ \"//plugins:mine(//toolchains:plugin_toolchain)\" ]\n" | |
60 " The string \"//build/toolchains:plugin_toolchain\" is a label that\n" | |
61 " identifies the toolchain declaration for compiling the sources.\n" | |
62 "\n" | |
63 " To load a file in an alternate toolchain, GN does the following:\n" | |
64 "\n" | |
65 " 1. Loads the file with the toolchain definition in it (as determined\n" | |
66 " by the toolchain label).\n" | |
67 " 2. Re-runs the master build configuration file, applying the\n" | |
68 " arguments specified by the toolchain_args section of the toolchain\n" | |
69 " definition (see \"gn help toolchain_args\").\n" | |
70 " 3. Loads the destination build file in the context of the\n" | |
71 " configuration file in the previous step.\n" | |
72 "\n" | |
73 "Example:\n" | |
74 " toolchain(\"plugin_toolchain\") {\n" | |
75 " tool(\"cc\") {\n" | |
76 " command = \"gcc $in\"" | |
77 " }\n" | |
78 "\n" | |
79 " toolchain_args() {\n" | |
80 " is_plugin = true\n" | |
81 " is_32bit = true\n" | |
82 " is_64bit = false\n" | |
83 " }\n" | |
84 " }\n"; | |
41 | 85 |
42 Value RunToolchain(Scope* scope, | 86 Value RunToolchain(Scope* scope, |
43 const FunctionCallNode* function, | 87 const FunctionCallNode* function, |
44 const std::vector<Value>& args, | 88 const std::vector<Value>& args, |
45 BlockNode* block, | 89 BlockNode* block, |
46 Err* err) { | 90 Err* err) { |
47 if (!EnsureNotProcessingImport(function, scope, err) || | 91 if (!EnsureNotProcessingImport(function, scope, err) || |
48 !EnsureNotProcessingBuildConfig(function, scope, err)) | 92 !EnsureNotProcessingBuildConfig(function, scope, err)) |
49 return Value(); | 93 return Value(); |
50 | 94 |
(...skipping 29 matching lines...) Expand all Loading... | |
80 build_settings->item_tree().MarkItemDefinedLocked(build_settings, label, | 124 build_settings->item_tree().MarkItemDefinedLocked(build_settings, label, |
81 err); | 125 err); |
82 } | 126 } |
83 return Value(); | 127 return Value(); |
84 } | 128 } |
85 | 129 |
86 // tool ------------------------------------------------------------------------ | 130 // tool ------------------------------------------------------------------------ |
87 | 131 |
88 const char kTool[] = "tool"; | 132 const char kTool[] = "tool"; |
89 const char kTool_Help[] = | 133 const char kTool_Help[] = |
90 "TODO(brettw) write this."; | 134 "tool: Specify arguments to a toolchain tool.\n" |
135 "\n" | |
136 " tool(<command type>) { <command flags> }\n" | |
137 "\n" | |
138 " Used inside a toolchain definition to define a command to run for a\n" | |
139 " given file type. See also \"gn help toolchain\".\n" | |
140 "\n" | |
141 "Command types:\n" | |
142 " The following values may be passed to the tool() function for the type\n" | |
143 " of the command:\n" | |
144 "\n" | |
145 " \"cc\", \"cxx\", \"objc\", \"objcxx\", \"asm\", \"alink\", \"solink\",\n" | |
146 " \"link\", \"stamp\", \"copy\"\n" | |
147 "\n" | |
148 "Command flags:\n" | |
149 "\n" | |
150 " These variables may be specified in the { } block after the tool call.\n" | |
151 " They are passed directly to Ninja. See the ninja documentation for how\n" | |
152 " they work. Don't forget to backslash-escape $ required by Ninja to\n" | |
153 " prevent GN from doing variable expansion.\n" | |
154 "\n" | |
155 " command, depfile, deps, description, pool, restat, rspfile,\n" | |
156 " rspfile_content\n" | |
157 "\n" | |
158 "Example:\n" | |
159 " toolchain(\"my_toolchain\") {\n" | |
160 " tool(\"cc\") {\n" | |
161 " command = \"gcc \\$in -o \\$out\"\n" | |
162 " description = \"GCC \\$in\"\n" | |
163 " }\n" | |
164 " tool(\"cxx\") {\n" | |
165 " command = \"g++ \\$in -o \\$out\"\n" | |
166 " description = \"G++ \\$in\"\n" | |
167 " }\n" | |
168 " }\n"; | |
91 | 169 |
92 Value RunTool(Scope* scope, | 170 Value RunTool(Scope* scope, |
93 const FunctionCallNode* function, | 171 const FunctionCallNode* function, |
94 const std::vector<Value>& args, | 172 const std::vector<Value>& args, |
95 BlockNode* block, | 173 BlockNode* block, |
96 Err* err) { | 174 Err* err) { |
97 // Find the toolchain definition we're executing inside of. The toolchain | 175 // Find the toolchain definition we're executing inside of. The toolchain |
98 // function will set a property pointing to it that we'll pick up. | 176 // function will set a property pointing to it that we'll pick up. |
99 Toolchain* toolchain = reinterpret_cast<Toolchain*>( | 177 Toolchain* toolchain = reinterpret_cast<Toolchain*>( |
100 scope->GetProperty(&kToolchainPropertyKey, NULL)); | 178 scope->GetProperty(&kToolchainPropertyKey, NULL)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 toolchain->SetTool(tool_type, t); | 217 toolchain->SetTool(tool_type, t); |
140 return Value(); | 218 return Value(); |
141 } | 219 } |
142 | 220 |
143 // toolchain_args -------------------------------------------------------------- | 221 // toolchain_args -------------------------------------------------------------- |
144 | 222 |
145 extern const char kToolchainArgs[] = "toolchain_args"; | 223 extern const char kToolchainArgs[] = "toolchain_args"; |
146 extern const char kToolchainArgs_Help[] = | 224 extern const char kToolchainArgs_Help[] = |
147 "toolchain_args: Set build arguments for toolchain build setup.\n" | 225 "toolchain_args: Set build arguments for toolchain build setup.\n" |
148 "\n" | 226 "\n" |
227 " Used inside a toolchain definition to pass arguments to an alternate\n" | |
228 " toolchain's invocation of the build.\n" | |
229 "\n" | |
149 " When you specify a target using an alternate toolchain, the master\n" | 230 " When you specify a target using an alternate toolchain, the master\n" |
150 " build configuration file is re-interpreted in the context of that\n" | 231 " build configuration file is re-interpreted in the context of that\n" |
151 " toolchain. This function allows you to control the arguments passed\n" | 232 " toolchain (see \"gn help toolchain\"). The toolchain_args function\n" |
152 " into this alternate invocation of the build.\n" | 233 " allows you to control the arguments passed into this alternate\n" |
234 " invocation of the build.\n" | |
153 "\n" | 235 "\n" |
154 " Any default system arguments or arguments passed in on the command-\n" | 236 " Any default system arguments or arguments passed in on the command-\n" |
155 " line will also be passed to the alternate invocation unless explicitly\n" | 237 " line will also be passed to the alternate invocation unless explicitly\n" |
156 " overriddey by toolchain_args.\n" | 238 " overridden by toolchain_args.\n" |
157 "\n" | 239 "\n" |
158 " The toolchain_args will be ignored when the toolchain being defined\n" | 240 " The toolchain_args will be ignored when the toolchain being defined\n" |
159 " is the default. In this case, it's expected you want the default\n" | 241 " is the default. In this case, it's expected you want the default\n" |
160 " argument values.\n" | 242 " argument values.\n" |
161 "\n" | 243 "\n" |
162 " See also \"gn help buildargs\" for an overview of these arguments.\n" | 244 " See also \"gn help buildargs\" for an overview of these arguments.\n" |
163 "\n" | 245 "\n" |
164 "Example:\n" | 246 "Example:\n" |
165 " toolchain(\"my_weird_toolchain\") {\n" | 247 " toolchain(\"my_weird_toolchain\") {\n" |
166 " ...\n" | 248 " ...\n" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 return Value(); | 286 return Value(); |
205 | 287 |
206 Scope::KeyValueMap values; | 288 Scope::KeyValueMap values; |
207 block_scope.GetCurrentScopeValues(&values); | 289 block_scope.GetCurrentScopeValues(&values); |
208 toolchain->args() = values; | 290 toolchain->args() = values; |
209 | 291 |
210 return Value(); | 292 return Value(); |
211 } | 293 } |
212 | 294 |
213 } // namespace functions | 295 } // namespace functions |
OLD | NEW |