OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 # Declare a target for processing a template. | 5 # Declare a target for processing a template. |
6 # | 6 # |
7 # Variables | 7 # Variables |
8 # input: The template file to be processed. | 8 # input: The template file to be processed. |
9 # output: Where to save the result. | 9 # output: Where to save the result. |
10 # variables: A list of variables to make available to the template | 10 # variables: A list of variables to make available to the template |
11 # processing environment, e.g. ["name=foo", "color=red"]. | 11 # processing environment, e.g. ["name=foo", "color=red"]. |
12 # | 12 # |
13 # Example | 13 # Example |
14 # file_template("chrome_shell_manifest") { | 14 # file_template("chrome_shell_manifest") { |
15 # input = "shell/java/AndroidManifest.xml" | 15 # input = "shell/java/AndroidManifest.xml" |
16 # output = "$target_gen_dir/AndroidManifest.xml" | 16 # output = "$target_gen_dir/AndroidManifest.xml" |
17 # variables = "app_name=chrome_shell app_version=1" | 17 # variables = "app_name=chrome_shell app_version=1" |
18 # } | 18 # } |
19 template("file_template") { | 19 template("file_template") { |
20 set_sources_assignment_filter([]) | 20 set_sources_assignment_filter([]) |
21 | 21 |
22 if (defined(invoker.testonly)) { | 22 if (defined(invoker.testonly)) { |
23 testonly = invoker.testonly | 23 testonly = invoker.testonly |
24 } | 24 } |
25 | 25 |
26 assert(defined(invoker.input), | 26 assert(defined(invoker.input), "The input file must be specified") |
27 "The input file must be specified") | 27 assert(defined(invoker.output), "The output file must be specified") |
28 assert(defined(invoker.output), | |
29 "The output file must be specified") | |
30 assert(defined(invoker.variables), | 28 assert(defined(invoker.variables), |
31 "The variable used for substitution in templates must be specified") | 29 "The variable used for substitution in templates must be specified") |
32 | 30 |
33 variables = invoker.variables | 31 variables = invoker.variables |
34 | 32 |
35 action(target_name) { | 33 action(target_name) { |
36 if(defined(invoker.visibility)) { | 34 if (defined(invoker.visibility)) { |
37 visibility = invoker.visibility | 35 visibility = invoker.visibility |
38 } | 36 } |
39 | 37 |
40 script = "//build/android/gyp/jinja_template.py" | 38 script = "//build/android/gyp/jinja_template.py" |
41 depfile = "$target_gen_dir/$target_name.d" | 39 depfile = "$target_gen_dir/$target_name.d" |
42 | 40 |
43 sources = [ invoker.input ] | 41 sources = [ |
44 outputs = [ invoker.output, depfile ] | 42 invoker.input, |
| 43 ] |
| 44 outputs = [ |
| 45 invoker.output, |
| 46 depfile, |
| 47 ] |
45 | 48 |
46 args = [ | 49 args = [ |
47 "--inputs", | 50 "--inputs", |
48 rebase_path(invoker.input, root_build_dir), | 51 rebase_path(invoker.input, root_build_dir), |
49 "--output", | 52 "--output", |
50 rebase_path(invoker.output, root_build_dir), | 53 rebase_path(invoker.output, root_build_dir), |
51 "--depfile", | 54 "--depfile", |
52 rebase_path(depfile, root_build_dir), | 55 rebase_path(depfile, root_build_dir), |
53 "--variables=${variables}" | 56 "--variables=${variables}", |
54 ] | 57 ] |
55 } | 58 } |
56 } | 59 } |
OLD | NEW |