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
|
# 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.
import("//build/config/compiler/compiler.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//chrome/process_version_rc_template.gni")
import("//chrome/test/mini_installer/mini_installer_test.gni")
import("//components/nacl/features.gni")
import("//third_party/icu/config.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//ui/base/ui_features.gni")
import("//v8/gni/v8.gni")
declare_args() {
# The Chrome archive is compressed in official builds to reduce the size of
# the installer. By default: non-official or component builds, a build mode
# targeting developers, do not compress so as to provide quicker build-test
# cycles.
skip_archive_compression = !is_official_build || is_component_build
}
config("mini_installer_compiler_flags") {
# Disable buffer security checking.
cflags = [ "/GS-" ]
}
source_set("lib") {
sources = [
"appid.h",
"chrome.release",
"chrome_appid.cc",
"configuration.cc",
"configuration.h",
"decompress.cc",
"decompress.h",
"mini_installer.cc",
"mini_installer.h",
"mini_installer.rc",
"mini_installer_constants.cc",
"mini_installer_constants.h",
"mini_installer_resource.h",
"mini_string.cc",
"mini_string.h",
"pe_resource.cc",
"pe_resource.h",
"regkey.cc",
"regkey.h",
]
if (skip_archive_compression) {
defines = [ "SKIP_ARCHIVE_COMPRESSION" ]
}
configs += [ ":mini_installer_compiler_flags" ]
# This input dependency on the mini installer test Python files will force a
# recompilation when any of the Python files have changed. This will then
# invalidate the build and trigger running the test on the bots even when
# no other Chrome files have changed. These have to be inputs rather than a
# dependency because a dependency won't actually trigger recompiles in
# incremental build cases unless a source file actually references one of the
# dependency outputs.
inputs = mini_installer_test_files
}
process_version_rc_template("version") {
template_file = "mini_installer_exe_version.rc.version"
output = "$root_out_dir/mini_installer_exe_version.rc"
}
source_set("unit_tests") {
testonly = true
sources = [
"configuration_test.cc",
"decompress_test.cc",
"mini_installer_unittest.cc",
"mini_string_test.cc",
]
public_deps = [
":lib",
]
deps = [
"//base",
"//base/test:test_support",
"//chrome/install_static:install_static_util",
"//chrome/installer/util:with_no_strings",
"//testing/gtest",
]
}
# The runtime deps are used to tell create_installer_archive what component
# DLLs need to be packaged in a component build.
chrome_runtime_deps = "$root_gen_dir/chrome_component.runtime_deps"
setup_runtime_deps = "$root_gen_dir/setup.runtime_deps"
group("chrome_runtime_deps") {
write_runtime_deps = chrome_runtime_deps
data_deps = [
"//chrome",
]
}
group("setup_runtime_deps") {
write_runtime_deps = setup_runtime_deps
data_deps = [
"//chrome/installer/setup",
]
}
# Generates a mini installer.
#
# out_dir (required)
# The output directory out_dir where the mini_installer image should be
# written.
#
# chrome_dll_file (required)
# The path to the version of chrome.dll that should be included in the
# installer archive.
#
# chrome_dll_target (required)
# The target that generated chrome_dll_file.
#
# deps (required)
# Normal meaning.
template("generate_mini_installer") {
chrome_dll_file = invoker.chrome_dll_file
chrome_dll_target = invoker.chrome_dll_target
output_dir = invoker.out_dir
packed_files_rc_file = "$target_gen_dir/$target_name/packed_files.rc"
archive_name = target_name + "_archive"
staging_dir = "$target_gen_dir/$target_name"
action(archive_name) {
script = "//chrome/tools/build/win/create_installer_archive.py"
release_file = "chrome.release"
inputs = [
"$chrome_dll_file",
"$root_out_dir/chrome.exe",
"$root_out_dir/locales/en-US.pak",
"$root_out_dir/setup.exe",
"//chrome/tools/build/win/makecab.py",
release_file,
]
outputs = [
# See also chrome.packed.7z conditionally added below.
"$output_dir/chrome.7z",
"$output_dir/setup.ex_",
packed_files_rc_file,
]
args = [
"--build_dir",
rebase_path(root_out_dir, root_build_dir),
"--staging_dir",
rebase_path(staging_dir, root_build_dir),
"--input_file",
rebase_path(release_file, root_build_dir),
"--resource_file_path",
rebase_path(packed_files_rc_file, root_build_dir),
"--target_arch=$current_cpu",
"--distribution=_google_chrome",
"--output_dir",
rebase_path(output_dir, root_build_dir),
"--chrome_runtime_deps",
rebase_path(chrome_runtime_deps, root_build_dir),
"--setup_runtime_deps",
rebase_path(setup_runtime_deps, root_build_dir),
# Optional arguments to generate diff installer.
#'--last_chrome_installer=C:/Temp/base',
#'--setup_exe_format=DIFF',
#'--diff_algorithm=COURGETTE',
# Optional argument for verbose archiving output.
#'--verbose',
]
deps = [
":chrome_runtime_deps",
":setup_runtime_deps",
"//chrome",
"//chrome/browser/extensions/default_extensions",
"//chrome/installer/setup",
"//third_party/icu:icudata",
chrome_dll_target,
]
if (enable_hidpi) {
args += [ "--enable_hidpi=1" ]
}
if (is_component_build) {
args += [ "--component_build=1" ]
}
if (skip_archive_compression) {
args += [ "--skip_archive_compression" ]
} else {
outputs += [ "$output_dir/chrome.packed.7z" ]
}
if (enable_nacl) {
inputs += [ "$root_out_dir/nacl_irt_x86_64.nexe" ]
deps += [ "//ppapi/native_client:irt" ]
if (current_cpu == "x86") {
inputs += [
"$root_out_dir/nacl64.exe",
"$root_out_dir/nacl_irt_x86_32.nexe",
]
deps += [ "//components/nacl/broker:nacl64" ]
}
}
if (icu_use_data_file) {
inputs += [ "$root_out_dir/icudtl.dat" ]
} else {
inputs += [ "$root_out_dir/icudt.dll" ]
}
if (v8_use_external_startup_data) {
inputs += [ "$root_out_dir/natives_blob.bin" ]
deps += [ "//v8" ]
if (use_v8_context_snapshot) {
inputs += [ "$root_out_dir/v8_context_snapshot.bin" ]
deps += [ "//tools/v8_context_snapshot" ]
} else {
inputs += [ "$root_out_dir/snapshot_blob.bin" ]
}
}
depfile = "$target_gen_dir/archive.d"
args += [
"--depfile",
rebase_path(depfile, root_build_dir),
]
}
executable(target_name) {
output_name = "mini_installer"
sources = [
"mini_installer_exe_main.cc",
packed_files_rc_file,
]
# This target is special so we manually override most linker flags and
# specify our own to keep the size down. Also make sure that we don't use
# WPO as it's not supported by the mini installer.
configs -= [
"//build/config/compiler:default_optimization",
"//build/config:executable_config",
"//build/config/win:console",
]
configs += [
":mini_installer_compiler_flags",
"//build/config/compiler:optimize_no_wpo",
"//build/config/sanitizers:link_executable",
"//build/config/win:sdk_link",
"//build/config/win:windowed",
]
ldflags = [
"/FIXED:NO",
"/ignore:4199",
"/NXCOMPAT",
]
if (!is_asan) {
ldflags += [ "/ENTRY:MainEntryPoint" ]
}
libs = [ "setupapi.lib" ]
deps = [
":$archive_name",
":lib",
":version",
"//build/config:exe_and_shlib_deps",
"//build/win:default_exe_manifest",
]
}
}
generate_mini_installer("mini_installer") {
out_dir = root_out_dir
chrome_dll_file = "$root_out_dir/chrome.dll"
chrome_dll_target = "//chrome:main_dll"
}
if (is_syzyasan) {
generate_mini_installer("mini_installer_syzygy") {
out_dir = "$root_out_dir/syzygy/"
chrome_dll_file = "$root_out_dir/syzygy/chrome.dll"
chrome_dll_target = "//chrome/tools/build/win/syzygy:chrome_dll_syzygy"
}
}
# next_version_mini_installer.exe can't be generated in an x86 Debug component
# build because it requires too much memory.
# TODO(thakis): Enable this in cross builds, https://crbug.com/799827
if (!(is_component_build && is_debug && target_cpu == "x86") &&
host_os == "win") {
action("next_version_mini_installer") {
script = "generate_next_version_mini_installer.py"
testonly = true
inputs = [
"$root_out_dir/alternate_version_generator.exe",
"$root_out_dir/mini_installer.exe",
]
outputs = [
"$root_out_dir/$target_name.exe",
]
args = [
"--out",
"$target_name.exe",
]
deps = [
":mini_installer",
"//chrome/installer/test:alternate_version_generator",
]
}
}
if (is_win) {
group("mini_installer_tests") {
testonly = true
data_deps = [
":mini_installer",
":next_version_mini_installer",
]
}
}
|