summaryrefslogtreecommitdiffstats
path: root/chrome/version.gni
blob: cc8d96a4c665d7f99bd2d8dc4f262dfe80a862b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Runs the version processing script over the given template file to produce
# an output file. This is used for generating various forms of files that
# incorporate the product name and version.
#
# This template automatically includes VERSION, LASTCHANGE, and BRANDING,
#
# Parameters:
#   source:
#     File name of source template file to read.
#
#   output:
#     File name of file to write.
#
#   extra_args (optional):
#     Extra arguments to pass to version.py.
#
#   visibility (optional)
#
# Example:
#   process_version("myversion") {
#     source = "myfile.h.in"
#     output = "$target_gen_dir/myfile.h"
#     extra_args = ["-e", "FOO=42"]
#   }
template("process_version") {
  assert(defined(invoker.source), "Source must be defined for $target_name")
  assert(defined(invoker.output), "Output must be defined for $target_name")

  action(target_name) {
    if (defined(invoker.visibility)) {
      visibility = invoker.visibility
    }
    script = "//build/util/version.py"

    lastchange_path = "//build/util/LASTCHANGE"
    version_path = "//chrome/VERSION"
    if (is_chrome_branded) {
      branding_path = "//chrome/app/theme/google_chrome/BRANDING"
    } else {
      branding_path = "//chrome/app/theme/chromium/BRANDING"
    }

    inputs = [
      version_path,
      invoker.source,
      lastchange_path,
      branding_path,
    ]

    outputs = [
      invoker.output,
    ]

    args = [
      "-f",
      rebase_path(version_path, root_build_dir),
      "-f",
      rebase_path(branding_path, root_build_dir),
      "-f",
      rebase_path(lastchange_path, root_build_dir),
      "-i",
      rebase_path(invoker.source, root_build_dir),
      "-o",
      rebase_path(invoker.output, root_build_dir),
    ]

    if (defined(invoker.extra_args)) {
      args += invoker.extra_args
    }
  }
}