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