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