Unbreak and re-enable PolicyPrefIndicatorTest on official builds
[chromium-blink-merge.git] / chrome / version.gni
blobb956e9c38e5084fae3b4569c86d3ba88d36412fb
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
13 # optional argument.
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
17 # multiple targets.
19 # You must specify either sources or a template_file, or both.
21 # Parameters:
22 #   sources (optional):
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.
26 #   output:
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)
41 # Example:
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" ]
47 #   }
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")
53   action(target_name) {
54     if (defined(invoker.visibility)) {
55       visibility = invoker.visibility
56     }
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"
63     } else {
64       branding_path = "//chrome/app/theme/chromium/BRANDING"
65     }
66     if (defined(invoker.template_file)) {
67       template_path = invoker.template_file
68     } else {
69       template_path = "//chrome/app/chrome_version.rc.version"
70     }
72     inputs = [
73       version_path,
74       lastchange_path,
75       branding_path,
76       template_path,
77     ]
79     outputs = [
80       invoker.output,
81     ]
83     args = []
85     if (defined(invoker.sources)) {
86       inputs += invoker.sources
87       foreach(i, invoker.sources) {
88         args += [
89           "-f",
90           rebase_path(i, root_build_dir),
91         ]
92       }
93     }
95     args += [
96       "-f",
97       rebase_path(version_path, root_build_dir),
98       "-f",
99       rebase_path(branding_path, root_build_dir),
100       "-f",
101       rebase_path(lastchange_path, root_build_dir),
102     ]
103     if (defined(invoker.extra_args)) {
104       args += invoker.extra_args
105     }
106     args += [
107       rebase_path(template_path, root_build_dir),
108       rebase_path(invoker.output, root_build_dir),
109     ]
110   }