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.
5 # Runs the version processing script over the given template file to produce
6 # an output file. This is used for generating various forms of files that
7 # incorporate the product name and version.
9 # This template automatically includes VERSION, LASTCHANGE, and BRANDING. It
10 # automatically uses the template file .
11 # GYP parameterizes this template file but all current invocations use this
12 # same one. If in the future we need to set it, this should be added as an
15 # In GYP this is a rule that runs once per ".ver" file. In GN this just
16 # processes one file per invocation of the template so you may have to have
19 # You must specify either sources or a template_file, or both.
23 # List of file names to read. When converting a GYP target, this should
24 # list the 'source' (see above) as well as any extra_variable_files.
27 # File name of file to write. In GYP this is unspecified and it will
28 # make up a file name for you based on the input name, and tack on
29 # "_version.rc" to the end. But in GN you need to specify the full name.
31 # template_file (optional):
32 # Template file to use (not a list). Defaults to
33 # //chrome/app/chrome_version.rc.version if unspecified.
35 # extra_args (optional):
36 # Extra arguments to pass to version.py. Any "-f <filename>" args should
37 # use sources instead.
39 # visibility (optional)
42 # process_version("myversion") {
43 # sources = [ "myfile.h.in" ]
44 # output = "$target_gen_dir/myfile.h"
45 # extra_args = ["-e", "FOO=42"]
46 # extra_files = [ "foo/BRANDING" ]
48 template("process_version") {
49 assert(defined(invoker.sources) || defined(invoker.template_file),
50 "Either sources or template_file must be defined for $target_name")
51 assert(defined(invoker.output), "Output must be defined for $target_name")
54 if (defined(invoker.visibility)) {
55 visibility = invoker.visibility
57 script = "//build/util/version.py"
59 lastchange_path = "//build/util/LASTCHANGE"
60 version_path = "//chrome/VERSION"
61 if (is_chrome_branded) {
62 branding_path = "//chrome/app/theme/google_chrome/BRANDING"
64 branding_path = "//chrome/app/theme/chromium/BRANDING"
66 if (defined(invoker.template_file)) {
67 template_path = invoker.template_file
69 template_path = "//chrome/app/chrome_version.rc.version"
85 if (defined(invoker.sources)) {
86 inputs += invoker.sources
87 foreach(i, invoker.sources) {
90 rebase_path(i, root_build_dir),
97 rebase_path(version_path, root_build_dir),
99 rebase_path(branding_path, root_build_dir),
101 rebase_path(lastchange_path, root_build_dir),
103 if (defined(invoker.extra_args)) {
104 args += invoker.extra_args
107 rebase_path(template_path, root_build_dir),
108 rebase_path(invoker.output, root_build_dir),