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

Unified Diff: build/util/process_version.gni

Issue 2308313003: gn: Generalize process_version() and move it to build/util (Closed)
Patch Set: Fix chromecast 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/config/chrome_build.gni ('k') | chrome/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/util/process_version.gni
diff --git a/chrome/version.gni b/build/util/process_version.gni
similarity index 62%
rename from chrome/version.gni
rename to build/util/process_version.gni
index a29cb8d372ec3c18f2976864b4df4dcc3b20c8eb..8c6477d04c166446a3d7128dc4ff6eecf54b35b5 100644
--- a/chrome/version.gni
+++ b/build/util/process_version.gni
@@ -11,12 +11,6 @@ import("//build/config/chrome_build.gni")
# Unlike GYP, this will actually compile the resulting file, so you don't need
# to add it separately to the sources, just depend on the target.
#
-# This template automatically includes VERSION, LASTCHANGE, and BRANDING. It
-# automatically uses the template file .
-# GYP parameterizes this template file but all current invocations use this
-# same one. If in the future we need to set it, this should be added as an
-# optional argument.
-#
# In GYP this is a rule that runs once per ".ver" file. In GN this just
# processes one file per invocation of the template so you may have to have
# multiple targets.
@@ -25,6 +19,7 @@ import("//build/config/chrome_build.gni")
# sources (optional):
# List of file names to read. When converting a GYP target, this should
# list the 'source' (see above) as well as any extra_variable_files.
+# The files will be passed to version.py in the order specified here.
#
# output:
# File name of file to write. In GYP this is unspecified and it will
@@ -33,8 +28,7 @@ import("//build/config/chrome_build.gni")
#
# template_file (optional):
# Template file to use (not a list). Most Windows uses for generating
-# resources will want to specify the chrome_version_rc_template defined
-# below.
+# resources will want to use process_version_rc_template() instead.
#
# extra_args (optional):
# Extra arguments to pass to version.py. Any "-f <filename>" args should
@@ -49,10 +43,12 @@ import("//build/config/chrome_build.gni")
#
# Example:
# process_version("myversion") {
-# sources = [ "myfile.h.in" ]
+# sources = [
+# "//chrome/VERSION"
+# "myfile.h.in"
+# ]
# output = "$target_gen_dir/myfile.h"
-# extra_args = ["-e", "FOO=42"]
-# extra_files = [ "foo/BRANDING" ]
+# extra_args = [ "-e", "FOO=42" ]
# }
template("process_version") {
assert(defined(invoker.output), "Output must be defined for $target_name")
@@ -69,19 +65,7 @@ template("process_version") {
action(action_name) {
script = "//build/util/version.py"
- lastchange_path = "//build/util/LASTCHANGE"
- version_path = "//chrome/VERSION"
- if (is_chrome_branded) {
- branding_path = "//chrome/app/theme/google_chrome/BRANDING"
- } else {
- branding_path = "//chrome/app/theme/chromium/BRANDING"
- }
-
- inputs = [
- version_path,
- lastchange_path,
- branding_path,
- ]
+ inputs = []
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}
@@ -109,14 +93,6 @@ template("process_version") {
}
}
- args += [
- "-f",
- rebase_path(version_path, root_build_dir),
- "-f",
- rebase_path(branding_path, root_build_dir),
- "-f",
- rebase_path(lastchange_path, root_build_dir),
- ]
if (defined(invoker.extra_args)) {
args += invoker.extra_args
}
@@ -150,4 +126,58 @@ template("process_version") {
}
}
-chrome_version_rc_template = "//chrome/app/chrome_version.rc.version"
+# This is a wrapper around process_version() that eases the task of processing
+# a .rc.version file (used especially on Windows).
+#
+# This template automatically includes VERSION, LASTCHANGE and BRANDING, and
+# any additional source files are passed after those (so their values can
+# override the ones specified by those 3 files).
+#
+# Parameters:
+# sources (optional):
+# List of files with value definitions that will be passed in addition to
+# VERSION, LASTCHANGE and BRANDING.
+#
+# template_file (optional):
+# Template file to use (not a list). If not specified, a default value,
+# //chrome/app/chrome_version.rc.version will be used.
+#
+# This template forwards all other parameters directly to process_version().
+#
+# Examples:
+# process_version_rc_template("my_exe_version") {
+# output = "$target_gen_dir/my_exe_version.rc"
+# sources = [ "frob/my_exe.ver" ]
+# extra_args = [ "-e", "FOO=42" ]
+# }
+#
+# process_version_rc_template("my_dll_version") {
+# output = "$target_gen_dir/my_dll_version.rc"
+# template_file = [ "//foo/bar/my_dll_version.rc.version" ]
+# }
+template("process_version_rc_template") {
+ if (defined(invoker.template_file)) {
+ _template_file = invoker.template_file
+ } else {
+ _template_file = "//chrome/app/chrome_version.rc.version"
brettw 2016/09/06 22:52:31 Since this depends on files from //chrome, it shou
+ }
+ _sources = [
+ "//build/util/LASTCHANGE",
+ "//chrome/VERSION",
+ branding_file_path,
+ ]
+ if (defined(invoker.sources)) {
+ _sources += invoker.sources
+ }
+
+ process_version(target_name) {
+ template_file = _template_file
+ sources = _sources
+ forward_variables_from(invoker,
+ "*",
+ [
+ "sources",
+ "template_file",
+ ])
+ }
+}
« no previous file with comments | « build/config/chrome_build.gni ('k') | chrome/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698