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

Unified Diff: tools/gn/function_template.cc

Issue 270613006: GN documentation updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/function_process_file_template.cc ('k') | tools/gn/functions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/function_template.cc
diff --git a/tools/gn/function_template.cc b/tools/gn/function_template.cc
index 368dc9712ffa1b0c2d57e213a25983ae677bb472..7af688e75b2344c3b1039d231e13c9f2249169c1 100644
--- a/tools/gn/function_template.cc
+++ b/tools/gn/function_template.cc
@@ -83,18 +83,17 @@ const char kTemplate_Help[] =
" assert(defined(invoker.sources),\n"
" \"Need sources in $target_name listing the idl files.\")\n"
"\n"
- " # Define a variable containing a source expansion\n"
- " # (see \"gn help source_expansion\") that maps input files to\n"
- " # output files. It is used in both targets below.\n"
- " filter = [ \"$target_gen_dir/{{source_name_part}}.cc\",\n"
- " \"$target_gen_dir/{{source_name_part}}.h\" ]\n"
+ " # Name of the intermediate target that does the code gen. This must\n"
+ " # incorporate the target name so it's unique across template\n"
+ " # instantiations.\n"
+ " code_gen_target_name = target_name + \"_code_gen\"\n"
"\n"
" # Intermediate target to convert IDL to C source. Note that the name\n"
" # is based on the name the invoker of the template specified. This\n"
" # way, each time the template is invoked we get a unique\n"
" # intermediate action name (since all target names are in the global\n"
" # scope).\n"
- " action_foreach(\"${target_name}_code_gen\") {\n"
+ " action_foreach(code_gen_target_name) {\n"
" # Access the scope defined by the invoker via the implicit\n"
" # \"invoker\" variable.\n"
" sources = invoker.sources\n"
@@ -106,20 +105,24 @@ const char kTemplate_Help[] =
" # to reference a script relative to the template file, we'll need\n"
" # to use an absolute path instead.\n"
" script = \"//tools/idl/idl_code_generator.py\"\n"
- " outputs = filter # Variable from above.\n"
+ "\n"
+ " # Tell GN how to expand output names given the sources.\n"
+ " # See \"gn help source_expansion\" for more.\n"
+ " outputs = [ \"$target_gen_dir/{{source_name_part}}.cc\",\n"
+ " \"$target_gen_dir/{{source_name_part}}.h\" ]\n"
" }\n"
"\n"
" # Name the source set the same as the template invocation so\n"
" # instancing this template produces something that other targets\n"
" # can link to in their deps.\n"
" source_set(target_name) {\n"
- " # Generates the list of sources.\n"
- " # See \"gn help process_file_template\"\n"
- " sources = process_file_template(invoker.sources, filter)\n"
+ " # Generates the list of sources, we get these from the\n"
+ " # action_foreach above.\n"
+ " sources = get_target_outputs(\":$code_gen_target_name\")\n"
"\n"
" # This target depends on the files produced by the above code gen\n"
" # target.\n"
- " deps = [ \":${target_name}_code_gen\" ]\n"
+ " deps = [ \":$code_gen_target_name\" ]\n"
" }\n"
" }\n"
"\n"
« no previous file with comments | « tools/gn/function_process_file_template.cc ('k') | tools/gn/functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698