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

Side by Side Diff: chrome/version.gni

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

Powered by Google App Engine
This is Rietveld 408576698