OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import("//build/config/chrome_build.gni") | |
6 | |
7 # Runs the version processing script over the given template file to produce | 5 # Runs the version processing script over the given template file to produce |
8 # an output file. This is used for generating various forms of files that | 6 # an output file. This is used for generating various forms of files that |
9 # incorporate the product name and version. | 7 # incorporate the product name and version. |
10 # | 8 # |
11 # Unlike GYP, this will actually compile the resulting file, so you don't need | 9 # Unlike GYP, this will actually compile the resulting file, so you don't need |
12 # to add it separately to the sources, just depend on the target. | 10 # to add it separately to the sources, just depend on the target. |
13 # | 11 # |
14 # This template automatically includes VERSION, LASTCHANGE, and BRANDING. It | |
15 # automatically uses the template file . | |
16 # GYP parameterizes this template file but all current invocations use this | |
17 # same one. If in the future we need to set it, this should be added as an | |
18 # optional argument. | |
19 # | |
20 # In GYP this is a rule that runs once per ".ver" file. In GN this just | 12 # In GYP this is a rule that runs once per ".ver" file. In GN this just |
21 # processes one file per invocation of the template so you may have to have | 13 # processes one file per invocation of the template so you may have to have |
22 # multiple targets. | 14 # multiple targets. |
23 # | 15 # |
24 # Parameters: | 16 # Parameters: |
25 # sources (optional): | 17 # sources (optional): |
26 # List of file names to read. When converting a GYP target, this should | 18 # List of file names to read. When converting a GYP target, this should |
27 # list the 'source' (see above) as well as any extra_variable_files. | 19 # list the 'source' (see above) as well as any extra_variable_files. |
| 20 # The files will be passed to version.py in the order specified here. |
28 # | 21 # |
29 # output: | 22 # output: |
30 # File name of file to write. In GYP this is unspecified and it will | 23 # File name of file to write. In GYP this is unspecified and it will |
31 # make up a file name for you based on the input name, and tack on | 24 # make up a file name for you based on the input name, and tack on |
32 # "_version.rc" to the end. But in GN you need to specify the full name. | 25 # "_version.rc" to the end. But in GN you need to specify the full name. |
33 # | 26 # |
34 # template_file (optional): | 27 # template_file (optional): |
35 # Template file to use (not a list). Most Windows uses for generating | 28 # Template file to use (not a list). Most Windows uses for generating |
36 # resources will want to specify the chrome_version_rc_template defined | 29 # resources will want to use process_version_rc_template() instead. |
37 # below. | |
38 # | 30 # |
39 # extra_args (optional): | 31 # extra_args (optional): |
40 # Extra arguments to pass to version.py. Any "-f <filename>" args should | 32 # Extra arguments to pass to version.py. Any "-f <filename>" args should |
41 # use sources instead. | 33 # use sources instead. |
42 # | 34 # |
43 # process_only (optional, defaults to false) | 35 # process_only (optional, defaults to false) |
44 # Set to generate only one action that processes the version file and | 36 # Set to generate only one action that processes the version file and |
45 # doesn't attempt to link the result into a source set. This is for if | 37 # doesn't attempt to link the result into a source set. This is for if |
46 # you are processing the version as data only. | 38 # you are processing the version as data only. |
47 # | 39 # |
48 # visibility (optional) | 40 # visibility (optional) |
49 # | 41 # |
50 # Example: | 42 # Example: |
51 # process_version("myversion") { | 43 # process_version("myversion") { |
52 # sources = [ "myfile.h.in" ] | 44 # sources = [ |
| 45 # "//chrome/VERSION" |
| 46 # "myfile.h.in" |
| 47 # ] |
53 # output = "$target_gen_dir/myfile.h" | 48 # output = "$target_gen_dir/myfile.h" |
54 # extra_args = ["-e", "FOO=42"] | 49 # extra_args = [ "-e", "FOO=42" ] |
55 # extra_files = [ "foo/BRANDING" ] | |
56 # } | 50 # } |
57 template("process_version") { | 51 template("process_version") { |
58 assert(defined(invoker.output), "Output must be defined for $target_name") | 52 assert(defined(invoker.output), "Output must be defined for $target_name") |
59 | 53 |
60 process_only = defined(invoker.process_only) && invoker.process_only | 54 process_only = defined(invoker.process_only) && invoker.process_only |
61 | 55 |
62 if (process_only) { | 56 if (process_only) { |
63 action_name = target_name | 57 action_name = target_name |
64 } else { | 58 } else { |
65 action_name = target_name + "_action" | 59 action_name = target_name + "_action" |
66 source_set_name = target_name | 60 source_set_name = target_name |
67 } | 61 } |
68 | 62 |
69 action(action_name) { | 63 action(action_name) { |
70 script = "//build/util/version.py" | 64 script = "//build/util/version.py" |
71 | 65 |
72 lastchange_path = "//build/util/LASTCHANGE" | 66 inputs = [] |
73 version_path = "//chrome/VERSION" | |
74 if (is_chrome_branded) { | |
75 branding_path = "//chrome/app/theme/google_chrome/BRANDING" | |
76 } else { | |
77 branding_path = "//chrome/app/theme/chromium/BRANDING" | |
78 } | |
79 | |
80 inputs = [ | |
81 version_path, | |
82 lastchange_path, | |
83 branding_path, | |
84 ] | |
85 if (defined(invoker.inputs)) { | 67 if (defined(invoker.inputs)) { |
86 inputs += invoker.inputs | 68 inputs += invoker.inputs |
87 } | 69 } |
88 if (defined(invoker.template_file)) { | 70 if (defined(invoker.template_file)) { |
89 inputs += [ invoker.template_file ] | 71 inputs += [ invoker.template_file ] |
90 } | 72 } |
91 | 73 |
92 outputs = [ | 74 outputs = [ |
93 invoker.output, | 75 invoker.output, |
94 ] | 76 ] |
95 | 77 |
96 args = [] | 78 args = [] |
97 | 79 |
98 if (is_official_build) { | 80 if (is_official_build) { |
99 args += [ "--official" ] | 81 args += [ "--official" ] |
100 } | 82 } |
101 | 83 |
102 if (defined(invoker.sources)) { | 84 if (defined(invoker.sources)) { |
103 inputs += invoker.sources | 85 inputs += invoker.sources |
104 foreach(i, invoker.sources) { | 86 foreach(i, invoker.sources) { |
105 args += [ | 87 args += [ |
106 "-f", | 88 "-f", |
107 rebase_path(i, root_build_dir), | 89 rebase_path(i, root_build_dir), |
108 ] | 90 ] |
109 } | 91 } |
110 } | 92 } |
111 | 93 |
112 args += [ | |
113 "-f", | |
114 rebase_path(version_path, root_build_dir), | |
115 "-f", | |
116 rebase_path(branding_path, root_build_dir), | |
117 "-f", | |
118 rebase_path(lastchange_path, root_build_dir), | |
119 ] | |
120 if (defined(invoker.extra_args)) { | 94 if (defined(invoker.extra_args)) { |
121 args += invoker.extra_args | 95 args += invoker.extra_args |
122 } | 96 } |
123 args += [ | 97 args += [ |
124 "-o", | 98 "-o", |
125 rebase_path(invoker.output, root_build_dir), | 99 rebase_path(invoker.output, root_build_dir), |
126 ] | 100 ] |
127 if (defined(invoker.template_file)) { | 101 if (defined(invoker.template_file)) { |
128 args += [ rebase_path(invoker.template_file, root_build_dir) ] | 102 args += [ rebase_path(invoker.template_file, root_build_dir) ] |
129 } | 103 } |
(...skipping 12 matching lines...) Expand all Loading... |
142 if (!process_only) { | 116 if (!process_only) { |
143 source_set(source_set_name) { | 117 source_set(source_set_name) { |
144 forward_variables_from(invoker, [ "visibility" ]) | 118 forward_variables_from(invoker, [ "visibility" ]) |
145 sources = get_target_outputs(":$action_name") | 119 sources = get_target_outputs(":$action_name") |
146 public_deps = [ | 120 public_deps = [ |
147 ":$action_name", | 121 ":$action_name", |
148 ] | 122 ] |
149 } | 123 } |
150 } | 124 } |
151 } | 125 } |
152 | |
153 chrome_version_rc_template = "//chrome/app/chrome_version.rc.version" | |
OLD | NEW |