summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/util/version.gni
blob: 998ce077d2b36009845eb53a2a06f06f8ee9f40b (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright 2015 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.

# This exposes the Chrome version as GN variables for use in build files.
# This also generates the various version codes used for builds of chrome for
# android.
#
# PREFER NOT TO USE THESE. The GYP build uses this kind of thing extensively.
# However, it is far better to write an action (or use the process_version
# wrapper in build/util/version.gni) to generate a file at build-time with the
# information you need. This allows better dependency checking and GN will
# run faster.
#
# These values should only be used if you REALLY need to depend on them at
# build-time, for example, in the computation of output file names.

# Give version.py a pattern that will expand to a GN scope consisting of
# all values we need at once.
_version_dictionary_template = "full = \"@MAJOR@.@MINOR@.@BUILD@.@PATCH@\" " +
                               "major = \"@MAJOR@\" minor = \"@MINOR@\" " +
                               "build = \"@BUILD@\" patch = \"@PATCH@\" "

# The file containing the Chrome version number.
chrome_version_file = "//chrome/VERSION"

_script_arguments = []

if (is_mac) {
  _version_dictionary_template += "patch_hi = @PATCH_HI@ patch_lo = @PATCH_LO@ "

  _script_arguments += [
    "-e",
    "PATCH_HI=int(PATCH)//256",
    "-e",
    "PATCH_LO=int(PATCH)%256",
  ]
} else if (target_os == "android") {
  import("//build/config/android/config.gni")

  _version_dictionary_template +=
      "chrome_version_code = " + "\"@CHROME_VERSION_CODE@\" " +
      "chrome_modern_version_code = \"@CHROME_MODERN_VERSION_CODE@\" " +
      "monochrome_version_code = \"@MONOCHROME_VERSION_CODE@\" " +
      "trichrome_version_code = \"@TRICHROME_VERSION_CODE@\" " +
      "webview_stable_version_code = \"@WEBVIEW_STABLE_VERSION_CODE@\" " +
      "webview_beta_version_code = \"@WEBVIEW_BETA_VERSION_CODE@\" " +
      "webview_dev_version_code = \"@WEBVIEW_DEV_VERSION_CODE@\" "

  if (target_cpu == "arm64" || target_cpu == "x64") {
    _version_dictionary_template += "monochrome_32_version_code = \"@MONOCHROME_32_VERSION_CODE@\" " + "monochrome_32_64_version_code = \"@MONOCHROME_32_64_VERSION_CODE@\" " + "monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" " + "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" " + "trichrome_32_version_code = \"@TRICHROME_32_VERSION_CODE@\" " + "trichrome_32_64_version_code = \"@TRICHROME_32_64_VERSION_CODE@\" " + "trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" " + "trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" " + "webview_32_stable_version_code = \"@WEBVIEW_32_STABLE_VERSION_CODE@\" " + "webview_32_beta_version_code = \"@WEBVIEW_32_BETA_VERSION_CODE@\" " + "webview_32_dev_version_code = \"@WEBVIEW_32_DEV_VERSION_CODE@\" " + "webview_64_stable_version_code = \"@WEBVIEW_64_STABLE_VERSION_CODE@\" " + "webview_64_beta_version_code = \"@WEBVIEW_64_BETA_VERSION_CODE@\" " + "webview_64_dev_version_code = \"@WEBVIEW_64_DEV_VERSION_CODE@\" "
  }

  _script_arguments += [
    "-a",
    target_cpu,
  ]

  if (defined(final_android_sdk) && !final_android_sdk) {
    _script_arguments += [ "--next" ]
  }
}

_script_arguments += [
  "-f",
  rebase_path(chrome_version_file, root_build_dir),
  "-t",
  _version_dictionary_template,
  "--os",
  target_os,
]

_result = exec_script("version.py",
                      _script_arguments,
                      "scope",
                      [
                        chrome_version_file,
                        "android_chrome_version.py",
                      ])

# Full version. For example "45.0.12321.0"
chrome_version_full = _result.full

# The consituent parts of the full version.
chrome_version_major = _result.major
chrome_version_minor = _result.minor
chrome_version_build = _result.build
chrome_version_patch = _result.patch

if (is_mac) {
  chrome_version_patch_hi = _result.patch_hi
  chrome_version_patch_lo = _result.patch_lo

  chrome_dylib_version = "$chrome_version_build.$chrome_version_patch_hi" +
                         ".$chrome_version_patch_lo"
} else if (target_os == "android") {
  forward_variables_from(_result,
                         [
                           "chrome_modern_version_code",
                           "chrome_version_code",
                           "monochrome_version_code",
                           "monochrome_32_version_code",
                           "monochrome_32_64_version_code",
                           "monochrome_64_32_version_code",
                           "monochrome_64_version_code",
                           "trichrome_version_code",
                           "trichrome_32_version_code",
                           "trichrome_32_64_version_code",
                           "trichrome_64_32_version_code",
                           "trichrome_64_version_code",
                           "webview_beta_version_code",
                           "webview_dev_version_code",
                           "webview_stable_version_code",
                           "webview_32_beta_version_code",
                           "webview_32_dev_version_code",
                           "webview_32_stable_version_code",
                           "webview_64_beta_version_code",
                           "webview_64_dev_version_code",
                           "webview_64_stable_version_code",
                         ])

  chrome_version_name = chrome_version_full

  lines_to_write = [
    "VersionName: $chrome_version_name",
    "Chrome: $chrome_version_code",
    "ChromeModern: $chrome_modern_version_code",
    "Monochrome: $monochrome_version_code",
    "TrichromeChrome: $trichrome_version_code",
    "AndroidWebviewStable: $webview_stable_version_code",
    "AndroidWebviewBeta: $webview_beta_version_code",
    "AndroidWebviewDev: $webview_dev_version_code",
  ]

  if (target_cpu == "arm64" || target_cpu == "x64") {
    lines_to_write += [
      "Monochrome32: $monochrome_32_version_code",
      "Monochrome3264: $monochrome_32_64_version_code",
      "Monochrome6432: $monochrome_64_32_version_code",
      "Monochrome64: $monochrome_64_version_code",
      "TrichromeChrome32: $trichrome_32_version_code",
      "TrichromeChrome3264: $trichrome_32_64_version_code",
      "TrichromeChrome6432: $trichrome_64_32_version_code",
      "TrichromeChrome64: $trichrome_64_version_code",
      "AndroidWebview32Stable: $webview_32_stable_version_code",
      "AndroidWebview32Beta: $webview_32_beta_version_code",
      "AndroidWebview32Dev: $webview_32_dev_version_code",
      "AndroidWebview64Stable: $webview_64_stable_version_code",
      "AndroidWebview64Beta: $webview_64_beta_version_code",
      "AndroidWebview64Dev: $webview_64_dev_version_code",
    ]
  }

  write_file("$root_out_dir/android_chrome_versions.txt", lines_to_write)
}