| 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") | 5 import("//build/config/chrome_build.gni") |
| 6 | 6 |
| 7 # 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 |
| 8 # 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 |
| 9 # incorporate the product name and version. | 9 # incorporate the product name and version. |
| 10 # | 10 # |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 # list the 'source' (see above) as well as any extra_variable_files. | 29 # list the 'source' (see above) as well as any extra_variable_files. |
| 30 # | 30 # |
| 31 # output: | 31 # output: |
| 32 # File name of file to write. In GYP this is unspecified and it will | 32 # File name of file to write. In GYP this is unspecified and it will |
| 33 # make up a file name for you based on the input name, and tack on | 33 # make up a file name for you based on the input name, and tack on |
| 34 # "_version.rc" to the end. But in GN you need to specify the full name. | 34 # "_version.rc" to the end. But in GN you need to specify the full name. |
| 35 # | 35 # |
| 36 # template_file (optional): | 36 # template_file (optional): |
| 37 # Template file to use (not a list). Defaults to | 37 # Template file to use (not a list). Defaults to |
| 38 # //chrome/app/chrome_version.rc.version if unspecified. | 38 # //chrome/app/chrome_version.rc.version if unspecified. |
| 39 # TODO(brettw) remove this default behavior and specify it every time. |
| 39 # | 40 # |
| 40 # extra_args (optional): | 41 # extra_args (optional): |
| 41 # Extra arguments to pass to version.py. Any "-f <filename>" args should | 42 # Extra arguments to pass to version.py. Any "-f <filename>" args should |
| 42 # use sources instead. | 43 # use sources instead. |
| 43 # | 44 # |
| 45 # process_only (optional, defaults to false) |
| 46 # Set to generate only one action that processes the version file and |
| 47 # doesn't attempt to link the result into a source set. This is for if |
| 48 # you are processing the version as data only. |
| 49 # |
| 44 # visibility (optional) | 50 # visibility (optional) |
| 45 # | 51 # |
| 46 # Example: | 52 # Example: |
| 47 # process_version("myversion") { | 53 # process_version("myversion") { |
| 48 # sources = [ "myfile.h.in" ] | 54 # sources = [ "myfile.h.in" ] |
| 49 # output = "$target_gen_dir/myfile.h" | 55 # output = "$target_gen_dir/myfile.h" |
| 50 # extra_args = ["-e", "FOO=42"] | 56 # extra_args = ["-e", "FOO=42"] |
| 51 # extra_files = [ "foo/BRANDING" ] | 57 # extra_files = [ "foo/BRANDING" ] |
| 52 # } | 58 # } |
| 53 template("process_version") { | 59 template("process_version") { |
| 54 assert(defined(invoker.sources) || defined(invoker.template_file), | 60 assert(defined(invoker.sources) || defined(invoker.template_file), |
| 55 "Either sources or template_file must be defined for $target_name") | 61 "Either sources or template_file must be defined for $target_name") |
| 56 assert(defined(invoker.output), "Output must be defined for $target_name") | 62 assert(defined(invoker.output), "Output must be defined for $target_name") |
| 57 | 63 |
| 58 action_name = target_name + "_action" | 64 process_only = defined(invoker.process_only) && invoker.process_only |
| 59 source_set_name = target_name | 65 |
| 66 if (process_only) { |
| 67 action_name = target_name |
| 68 } else { |
| 69 action_name = target_name + "_action" |
| 70 source_set_name = target_name |
| 71 } |
| 60 | 72 |
| 61 action(action_name) { | 73 action(action_name) { |
| 62 visibility = [ ":$source_set_name" ] | |
| 63 script = "//build/util/version.py" | 74 script = "//build/util/version.py" |
| 64 | 75 |
| 65 lastchange_path = "//build/util/LASTCHANGE" | 76 lastchange_path = "//build/util/LASTCHANGE" |
| 66 version_path = "//chrome/VERSION" | 77 version_path = "//chrome/VERSION" |
| 67 if (is_chrome_branded) { | 78 if (is_chrome_branded) { |
| 68 branding_path = "//chrome/app/theme/google_chrome/BRANDING" | 79 branding_path = "//chrome/app/theme/google_chrome/BRANDING" |
| 69 } else { | 80 } else { |
| 70 branding_path = "//chrome/app/theme/chromium/BRANDING" | 81 branding_path = "//chrome/app/theme/chromium/BRANDING" |
| 71 } | 82 } |
| 72 if (defined(invoker.template_file)) { | 83 if (defined(invoker.template_file)) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 "-f", | 117 "-f", |
| 107 rebase_path(lastchange_path, root_build_dir), | 118 rebase_path(lastchange_path, root_build_dir), |
| 108 ] | 119 ] |
| 109 if (defined(invoker.extra_args)) { | 120 if (defined(invoker.extra_args)) { |
| 110 args += invoker.extra_args | 121 args += invoker.extra_args |
| 111 } | 122 } |
| 112 args += [ | 123 args += [ |
| 113 rebase_path(template_path, root_build_dir), | 124 rebase_path(template_path, root_build_dir), |
| 114 rebase_path(invoker.output, root_build_dir), | 125 rebase_path(invoker.output, root_build_dir), |
| 115 ] | 126 ] |
| 127 |
| 128 if (process_only) { |
| 129 # When processing only, visibility gets applied to this target. |
| 130 if (defined(invoker.visibility)) { |
| 131 visibility = invoker.visibility |
| 132 } |
| 133 } else { |
| 134 # When linking the result, only the source set can depend on the action. |
| 135 visibility = [ ":$source_set_name" ] |
| 136 } |
| 116 } | 137 } |
| 117 | 138 |
| 118 source_set(source_set_name) { | 139 if (!process_only) { |
| 119 if (defined(invoker.visibility)) { | 140 source_set(source_set_name) { |
| 120 visibility = invoker.visibility | 141 if (defined(invoker.visibility)) { |
| 142 visibility = invoker.visibility |
| 143 } |
| 144 sources = get_target_outputs(":$action_name") |
| 145 public_deps = [ |
| 146 ":$action_name", |
| 147 ] |
| 121 } | 148 } |
| 122 sources = get_target_outputs(":$action_name") | |
| 123 public_deps = [ | |
| 124 ":$action_name", | |
| 125 ] | |
| 126 } | 149 } |
| 127 } | 150 } |
| OLD | NEW |