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

Side by Side Diff: chrome/version.gni

Issue 2308313003: gn: Generalize process_version() and move it to build/util (Closed)
Patch Set: Move branding_file_path to chrome/process_version_rc_template.gni Created 4 years, 3 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
« no previous file with comments | « chrome/process_version_rc_template.gni ('k') | chrome_elf/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import("//build/config/chrome_build.gni")
6
7 # 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
9 # incorporate the product name and version.
10 #
11 # 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.
13 #
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
21 # processes one file per invocation of the template so you may have to have
22 # multiple targets.
23 #
24 # Parameters:
25 # sources (optional):
26 # 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.
28 #
29 # output:
30 # 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
32 # "_version.rc" to the end. But in GN you need to specify the full name.
33 #
34 # template_file (optional):
35 # Template file to use (not a list). Most Windows uses for generating
36 # resources will want to specify the chrome_version_rc_template defined
37 # below.
38 #
39 # extra_args (optional):
40 # Extra arguments to pass to version.py. Any "-f <filename>" args should
41 # use sources instead.
42 #
43 # process_only (optional, defaults to false)
44 # 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
46 # you are processing the version as data only.
47 #
48 # visibility (optional)
49 #
50 # Example:
51 # process_version("myversion") {
52 # sources = [ "myfile.h.in" ]
53 # output = "$target_gen_dir/myfile.h"
54 # extra_args = ["-e", "FOO=42"]
55 # extra_files = [ "foo/BRANDING" ]
56 # }
57 template("process_version") {
58 assert(defined(invoker.output), "Output must be defined for $target_name")
59
60 process_only = defined(invoker.process_only) && invoker.process_only
61
62 if (process_only) {
63 action_name = target_name
64 } else {
65 action_name = target_name + "_action"
66 source_set_name = target_name
67 }
68
69 action(action_name) {
70 script = "//build/util/version.py"
71
72 lastchange_path = "//build/util/LASTCHANGE"
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)) {
86 inputs += invoker.inputs
87 }
88 if (defined(invoker.template_file)) {
89 inputs += [ invoker.template_file ]
90 }
91
92 outputs = [
93 invoker.output,
94 ]
95
96 args = []
97
98 if (is_official_build) {
99 args += [ "--official" ]
100 }
101
102 if (defined(invoker.sources)) {
103 inputs += invoker.sources
104 foreach(i, invoker.sources) {
105 args += [
106 "-f",
107 rebase_path(i, root_build_dir),
108 ]
109 }
110 }
111
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)) {
121 args += invoker.extra_args
122 }
123 args += [
124 "-o",
125 rebase_path(invoker.output, root_build_dir),
126 ]
127 if (defined(invoker.template_file)) {
128 args += [ rebase_path(invoker.template_file, root_build_dir) ]
129 }
130
131 forward_variables_from(invoker, [ "deps" ])
132
133 if (process_only) {
134 # When processing only, visibility gets applied to this target.
135 forward_variables_from(invoker, [ "visibility" ])
136 } else {
137 # When linking the result, only the source set can depend on the action.
138 visibility = [ ":$source_set_name" ]
139 }
140 }
141
142 if (!process_only) {
143 source_set(source_set_name) {
144 forward_variables_from(invoker, [ "visibility" ])
145 sources = get_target_outputs(":$action_name")
146 public_deps = [
147 ":$action_name",
148 ]
149 }
150 }
151 }
152
153 chrome_version_rc_template = "//chrome/app/chrome_version.rc.version"
OLDNEW
« no previous file with comments | « chrome/process_version_rc_template.gni ('k') | chrome_elf/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698