1 # Copyright 2015 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 # This exposes the Chrome version as GN variables for use in build files.
6 # This also generates the various version codes used for builds of chrome for
9 # PREFER NOT TO USE THESE. The GYP build uses this kind of thing extensively.
10 # However, it is far better to write an action (or use
11 # //build/util/process_version.gni) to generate a file at build-time with the
12 # information you need. This allows better dependency checking and GN will
15 # These values should only be used if you REALLY need to depend on them at
16 # build-time, for example, in the computation of output file names.
18 # Give version.py a pattern that will expand to a GN scope consisting of
19 # all values we need at once.
20 _version_dictionary_template = "full = \"@MAJOR@.@MINOR@.@BUILD@.@PATCH@\" " +
21 "major = \"@MAJOR@\" minor = \"@MINOR@\" " +
22 "build = \"@BUILD@\" patch = \"@PATCH@\" "
24 # The file containing the Chrome version number.
25 chrome_version_file = "//chrome/VERSION"
27 _script_arguments = []
30 _version_dictionary_template += "patch_hi = @PATCH_HI@ patch_lo = @PATCH_LO@ "
32 _script_arguments += [
34 "PATCH_HI=int(PATCH)//256",
36 "PATCH_LO=int(PATCH)%256",
38 } else if (target_os == "android") {
39 import("//build/config/android/config.gni")
40 import("//build/config/chrome_build.gni")
42 _version_dictionary_template +=
43 "chrome_version_code = " + "\"@CHROME_VERSION_CODE@\" " +
44 "monochrome_version_code = \"@MONOCHROME_VERSION_CODE@\" " +
45 "trichrome_version_code = \"@TRICHROME_VERSION_CODE@\" " +
46 "trichrome_auto_version_code = \"@TRICHROME_AUTO_VERSION_CODE@\" " +
47 "trichrome_beta_version_code = \"@TRICHROME_BETA_VERSION_CODE@\" " +
48 "webview_stable_version_code = \"@WEBVIEW_STABLE_VERSION_CODE@\" " +
49 "webview_beta_version_code = \"@WEBVIEW_BETA_VERSION_CODE@\" " +
50 "webview_dev_version_code = \"@WEBVIEW_DEV_VERSION_CODE@\" "
52 # Generate hybrid configurations for target_cpu's that can run in hybrid configurations.
53 # i.e. "riscv64" does not show up in this list, as it's a 64-bit-only target_cpu.
54 if (target_cpu == "arm64" || target_cpu == "x64") {
55 _version_dictionary_template +=
56 "monochrome_32_version_code = \"@MONOCHROME_32_VERSION_CODE@\" "
57 _version_dictionary_template +=
58 "monochrome_32_64_version_code = \"@MONOCHROME_32_64_VERSION_CODE@\" "
59 _version_dictionary_template +=
60 "monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" "
61 _version_dictionary_template +=
62 "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" "
63 _version_dictionary_template +=
64 "trichrome_32_version_code = \"@TRICHROME_32_VERSION_CODE@\" "
65 _version_dictionary_template +=
66 "trichrome_auto_32_version_code = \"@TRICHROME_AUTO_32_VERSION_CODE@\" "
67 _version_dictionary_template +=
68 "trichrome_auto_32_64_version_code = \"@TRICHROME_AUTO_32_64_VERSION_CODE@\" "
69 _version_dictionary_template +=
70 "trichrome_32_64_version_code = \"@TRICHROME_32_64_VERSION_CODE@\" "
71 _version_dictionary_template +=
72 "trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" "
73 _version_dictionary_template += "trichrome_auto_64_32_version_code = \"@TRICHROME_AUTO_64_32_VERSION_CODE@\" "
74 _version_dictionary_template +=
75 "trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" "
76 _version_dictionary_template +=
77 "trichrome_auto_64_version_code = \"@TRICHROME_AUTO_64_VERSION_CODE@\" "
78 if (target_cpu == "arm64") {
79 _version_dictionary_template += "trichrome_64_32_high_version_code = \"@TRICHROME_64_32_HIGH_VERSION_CODE@\" "
80 _version_dictionary_template += "trichrome_auto_64_32_high_version_code = \"@TRICHROME_AUTO_64_32_HIGH_VERSION_CODE@\" "
82 _version_dictionary_template +=
83 "trichrome_32_beta_version_code = \"@TRICHROME_32_BETA_VERSION_CODE@\" "
84 _version_dictionary_template += "trichrome_32_64_beta_version_code = \"@TRICHROME_32_64_BETA_VERSION_CODE@\" "
85 _version_dictionary_template += "trichrome_64_32_beta_version_code = \"@TRICHROME_64_32_BETA_VERSION_CODE@\" "
86 _version_dictionary_template +=
87 "trichrome_64_beta_version_code = \"@TRICHROME_64_BETA_VERSION_CODE@\" "
88 if (target_cpu == "arm64") {
89 _version_dictionary_template += "trichrome_64_32_high_beta_version_code = \"@TRICHROME_64_32_HIGH_BETA_VERSION_CODE@\" "
91 _version_dictionary_template +=
92 "webview_32_stable_version_code = \"@WEBVIEW_32_STABLE_VERSION_CODE@\" "
93 _version_dictionary_template +=
94 "webview_32_beta_version_code = \"@WEBVIEW_32_BETA_VERSION_CODE@\" "
95 _version_dictionary_template +=
96 "webview_32_dev_version_code = \"@WEBVIEW_32_DEV_VERSION_CODE@\" "
97 _version_dictionary_template +=
98 "webview_64_stable_version_code = \"@WEBVIEW_64_STABLE_VERSION_CODE@\" "
99 _version_dictionary_template +=
100 "webview_64_beta_version_code = \"@WEBVIEW_64_BETA_VERSION_CODE@\" "
101 _version_dictionary_template +=
102 "webview_64_dev_version_code = \"@WEBVIEW_64_DEV_VERSION_CODE@\" "
105 _script_arguments += [
110 if (defined(final_android_sdk) && !final_android_sdk) {
111 _script_arguments += [ "--next" ]
115 _script_arguments += [
117 rebase_path(chrome_version_file, root_build_dir),
119 _version_dictionary_template,
124 _result = exec_script("//build/util/version.py",
129 "//build/util/android_chrome_version.py",
132 # Full version. For example "45.0.12321.0"
133 chrome_version_full = _result.full
135 # The constituent parts of the full version.
136 chrome_version_major = _result.major
137 chrome_version_minor = _result.minor
138 chrome_version_build = _result.build
139 chrome_version_patch = _result.patch
142 chrome_version_patch_hi = _result.patch_hi
143 chrome_version_patch_lo = _result.patch_lo
145 chrome_dylib_version = "$chrome_version_build.$chrome_version_patch_hi" +
146 ".$chrome_version_patch_lo"
147 } else if (target_os == "android") {
148 forward_variables_from(_result,
150 "chrome_version_code",
151 "monochrome_version_code",
152 "monochrome_32_version_code",
153 "monochrome_32_64_version_code",
154 "monochrome_64_32_version_code",
155 "monochrome_64_version_code",
156 "trichrome_version_code",
157 "trichrome_auto_version_code",
158 "trichrome_32_version_code",
159 "trichrome_auto_32_version_code",
160 "trichrome_32_64_version_code",
161 "trichrome_64_32_version_code",
162 "trichrome_64_32_high_version_code",
163 "trichrome_auto_32_64_version_code",
164 "trichrome_auto_64_version_code",
165 "trichrome_auto_64_32_version_code",
166 "trichrome_auto_64_32_high_version_code",
167 "trichrome_64_version_code",
168 "trichrome_beta_version_code",
169 "trichrome_32_beta_version_code",
170 "trichrome_32_64_beta_version_code",
171 "trichrome_64_32_beta_version_code",
172 "trichrome_64_32_high_beta_version_code",
173 "trichrome_64_beta_version_code",
174 "webview_beta_version_code",
175 "webview_dev_version_code",
176 "webview_stable_version_code",
177 "webview_32_beta_version_code",
178 "webview_32_dev_version_code",
179 "webview_32_stable_version_code",
180 "webview_64_beta_version_code",
181 "webview_64_dev_version_code",
182 "webview_64_stable_version_code",
185 chrome_version_name = chrome_version_full
188 if (is_android && current_toolchain == default_toolchain) {
190 "VersionName: $chrome_version_name",
191 "Chrome: $chrome_version_code",
192 "Monochrome: $monochrome_version_code",
193 "TrichromeChrome: $trichrome_version_code",
194 "TrichromeChromeOpenBeta: $trichrome_beta_version_code",
195 "TrichromeChromeAuto: $trichrome_auto_version_code",
196 "AndroidWebviewStable: $webview_stable_version_code",
197 "AndroidWebviewBeta: $webview_beta_version_code",
198 "AndroidWebviewDev: $webview_dev_version_code",
201 if (android_64bit_target_cpu && defined(android_app_secondary_abi)) {
203 "Monochrome32: $monochrome_32_version_code",
204 "Monochrome3264: $monochrome_32_64_version_code",
205 "Monochrome6432: $monochrome_64_32_version_code",
206 "Monochrome64: $monochrome_64_version_code",
207 "TrichromeChrome32: $trichrome_32_version_code",
208 "TrichromeChrome3264: $trichrome_32_64_version_code",
209 "TrichromeChrome6432: $trichrome_64_32_version_code",
210 "TrichromeChrome64: $trichrome_64_version_code",
211 "TrichromeChromeAuto32: $trichrome_auto_32_version_code",
212 "TrichromeChromeAuto3264: $trichrome_auto_32_64_version_code",
213 "TrichromeChromeAuto64: $trichrome_auto_64_version_code",
214 "TrichromeChromeAuto6432: $trichrome_auto_64_32_version_code",
216 if (target_cpu == "arm64") {
218 "TrichromeChrome6432High: $trichrome_64_32_high_version_code",
219 "TrichromeChromeAuto6432High: $trichrome_auto_64_32_high_version_code"
223 "TrichromeChrome32OpenBeta: $trichrome_32_beta_version_code",
224 "TrichromeChrome3264OpenBeta: $trichrome_32_64_beta_version_code",
225 "TrichromeChrome6432OpenBeta: $trichrome_64_32_beta_version_code",
226 "TrichromeChrome64OpenBeta: $trichrome_64_beta_version_code",
228 if (target_cpu == "arm64") {
229 lines_to_write += [ "TrichromeChrome6432HighOpenBeta: $trichrome_64_32_high_beta_version_code" ]
232 "AndroidWebview32Stable: $webview_32_stable_version_code",
233 "AndroidWebview32Beta: $webview_32_beta_version_code",
234 "AndroidWebview32Dev: $webview_32_dev_version_code",
235 "AndroidWebview64Stable: $webview_64_stable_version_code",
236 "AndroidWebview64Beta: $webview_64_beta_version_code",
237 "AndroidWebview64Dev: $webview_64_dev_version_code",
241 write_file("$root_out_dir/android_chrome_versions.txt", lines_to_write)
245 import("//build/config/android/channel.gni")
246 import("//build/config/android/config.gni")
247 import("//build/config/chrome_build.gni")
249 # Lookup tables for version codes.
250 # For the list of configurations that exist, see:
251 # https://chromium.googlesource.com/chromium/src/+/main/docs/android_native_libraries.md#build-variants-eg_monochrome_64_32_apk
253 # For how version codes are computed, see:
254 # //build/util/android_chrome_version.py
256 # Key: {android_64bit_target_cpu}_{is_64_bit_browser}_{include_64_bit_webview}_{include_32_bit_webview}
257 TRICHROME_VERSION_MAP = {
258 _use_stable_package_name_for_trichrome =
259 use_stable_package_name_for_trichrome && android_channel == "beta"
261 # 64-bit constants are not generated by version.py on non-64-bit target_cpu.
262 if (android_64bit_target_cpu) {
263 # hybrid constants are not generated by version.py on non-64-bit-only target_cpu.
264 if (defined(android_app_secondary_abi)) {
265 if (_use_stable_package_name_for_trichrome) {
266 if (is_high_end_android) {
267 true_true_true_true = trichrome_64_32_high_beta_version_code
269 true_true_true_true = trichrome_64_32_beta_version_code
271 true_true_true_false = trichrome_64_beta_version_code
272 true_false_false_true = trichrome_32_beta_version_code
273 true_false_true_true = trichrome_32_64_beta_version_code
275 if (is_high_end_android) {
276 true_true_true_true = trichrome_64_32_high_version_code
278 true_true_true_true = trichrome_64_32_version_code
280 true_true_true_false = trichrome_64_version_code
281 true_false_false_true = trichrome_32_version_code
282 true_false_true_true = trichrome_32_64_version_code
285 if (_use_stable_package_name_for_trichrome) {
286 true_true_true_false = trichrome_beta_version_code
288 true_true_true_false = trichrome_version_code
292 # !android_64bit_target_cpu
293 if (_use_stable_package_name_for_trichrome) {
294 false_false_false_true = trichrome_beta_version_code
296 false_false_false_true = trichrome_version_code
301 # Key: {android_64bit_target_cpu}_{is_64_bit_browser}_{include_64_bit_webview}_{include_32_bit_webview}
302 MONOCHROME_VERSION_MAP = {
303 if (android_64bit_target_cpu) {
304 if (defined(android_app_secondary_abi)) {
305 true_true_true_true = monochrome_64_32_version_code
306 true_false_true_true = monochrome_32_64_version_code
307 true_true_true_false = monochrome_64_version_code
308 true_false_false_true = monochrome_32_version_code
310 true_true_true_false = monochrome_version_code
313 false_false_false_true = monochrome_version_code
317 # Key: {android_64bit_target_cpu}_{include_64_bit_webview}_{include_32_bit_webview}
318 WEBVIEW_VERSION_MAP = {
319 # 64-bit constants are not generated by version.py on non-64-bit target_cpu.
320 if (android_64bit_target_cpu) {
321 if (defined(android_app_secondary_abi)) {
322 if (android_channel == "dev") {
323 true_false_true = webview_32_dev_version_code
324 true_true_false = webview_64_dev_version_code
325 true_true_true = webview_dev_version_code
326 } else if (android_channel == "beta") {
327 true_false_true = webview_32_beta_version_code
328 true_true_false = webview_64_beta_version_code
329 true_true_true = webview_beta_version_code
331 true_false_true = webview_32_stable_version_code
332 true_true_false = webview_64_stable_version_code
333 true_true_true = webview_stable_version_code
336 if (android_channel == "dev") {
337 true_true_false = webview_dev_version_code
338 } else if (android_channel == "beta") {
339 true_true_false = webview_beta_version_code
341 true_true_false = webview_stable_version_code
345 # !android_64bit_target_cpu
346 if (android_channel == "dev") {
347 false_false_true = webview_dev_version_code
348 } else if (android_channel == "beta") {
349 false_false_true = webview_beta_version_code
351 false_false_true = webview_stable_version_code
355 # For system_webview_no_weblayer_apk.
356 true_false_false = "1"
357 false_false_false = "1"