Show a margin for long ash chromecast tray strings. Also trim them if necessary.
[chromium-blink-merge.git] / chrome / version.gni
blob453a8d8abeb79696a6c262d7d4f4cf0ae2b87286
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 import("//build/config/chrome_build.gni")
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.
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.
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.
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.
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.
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.
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.
39 #   extra_args (optional):
40 #     Extra arguments to pass to version.py. Any "-f <filename>" args should
41 #     use sources instead.
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.
48 #   visibility (optional)
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")
60   process_only = defined(invoker.process_only) && invoker.process_only
62   if (process_only) {
63     action_name = target_name
64   } else {
65     action_name = target_name + "_action"
66     source_set_name = target_name
67   }
69   action(action_name) {
70     script = "//build/util/version.py"
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     }
80     inputs = [
81       version_path,
82       lastchange_path,
83       branding_path,
84     ]
85     if (defined(invoker.template_file)) {
86       inputs += [ invoker.template_file ]
87     }
89     outputs = [
90       invoker.output,
91     ]
93     args = []
95     if (defined(invoker.sources)) {
96       inputs += invoker.sources
97       foreach(i, invoker.sources) {
98         args += [
99           "-f",
100           rebase_path(i, root_build_dir),
101         ]
102       }
103     }
105     args += [
106       "-f",
107       rebase_path(version_path, root_build_dir),
108       "-f",
109       rebase_path(branding_path, root_build_dir),
110       "-f",
111       rebase_path(lastchange_path, root_build_dir),
112     ]
113     if (defined(invoker.extra_args)) {
114       args += invoker.extra_args
115     }
116     args += [
117       "-o",
118       rebase_path(invoker.output, root_build_dir),
119     ]
120     if (defined(invoker.template_file)) {
121       args += [ rebase_path(invoker.template_file, root_build_dir) ]
122     }
124     if (process_only) {
125       # When processing only, visibility gets applied to this target.
126       forward_variables_from(invoker, [ "visibility" ])
127     } else {
128       # When linking the result, only the source set can depend on the action.
129       visibility = [ ":$source_set_name" ]
130     }
131   }
133   if (!process_only) {
134     source_set(source_set_name) {
135       forward_variables_from(invoker, [ "visibility" ])
136       sources = get_target_outputs(":$action_name")
137       public_deps = [
138         ":$action_name",
139       ]
140     }
141   }
144 chrome_version_rc_template = "//chrome/app/chrome_version.rc.version"