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

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

Issue 333243004: Rename GN source_prereqs to inputs, enhance "desc" (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/command_desc.cc ('k') | tools/gn/ninja_action_target_writer_unittest.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/functions.h" 5 #include "tools/gn/functions.h"
6 6
7 #include "tools/gn/config_values_generator.h" 7 #include "tools/gn/config_values_generator.h"
8 #include "tools/gn/err.h" 8 #include "tools/gn/err.h"
9 #include "tools/gn/parse_tree.h" 9 #include "tools/gn/parse_tree.h"
10 #include "tools/gn/scope.h" 10 #include "tools/gn/scope.h"
11 #include "tools/gn/target_generator.h" 11 #include "tools/gn/target_generator.h"
12 #include "tools/gn/value.h" 12 #include "tools/gn/value.h"
13 #include "tools/gn/variables.h" 13 #include "tools/gn/variables.h"
14 14
15 #define DEPENDENT_CONFIG_VARS \ 15 #define DEPENDENT_CONFIG_VARS \
16 " Dependent configs: all_dependent_configs, direct_dependent_configs\n" 16 " Dependent configs: all_dependent_configs, direct_dependent_configs\n"
17 #define DEPS_VARS \ 17 #define DEPS_VARS \
18 " Deps: data, datadeps, deps, forward_dependent_configs_from, hard_dep\n" 18 " Deps: data, datadeps, deps, forward_dependent_configs_from, hard_dep\n"
19 #define GENERAL_TARGET_VARS \ 19 #define GENERAL_TARGET_VARS \
20 " General: configs, source_prereqs, sources\n" 20 " General: configs, inputs, sources\n"
21 21
22 namespace functions { 22 namespace functions {
23 23
24 namespace { 24 namespace {
25 25
26 Value ExecuteGenericTarget(const char* target_type, 26 Value ExecuteGenericTarget(const char* target_type,
27 Scope* scope, 27 Scope* scope,
28 const FunctionCallNode* function, 28 const FunctionCallNode* function,
29 const std::vector<Value>& args, 29 const std::vector<Value>& args,
30 BlockNode* block, 30 BlockNode* block,
(...skipping 22 matching lines...) Expand all
53 } // namespace 53 } // namespace
54 54
55 // action ---------------------------------------------------------------------- 55 // action ----------------------------------------------------------------------
56 56
57 // Common help paragraph on script runtime execution directories. 57 // Common help paragraph on script runtime execution directories.
58 #define SCRIPT_EXECUTION_CONTEXT \ 58 #define SCRIPT_EXECUTION_CONTEXT \
59 " The script will be executed with the given arguments with the current\n"\ 59 " The script will be executed with the given arguments with the current\n"\
60 " directory being that of the root build directory. If you pass files\n"\ 60 " directory being that of the root build directory. If you pass files\n"\
61 " to your script, see \"gn help rebase_path\" for how to convert\n" \ 61 " to your script, see \"gn help rebase_path\" for how to convert\n" \
62 " file names to be relative to the build directory (file names in the\n" \ 62 " file names to be relative to the build directory (file names in the\n" \
63 " sources, outputs, and source_prereqs will be all treated as relative\n" \ 63 " sources, outputs, and inputs will be all treated as relative to the\n" \
64 " to the current build file and converted as needed automatically).\n" 64 " current build file and converted as needed automatically).\n"
65 65
66 // Common help paragraph on script output directories. 66 // Common help paragraph on script output directories.
67 #define SCRIPT_EXECUTION_OUTPUTS \ 67 #define SCRIPT_EXECUTION_OUTPUTS \
68 " All output files must be inside the output directory of the build.\n" \ 68 " All output files must be inside the output directory of the build.\n" \
69 " You would generally use |$target_out_dir| or |$target_gen_dir| to\n" \ 69 " You would generally use |$target_out_dir| or |$target_gen_dir| to\n" \
70 " reference the output or generated intermediate file directories,\n" \ 70 " reference the output or generated intermediate file directories,\n" \
71 " respectively.\n" 71 " respectively.\n"
72 72
73 #define ACTION_DEPS \ 73 #define ACTION_DEPS \
74 " The \"deps\" for an action will always be completed before any part\n" \ 74 " The \"deps\" for an action will always be completed before any part\n" \
75 " of the action is run so it can depend on the output of previous\n" \ 75 " of the action is run so it can depend on the output of previous\n" \
76 " steps. The \"datadeps\" will be built if the action is built, but\n" \ 76 " steps. The \"datadeps\" will be built if the action is built, but\n" \
77 " may not have completed before all steps of the action are started.\n" \ 77 " may not have completed before all steps of the action are started.\n" \
78 " This can give additional parallelism in the build for runtime-only\n" \ 78 " This can give additional parallelism in the build for runtime-only\n" \
79 " dependencies.\n" 79 " dependencies.\n"
80 80
81 const char kAction[] = "action"; 81 const char kAction[] = "action";
82 const char kAction_HelpShort[] = 82 const char kAction_HelpShort[] =
83 "action: Declare a target that runs a script a single time."; 83 "action: Declare a target that runs a script a single time.";
84 const char kAction_Help[] = 84 const char kAction_Help[] =
85 "action: Declare a target that runs a script a single time.\n" 85 "action: Declare a target that runs a script a single time.\n"
86 "\n" 86 "\n"
87 " This target type allows you to run a script a single time to produce\n" 87 " This target type allows you to run a script a single time to produce\n"
88 " or more output files. If you want to run a script once for each of a\n" 88 " or more output files. If you want to run a script once for each of a\n"
89 " set of input files, see \"gn help action_foreach\".\n" 89 " set of input files, see \"gn help action_foreach\".\n"
90 "\n" 90 "\n"
91 "Inputs\n" 91 "Inputs\n"
92 "\n" 92 "\n"
93 " In an action the \"sources\" and \"source_prereqs\" are treated the\n" 93 " In an action the \"sources\" and \"inputs\" are treated the same:\n"
94 " same: they're both input dependencies on script execution with no\n" 94 " they're both input dependencies on script execution with no special\n"
95 " special handling. If you want to pass the sources to your script, you\n" 95 " handling. If you want to pass the sources to your script, you must do\n"
96 " must do so explicitly by including them in the \"args\". Note also\n" 96 " so explicitly by including them in the \"args\". Note also that this\n"
97 " that this means there is no special handling of paths since GN\n" 97 " means there is no special handling of paths since GN doesn't know\n"
98 " doesn't know which of the args are paths and not. You will want to use\n" 98 " which of the args are paths and not. You will want to use\n"
99 " rebase_path() to convert paths to be relative to the root_build_dir.\n" 99 " rebase_path() to convert paths to be relative to the root_build_dir.\n"
100 "\n" 100 "\n"
101 " You can dynamically write input dependencies (for incremental rebuilds\n"
102 " if an input file changes) by writing a depfile when the script is run\n"
103 " (see \"gn help depfile\"). This is more flexible than \"inputs\".\n"
104 "\n"
101 " It is recommended you put inputs to your script in the \"sources\"\n" 105 " It is recommended you put inputs to your script in the \"sources\"\n"
102 " variable, and stuff like other Python files required to run your\n" 106 " variable, and stuff like other Python files required to run your\n"
103 " script in the \"source_prereqs\" variable.\n" 107 " script in the \"inputs\" variable.\n"
104 "\n" 108 "\n"
105 ACTION_DEPS 109 ACTION_DEPS
106 "\n" 110 "\n"
107 "Outputs\n" 111 "Outputs\n"
108 "\n" 112 "\n"
109 " You should specify files created by your script by specifying them in\n" 113 " You should specify files created by your script by specifying them in\n"
110 " the \"outputs\".\n" 114 " the \"outputs\".\n"
111 "\n" 115 "\n"
112 SCRIPT_EXECUTION_CONTEXT 116 SCRIPT_EXECUTION_CONTEXT
113 "\n" 117 "\n"
114 "File name handling\n" 118 "File name handling\n"
115 "\n" 119 "\n"
116 SCRIPT_EXECUTION_OUTPUTS 120 SCRIPT_EXECUTION_OUTPUTS
117 "\n" 121 "\n"
118 "Variables\n" 122 "Variables\n"
119 "\n" 123 "\n"
120 " args, data, datadeps, depfile, deps, outputs*, script*,\n" 124 " args, data, datadeps, depfile, deps, outputs*, script*,\n"
121 " source_prereqs, sources\n" 125 " inputs, sources\n"
122 " * = required\n" 126 " * = required\n"
123 "\n" 127 "\n"
124 "Example\n" 128 "Example\n"
125 "\n" 129 "\n"
126 " action(\"run_this_guy_once\") {\n" 130 " action(\"run_this_guy_once\") {\n"
127 " script = \"doprocessing.py\"\n" 131 " script = \"doprocessing.py\"\n"
128 " sources = [ \"my_configuration.txt\" ]\n" 132 " sources = [ \"my_configuration.txt\" ]\n"
129 " outputs = [ \"$target_gen_dir/insightful_output.txt\" ]\n" 133 " outputs = [ \"$target_gen_dir/insightful_output.txt\" ]\n"
130 "\n" 134 "\n"
131 " # Our script imports this Python file so we want to rebuild if it\n" 135 " # Our script imports this Python file so we want to rebuild if it\n"
132 " # changes.\n" 136 " # changes.\n"
133 " source_prereqs = [ \"helper_library.py\" ]\n" 137 " inputs = [ \"helper_library.py\" ]\n"
134 "\n" 138 "\n"
135 " # Note that we have to manually pass the sources to our script if\n" 139 " # Note that we have to manually pass the sources to our script if\n"
136 " # the script needs them as inputs.\n" 140 " # the script needs them as inputs.\n"
137 " args = [ \"--out\", rebase_path(target_gen_dir, root_build_dir) ] +\n" 141 " args = [ \"--out\", rebase_path(target_gen_dir, root_build_dir) ] +\n"
138 " rebase_path(sources, root_build_dir)\n" 142 " rebase_path(sources, root_build_dir)\n"
139 " }\n"; 143 " }\n";
140 144
141 Value RunAction(Scope* scope, 145 Value RunAction(Scope* scope,
142 const FunctionCallNode* function, 146 const FunctionCallNode* function,
143 const std::vector<Value>& args, 147 const std::vector<Value>& args,
(...skipping 18 matching lines...) Expand all
162 "Inputs\n" 166 "Inputs\n"
163 "\n" 167 "\n"
164 " The script will be run once per file in the \"sources\" variable. The\n" 168 " The script will be run once per file in the \"sources\" variable. The\n"
165 " \"outputs\" variable should specify one or more files with a source\n" 169 " \"outputs\" variable should specify one or more files with a source\n"
166 " expansion pattern in it (see \"gn help source_expansion\"). The output\n" 170 " expansion pattern in it (see \"gn help source_expansion\"). The output\n"
167 " file(s) for each script invocation should be unique. Normally you\n" 171 " file(s) for each script invocation should be unique. Normally you\n"
168 " use \"{{source_name_part}}\" in each output file.\n" 172 " use \"{{source_name_part}}\" in each output file.\n"
169 "\n" 173 "\n"
170 " If your script takes additional data as input, such as a shared\n" 174 " If your script takes additional data as input, such as a shared\n"
171 " configuration file or a Python module it uses, those files should be\n" 175 " configuration file or a Python module it uses, those files should be\n"
172 " listed in the \"source_prereqs\" variable. These files are treated as\n" 176 " listed in the \"inputs\" variable. These files are treated as\n"
173 " dependencies of each script invocation.\n" 177 " dependencies of each script invocation.\n"
174 "\n" 178 "\n"
179 " You can dynamically write input dependencies (for incremental rebuilds\n"
180 " if an input file changes) by writing a depfile when the script is run\n"
181 " (see \"gn help depfile\"). This is more flexible than \"inputs\".\n"
182 "\n"
175 ACTION_DEPS 183 ACTION_DEPS
176 "\n" 184 "\n"
177 "Outputs\n" 185 "Outputs\n"
178 "\n" 186 "\n"
179 SCRIPT_EXECUTION_CONTEXT 187 SCRIPT_EXECUTION_CONTEXT
180 "\n" 188 "\n"
181 "File name handling\n" 189 "File name handling\n"
182 "\n" 190 "\n"
183 SCRIPT_EXECUTION_OUTPUTS 191 SCRIPT_EXECUTION_OUTPUTS
184 "\n" 192 "\n"
185 "Variables\n" 193 "Variables\n"
186 "\n" 194 "\n"
187 " args, data, datadeps, depfile, deps, outputs*, script*,\n" 195 " args, data, datadeps, depfile, deps, outputs*, script*,\n"
188 " source_prereqs, sources*\n" 196 " inputs, sources*\n"
189 " * = required\n" 197 " * = required\n"
190 "\n" 198 "\n"
191 "Example\n" 199 "Example\n"
192 "\n" 200 "\n"
193 " # Runs the script over each IDL file. The IDL script will generate\n" 201 " # Runs the script over each IDL file. The IDL script will generate\n"
194 " # both a .cc and a .h file for each input.\n" 202 " # both a .cc and a .h file for each input.\n"
195 " action_foreach(\"my_idl\") {\n" 203 " action_foreach(\"my_idl\") {\n"
196 " script = \"idl_processor.py\"\n" 204 " script = \"idl_processor.py\"\n"
197 " sources = [ \"foo.idl\", \"bar.idl\" ]\n" 205 " sources = [ \"foo.idl\", \"bar.idl\" ]\n"
198 "\n" 206 "\n"
199 " # Our script reads this file each time, so we need to list is as a\n" 207 " # Our script reads this file each time, so we need to list is as a\n"
200 " # dependency so we can rebuild if it changes.\n" 208 " # dependency so we can rebuild if it changes.\n"
201 " source_prereqs = [ \"my_configuration.txt\" ]\n" 209 " inputs = [ \"my_configuration.txt\" ]\n"
202 "\n" 210 "\n"
203 " # Transformation from source file name to output file names.\n" 211 " # Transformation from source file name to output file names.\n"
204 " outputs = [ \"$target_gen_dir/{{source_name_part}}.h\",\n" 212 " outputs = [ \"$target_gen_dir/{{source_name_part}}.h\",\n"
205 " \"$target_gen_dir/{{source_name_part}}.cc\" ]\n" 213 " \"$target_gen_dir/{{source_name_part}}.cc\" ]\n"
206 "\n" 214 "\n"
207 " # Note that since \"args\" is opaque to GN, if you specify paths\n" 215 " # Note that since \"args\" is opaque to GN, if you specify paths\n"
208 " # here, you will need to convert it to be relative to the build\n" 216 " # here, you will need to convert it to be relative to the build\n"
209 " # directory using \"rebase_path()\".\n" 217 " # directory using \"rebase_path()\".\n"
210 " args = [\n" 218 " args = [\n"
211 " \"{{source}}\",\n" 219 " \"{{source}}\",\n"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 Value RunTest(Scope* scope, 538 Value RunTest(Scope* scope,
531 const FunctionCallNode* function, 539 const FunctionCallNode* function,
532 const std::vector<Value>& args, 540 const std::vector<Value>& args,
533 BlockNode* block, 541 BlockNode* block,
534 Err* err) { 542 Err* err) {
535 return ExecuteGenericTarget(functions::kExecutable, scope, function, args, 543 return ExecuteGenericTarget(functions::kExecutable, scope, function, args,
536 block, err); 544 block, err);
537 } 545 }
538 546
539 } // namespace functions 547 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/ninja_action_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698