Chromium Code Reviews| 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 # 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 |
| 6 # 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 |
| 7 # incorporate the product name and version. | 7 # incorporate the product name and version. |
| 8 # | 8 # |
| 9 # This template automatically includes VERSION, LASTCHANGE, and BRANDING, | 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. | |
| 14 # | |
| 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. | |
| 10 # | 18 # |
| 11 # Parameters: | 19 # Parameters: |
| 12 # source: | 20 # sources (optional): |
| 13 # File name of source template file to read. | 21 # List of file names to read. In GYP, this should list the 'source' (see |
| 22 # above) as well as any extra_variable_files. | |
| 14 # | 23 # |
| 15 # output: | 24 # output: |
| 16 # File name of file to write. | 25 # File name of file to write. In GYP this is unspecified and it will |
| 26 # make up a file name for you based on the input name, and tack on | |
| 27 # "_version.rc" to the end. But in GN you need to specify the full name. | |
| 28 # | |
| 29 # template_file (optional): | |
| 30 # Template file to use (not a list). Defaults to | |
| 31 # //chrome/app/chrome_version.rc.version if unspecified. | |
| 17 # | 32 # |
| 18 # extra_args (optional): | 33 # extra_args (optional): |
| 19 # Extra arguments to pass to version.py. | 34 # Extra arguments to pass to version.py. Any "-f <filename>" args should |
| 35 # use sources instead. | |
| 20 # | 36 # |
| 21 # visibility (optional) | 37 # visibility (optional) |
| 22 # | 38 # |
| 23 # Example: | 39 # Example: |
| 24 # process_version("myversion") { | 40 # process_version("myversion") { |
| 25 # source = "myfile.h.in" | 41 # sources = [ ""myfile.h.in" |
|
Dirk Pranke
2015/02/25 00:23:19
Nit: you have two leading quotes and a missing end
| |
| 26 # output = "$target_gen_dir/myfile.h" | 42 # output = "$target_gen_dir/myfile.h" |
| 27 # extra_args = ["-e", "FOO=42"] | 43 # extra_args = ["-e", "FOO=42"] |
| 44 # extra_files = [ "foo/BRANDING" ] | |
| 28 # } | 45 # } |
| 29 template("process_version") { | 46 template("process_version") { |
| 30 assert(defined(invoker.source), "Source must be defined for $target_name") | 47 assert(defined(invoker.sources) || defined(invoker.template_file), |
| 48 "sources or template_file must be defined for $target_name") | |
|
Dirk Pranke
2015/02/25 00:23:19
It's not actually clear in the docs above that you
| |
| 31 assert(defined(invoker.output), "Output must be defined for $target_name") | 49 assert(defined(invoker.output), "Output must be defined for $target_name") |
| 32 | 50 |
| 33 action(target_name) { | 51 action(target_name) { |
| 34 if (defined(invoker.visibility)) { | 52 if (defined(invoker.visibility)) { |
| 35 visibility = invoker.visibility | 53 visibility = invoker.visibility |
| 36 } | 54 } |
| 37 script = "//build/util/version.py" | 55 script = "//build/util/version.py" |
| 38 | 56 |
| 39 lastchange_path = "//build/util/LASTCHANGE" | 57 lastchange_path = "//build/util/LASTCHANGE" |
| 40 version_path = "//chrome/VERSION" | 58 version_path = "//chrome/VERSION" |
| 41 if (is_chrome_branded) { | 59 if (is_chrome_branded) { |
| 42 branding_path = "//chrome/app/theme/google_chrome/BRANDING" | 60 branding_path = "//chrome/app/theme/google_chrome/BRANDING" |
| 43 } else { | 61 } else { |
| 44 branding_path = "//chrome/app/theme/chromium/BRANDING" | 62 branding_path = "//chrome/app/theme/chromium/BRANDING" |
| 45 } | 63 } |
| 64 if (defined(invoker.template_file)) { | |
| 65 template_path = invoker.template_file | |
| 66 } else { | |
| 67 template_path = "//chrome/app/chrome_version.rc.version" | |
| 68 } | |
| 46 | 69 |
| 47 inputs = [ | 70 inputs = [ |
| 48 version_path, | 71 version_path, |
| 49 invoker.source, | |
| 50 lastchange_path, | 72 lastchange_path, |
| 51 branding_path, | 73 branding_path, |
| 74 template_path | |
|
Dirk Pranke
2015/02/25 00:23:19
nit: should there be a trailing comma?
| |
| 52 ] | 75 ] |
| 53 | 76 |
| 54 outputs = [ | 77 outputs = [ |
| 55 invoker.output, | 78 invoker.output, |
| 56 ] | 79 ] |
| 57 | 80 |
| 58 args = [ | 81 args = [] |
| 82 | |
| 83 if (defined(invoker.sources)) { | |
| 84 inputs += invoker.sources | |
| 85 foreach(i, invoker.sources) { | |
| 86 args += [ "-f", rebase_path(i, root_build_dir) ] | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 args += [ | |
| 59 "-f", | 91 "-f", |
| 60 rebase_path(version_path, root_build_dir), | 92 rebase_path(version_path, root_build_dir), |
| 61 "-f", | 93 "-f", |
| 62 rebase_path(branding_path, root_build_dir), | 94 rebase_path(branding_path, root_build_dir), |
| 63 "-f", | 95 "-f", |
| 64 rebase_path(lastchange_path, root_build_dir), | 96 rebase_path(lastchange_path, root_build_dir), |
| 65 "-i", | 97 rebase_path(template_path, root_build_dir), |
| 66 rebase_path(invoker.source, root_build_dir), | |
| 67 "-o", | |
| 68 rebase_path(invoker.output, root_build_dir), | 98 rebase_path(invoker.output, root_build_dir), |
| 69 ] | 99 ] |
| 70 | 100 |
| 71 if (defined(invoker.extra_args)) { | 101 if (defined(invoker.extra_args)) { |
| 72 args += invoker.extra_args | 102 args += invoker.extra_args |
| 73 } | 103 } |
| 74 } | 104 } |
| 75 } | 105 } |
| OLD | NEW |