OLD | NEW |
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") | |
6 | |
7 # Runs the version processing script over the given template file to produce | 5 # 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 | 6 # an output file. This is used for generating various forms of files that |
9 # incorporate the product name and version. | 7 # incorporate the product name and version. |
10 # | 8 # |
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. | |
13 # | |
14 # This template automatically includes VERSION, LASTCHANGE, and BRANDING. It | 9 # This template automatically includes VERSION, LASTCHANGE, and BRANDING. It |
15 # automatically uses the template file . | 10 # automatically uses the template file . |
16 # GYP parameterizes this template file but all current invocations use this | 11 # 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 | 12 # same one. If in the future we need to set it, this should be added as an |
18 # optional argument. | 13 # optional argument. |
19 # | 14 # |
20 # In GYP this is a rule that runs once per ".ver" file. In GN this just | 15 # 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 | 16 # processes one file per invocation of the template so you may have to have |
22 # multiple targets. | 17 # multiple targets. |
23 # | 18 # |
(...skipping 24 matching lines...) Expand all Loading... |
48 # sources = [ "myfile.h.in" ] | 43 # sources = [ "myfile.h.in" ] |
49 # output = "$target_gen_dir/myfile.h" | 44 # output = "$target_gen_dir/myfile.h" |
50 # extra_args = ["-e", "FOO=42"] | 45 # extra_args = ["-e", "FOO=42"] |
51 # extra_files = [ "foo/BRANDING" ] | 46 # extra_files = [ "foo/BRANDING" ] |
52 # } | 47 # } |
53 template("process_version") { | 48 template("process_version") { |
54 assert(defined(invoker.sources) || defined(invoker.template_file), | 49 assert(defined(invoker.sources) || defined(invoker.template_file), |
55 "Either sources or template_file must be defined for $target_name") | 50 "Either sources or template_file must be defined for $target_name") |
56 assert(defined(invoker.output), "Output must be defined for $target_name") | 51 assert(defined(invoker.output), "Output must be defined for $target_name") |
57 | 52 |
58 action_name = target_name + "_action" | 53 action(target_name) { |
59 source_set_name = target_name | 54 if (defined(invoker.visibility)) { |
60 | 55 visibility = invoker.visibility |
61 action(action_name) { | 56 } |
62 visibility = [ ":$source_set_name" ] | |
63 script = "//build/util/version.py" | 57 script = "//build/util/version.py" |
64 | 58 |
65 lastchange_path = "//build/util/LASTCHANGE" | 59 lastchange_path = "//build/util/LASTCHANGE" |
66 version_path = "//chrome/VERSION" | 60 version_path = "//chrome/VERSION" |
67 if (is_chrome_branded) { | 61 if (is_chrome_branded) { |
68 branding_path = "//chrome/app/theme/google_chrome/BRANDING" | 62 branding_path = "//chrome/app/theme/google_chrome/BRANDING" |
69 } else { | 63 } else { |
70 branding_path = "//chrome/app/theme/chromium/BRANDING" | 64 branding_path = "//chrome/app/theme/chromium/BRANDING" |
71 } | 65 } |
72 if (defined(invoker.template_file)) { | 66 if (defined(invoker.template_file)) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 rebase_path(lastchange_path, root_build_dir), | 101 rebase_path(lastchange_path, root_build_dir), |
108 ] | 102 ] |
109 if (defined(invoker.extra_args)) { | 103 if (defined(invoker.extra_args)) { |
110 args += invoker.extra_args | 104 args += invoker.extra_args |
111 } | 105 } |
112 args += [ | 106 args += [ |
113 rebase_path(template_path, root_build_dir), | 107 rebase_path(template_path, root_build_dir), |
114 rebase_path(invoker.output, root_build_dir), | 108 rebase_path(invoker.output, root_build_dir), |
115 ] | 109 ] |
116 } | 110 } |
117 | |
118 source_set(source_set_name) { | |
119 if (defined(invoker.visibility)) { | |
120 visibility = invoker.visibility | |
121 } | |
122 sources = get_target_outputs(":$action_name") | |
123 deps = [ | |
124 ":$action_name", | |
125 ] | |
126 } | |
127 } | 111 } |
OLD | NEW |