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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
chrome / version.gni [blame]
# Copyright 2015 The Chromium Authors
# 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
# //build/util/process_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",
]
}
if (target_os == "android") {
import("//build/config/android/config.gni")
import("//build/config/chrome_build.gni")
_version_dictionary_template +=
"chrome_version_code = " + "\"@CHROME_VERSION_CODE@\" " +
"monochrome_version_code = \"@MONOCHROME_VERSION_CODE@\" " +
"trichrome_version_code = \"@TRICHROME_VERSION_CODE@\" " +
"trichrome_auto_version_code = \"@TRICHROME_AUTO_VERSION_CODE@\" " +
"trichrome_beta_version_code = \"@TRICHROME_BETA_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@\" "
# Generate hybrid configurations for target_cpu's that can run in hybrid configurations.
# i.e. "riscv64" does not show up in this list, as it's a 64-bit-only target_cpu.
if (target_cpu == "arm64" || target_cpu == "x64") {
_version_dictionary_template +=
"chrome_32_version_code = \"@CHROME_32_VERSION_CODE@\" "
_version_dictionary_template +=
"monochrome_32_version_code = \"@MONOCHROME_32_VERSION_CODE@\" "
_version_dictionary_template +=
"monochrome_32_64_version_code = \"@MONOCHROME_32_64_VERSION_CODE@\" "
_version_dictionary_template +=
"monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" "
_version_dictionary_template +=
"monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_32_version_code = \"@TRICHROME_32_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_auto_32_version_code = \"@TRICHROME_AUTO_32_VERSION_CODE@\" "
_version_dictionary_template += "trichrome_auto_32_64_version_code = \"@TRICHROME_AUTO_32_64_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_32_64_version_code = \"@TRICHROME_32_64_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" "
_version_dictionary_template += "trichrome_auto_64_32_version_code = \"@TRICHROME_AUTO_64_32_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_auto_64_version_code = \"@TRICHROME_AUTO_64_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_desktop_64_version_code = \"@TRICHROME_DESKTOP_64_VERSION_CODE@\" "
if (target_cpu == "arm64") {
_version_dictionary_template += "trichrome_64_32_high_version_code = \"@TRICHROME_64_32_HIGH_VERSION_CODE@\" "
_version_dictionary_template += "trichrome_auto_64_32_high_version_code = \"@TRICHROME_AUTO_64_32_HIGH_VERSION_CODE@\" "
}
_version_dictionary_template +=
"trichrome_32_beta_version_code = \"@TRICHROME_32_BETA_VERSION_CODE@\" "
_version_dictionary_template += "trichrome_32_64_beta_version_code = \"@TRICHROME_32_64_BETA_VERSION_CODE@\" "
_version_dictionary_template += "trichrome_64_32_beta_version_code = \"@TRICHROME_64_32_BETA_VERSION_CODE@\" "
_version_dictionary_template +=
"trichrome_64_beta_version_code = \"@TRICHROME_64_BETA_VERSION_CODE@\" "
if (target_cpu == "arm64") {
_version_dictionary_template += "trichrome_64_32_high_beta_version_code = \"@TRICHROME_64_32_HIGH_BETA_VERSION_CODE@\" "
}
_version_dictionary_template +=
"webview_32_stable_version_code = \"@WEBVIEW_32_STABLE_VERSION_CODE@\" "
_version_dictionary_template +=
"webview_32_beta_version_code = \"@WEBVIEW_32_BETA_VERSION_CODE@\" "
_version_dictionary_template +=
"webview_32_dev_version_code = \"@WEBVIEW_32_DEV_VERSION_CODE@\" "
_version_dictionary_template +=
"webview_64_stable_version_code = \"@WEBVIEW_64_STABLE_VERSION_CODE@\" "
_version_dictionary_template +=
"webview_64_beta_version_code = \"@WEBVIEW_64_BETA_VERSION_CODE@\" "
_version_dictionary_template +=
"webview_64_dev_version_code = \"@WEBVIEW_64_DEV_VERSION_CODE@\" "
}
_script_arguments += [
"-a",
target_cpu,
]
}
_script_arguments += [
"-f",
rebase_path(chrome_version_file, root_build_dir),
"-t",
_version_dictionary_template,
"--os",
target_os,
]
_result = exec_script("//build/util/version.py",
_script_arguments,
"scope",
[
chrome_version_file,
"//build/util/android_chrome_version.py",
])
# Full version. For example "45.0.12321.0"
chrome_version_full = _result.full
# The constituent 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_version_code",
"chrome_32_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_auto_version_code",
"trichrome_32_version_code",
"trichrome_auto_32_version_code",
"trichrome_32_64_version_code",
"trichrome_64_32_version_code",
"trichrome_64_32_high_version_code",
"trichrome_auto_32_64_version_code",
"trichrome_auto_64_version_code",
"trichrome_auto_64_32_version_code",
"trichrome_auto_64_32_high_version_code",
"trichrome_desktop_64_version_code",
"trichrome_64_version_code",
"trichrome_beta_version_code",
"trichrome_32_beta_version_code",
"trichrome_32_64_beta_version_code",
"trichrome_64_32_beta_version_code",
"trichrome_64_32_high_beta_version_code",
"trichrome_64_beta_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
# There is a different version code only for arm64.
if (is_high_end_android && target_cpu != "arm64") {
trichrome_64_32_high_beta_version_code = trichrome_64_32_beta_version_code
trichrome_64_32_high_version_code = trichrome_64_32_version_code
trichrome_auto_64_32_high_version_code = trichrome_auto_64_32_version_code
}
}
if (is_android && current_toolchain == default_toolchain) {
lines_to_write = [
"VersionName: $chrome_version_name",
"Chrome: $chrome_version_code",
"Monochrome: $monochrome_version_code",
"TrichromeChrome: $trichrome_version_code",
"TrichromeChromeOpenBeta: $trichrome_beta_version_code",
"TrichromeChromeAuto: $trichrome_auto_version_code",
"AndroidWebviewStable: $webview_stable_version_code",
"AndroidWebviewBeta: $webview_beta_version_code",
"AndroidWebviewDev: $webview_dev_version_code",
]
if (android_64bit_target_cpu && defined(android_app_secondary_abi)) {
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",
"TrichromeChromeAuto32: $trichrome_auto_32_version_code",
"TrichromeChromeAuto3264: $trichrome_auto_32_64_version_code",
"TrichromeChromeAuto64: $trichrome_auto_64_version_code",
"TrichromeChromeAuto6432: $trichrome_auto_64_32_version_code",
"TrichromeChromeDesktop64: $trichrome_desktop_64_version_code",
]
if (target_cpu == "arm64") {
lines_to_write += [
"TrichromeChrome6432High: $trichrome_64_32_high_version_code",
"TrichromeChromeAuto6432High: $trichrome_auto_64_32_high_version_code",
]
}
lines_to_write += [
"TrichromeChrome32OpenBeta: $trichrome_32_beta_version_code",
"TrichromeChrome3264OpenBeta: $trichrome_32_64_beta_version_code",
"TrichromeChrome6432OpenBeta: $trichrome_64_32_beta_version_code",
"TrichromeChrome64OpenBeta: $trichrome_64_beta_version_code",
]
if (target_cpu == "arm64") {
lines_to_write += [ "TrichromeChrome6432HighOpenBeta: $trichrome_64_32_high_beta_version_code" ]
}
lines_to_write += [
"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)
}
if (is_android) {
import("//build/config/android/channel.gni")
import("//build/config/android/config.gni")
import("//build/config/chrome_build.gni")
# Lookup tables for version codes.
# For the list of configurations that exist, see:
# https://chromium.googlesource.com/chromium/src/+/main/docs/android_native_libraries.md#build-variants-eg_monochrome_64_32_apk
#
# For how version codes are computed, see:
# //build/util/android_chrome_version.py
# Key: {android_64bit_target_cpu}_{is_64_bit_browser}_{include_64_bit_webview}_{include_32_bit_webview}
TRICHROME_VERSION_MAP = {
_use_stable_package_name_for_trichrome =
use_stable_package_name_for_trichrome && android_channel == "beta"
# 64-bit constants are not generated by version.py on non-64-bit target_cpu.
if (android_64bit_target_cpu) {
# hybrid constants are not generated by version.py on non-64-bit-only target_cpu.
if (defined(android_app_secondary_abi)) {
if (_use_stable_package_name_for_trichrome) {
if (is_high_end_android) {
true_true_true_true = trichrome_64_32_high_beta_version_code
} else {
true_true_true_true = trichrome_64_32_beta_version_code
}
true_true_true_false = trichrome_64_beta_version_code
true_false_false_true = trichrome_32_beta_version_code
true_false_true_true = trichrome_32_64_beta_version_code
} else {
if (is_high_end_android) {
true_true_true_true = trichrome_64_32_high_version_code
} else {
true_true_true_true = trichrome_64_32_version_code
}
if (is_desktop_android) {
true_true_true_false = trichrome_desktop_64_version_code
} else {
true_true_true_false = trichrome_64_version_code
}
true_false_false_true = trichrome_32_version_code
true_false_true_true = trichrome_32_64_version_code
}
} else {
if (_use_stable_package_name_for_trichrome) {
true_true_true_false = trichrome_beta_version_code
} else {
true_true_true_false = trichrome_version_code
}
}
} else {
# !android_64bit_target_cpu
if (_use_stable_package_name_for_trichrome) {
false_false_false_true = trichrome_beta_version_code
} else {
false_false_false_true = trichrome_version_code
}
}
}
# Key: {android_64bit_target_cpu}_{is_64_bit_browser}_{include_64_bit_webview}_{include_32_bit_webview}
MONOCHROME_VERSION_MAP = {
if (android_64bit_target_cpu) {
if (defined(android_app_secondary_abi)) {
true_true_true_true = monochrome_64_32_version_code
true_false_true_true = monochrome_32_64_version_code
true_true_true_false = monochrome_64_version_code
true_false_false_true = monochrome_32_version_code
} else {
true_true_true_false = monochrome_version_code
}
} else {
false_false_false_true = monochrome_version_code
}
}
# Key: {android_64bit_target_cpu}_{include_64_bit_webview}_{include_32_bit_webview}
WEBVIEW_VERSION_MAP = {
# 64-bit constants are not generated by version.py on non-64-bit target_cpu.
if (android_64bit_target_cpu) {
if (defined(android_app_secondary_abi)) {
if (android_channel == "dev") {
true_false_true = webview_32_dev_version_code
true_true_false = webview_64_dev_version_code
true_true_true = webview_dev_version_code
} else if (android_channel == "beta") {
true_false_true = webview_32_beta_version_code
true_true_false = webview_64_beta_version_code
true_true_true = webview_beta_version_code
} else {
true_false_true = webview_32_stable_version_code
true_true_false = webview_64_stable_version_code
true_true_true = webview_stable_version_code
}
} else {
if (android_channel == "dev") {
true_true_false = webview_dev_version_code
} else if (android_channel == "beta") {
true_true_false = webview_beta_version_code
} else {
true_true_false = webview_stable_version_code
}
}
} else {
# !android_64bit_target_cpu
if (android_channel == "dev") {
false_false_true = webview_dev_version_code
} else if (android_channel == "beta") {
false_false_true = webview_beta_version_code
} else {
false_false_true = webview_stable_version_code
}
}
# For system_webview_no_weblayer_apk.
true_false_false = "1"
false_false_false = "1"
}
}