forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.gn
412 lines (373 loc) · 10.6 KB
/
BUILD.gn
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# 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.
# Chrome elf targets (excepting tests) should only link in kernel32.
# Please don't add dependencies on any other system libraries.
import("//build/config/compiler/compiler.gni")
import("//build/config/win/manifest.gni")
import("//chrome/process_version_rc_template.gni")
import("//testing/test.gni")
##------------------------------------------------------------------------------
## chrome_elf
##------------------------------------------------------------------------------
process_version_rc_template("chrome_elf_resources") {
sources = [
"chrome_elf.ver",
]
output = "$target_gen_dir/chrome_elf_version.rc"
}
# This manifest matches what GYP produces. It may not even be necessary.
windows_manifest("chrome_elf_manifest") {
sources = [
as_invoker_manifest,
]
}
# Users of chrome_elf exports can depend on this target, which doesn't
# pin them to linking either chrome_elf.dll or test_stubs.
source_set("chrome_elf_main_include") {
sources = [
"chrome_elf_main.h",
]
}
# For code that isn't Chrome-the browser, like test binaries, these stubs stand
# in for chrome_elf.;
static_library("test_stubs") {
testonly = true
sources = [
"chrome_elf_main.h",
"chrome_elf_test_stubs.cc",
]
deps = [
":sha1",
":third_party_shared_defines",
"//base",
"//chrome/common:constants",
]
}
# We should move chrome_result_codes.h to another target which does not bring
# in the world.
shared_library("chrome_elf") {
sources = [
"chrome_elf_main.cc",
"chrome_elf_main.h",
]
if (target_cpu == "x86") {
sources += [ "chrome_elf_x86.def" ]
} else if (target_cpu == "arm64") {
sources += [ "chrome_elf_arm64.def" ]
} else {
sources += [ "chrome_elf_x64.def" ]
}
deps = [
":blacklist",
":chrome_elf_manifest",
":chrome_elf_resources",
":constants",
":crash",
":hook_util",
":nt_registry",
":security",
":third_party_dlls",
"//chrome/install_static:install_static_util",
"//chrome/install_static:primary_module",
"//components/crash/content/app:crash_export_thunks",
]
configs += [ "//build/config/win:windowed" ]
configs -= [ "//build/config/win:console" ]
# Delay loads in this list will prevent user32.dll
# from loading too early.
ldflags = [
"/DELAYLOAD:advapi32.dll",
"/DELAYLOAD:dbghelp.dll",
"/DELAYLOAD:rpcrt4.dll",
"/DELAYLOAD:winmm.dll",
]
if (current_cpu == "x86") {
# Don"t set an x64 base address (to avoid breaking HE-ASLR).
ldflags += [ "/BASE:0x01c20000" ]
}
}
##------------------------------------------------------------------------------
## chrome_elf sub targets
##------------------------------------------------------------------------------
static_library("blacklist") {
sources = [
"blacklist/blacklist.cc",
"blacklist/blacklist.h",
]
deps = [
":constants",
":nt_registry",
"//chrome/install_static:install_static_util",
]
}
source_set("constants") {
sources = [
"chrome_elf_constants.cc",
"chrome_elf_constants.h",
]
}
static_library("crash") {
sources = [
"../chrome/app/chrome_crash_reporter_client_win.cc",
"../chrome/app/chrome_crash_reporter_client_win.h",
"../chrome/common/chrome_result_codes.h",
"crash/crash_helper.cc",
"crash/crash_helper.h",
]
deps = [
":hook_util",
"//base", # This needs to go. DEP of app, crash_keys, client.
"//base:base_static", # pe_image
"//chrome/install_static:install_static_util",
"//components/crash/content/app",
"//components/crash/core/common", # crash_keys
"//components/version_info:channel",
"//content/public/common:result_codes",
"//third_party/crashpad/crashpad/client", # DumpWithoutCrash
]
}
source_set("dll_hash") {
deps = [
"//base",
]
sources = [
"dll_hash/dll_hash.cc",
"dll_hash/dll_hash.h",
]
}
executable("dll_hash_main") {
sources = [
"dll_hash/dll_hash_main.cc",
]
deps = [
":dll_hash",
"//build/win:default_exe_manifest",
]
}
static_library("hook_util") {
sources = [
"../base/macros.h",
"hook_util/hook_util.cc",
"hook_util/hook_util.h",
]
deps = [
":nt_registry", # utils
"//base:base_static", # pe_image
]
public_deps = [
"//sandbox",
]
}
# This target contains utility functions which must only depend on
# kernel32. Please don't add dependencies on other system libraries.
static_library("nt_registry") {
sources = [
"../sandbox/win/src/nt_internals.h",
"nt_registry/nt_registry.cc",
"nt_registry/nt_registry.h",
]
if (is_official_build && full_wpo_on_official == true) {
# This library doen't build with WPO enabled due to a MSVC compiler bug.
# TODO(pennymac|sebmarchand): Remove this once MS has fixed this compiler
# bug: https://connect.microsoft.com/VisualStudio/feedback/details/3104499
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_no_wpo" ]
}
libs = [ "kernel32.lib" ]
}
source_set("pe_image_safe") {
sources = [
"pe_image_safe/pe_image_safe.cc",
"pe_image_safe/pe_image_safe.h",
]
}
source_set("security") {
sources = [
"chrome_elf_security.cc",
"chrome_elf_security.h",
]
deps = [
":constants",
":nt_registry",
"//chrome/install_static:install_static_util",
]
}
source_set("sha1") {
sources = [
"sha1/sha1.cc",
"sha1/sha1.h",
]
}
static_library("third_party_dlls") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
sources = [
"third_party_dlls/hook.cc",
"third_party_dlls/hook.h",
"third_party_dlls/logs.cc",
"third_party_dlls/logs.h",
"third_party_dlls/main.cc",
"third_party_dlls/main.h",
"third_party_dlls/packed_list_file.cc",
"third_party_dlls/packed_list_file.h",
]
public_deps = [
":blacklist",
":crash",
":hook_util",
":nt_registry",
":pe_image_safe",
":sha1",
":third_party_shared_defines",
"//chrome/install_static:install_static_util",
]
}
# This source_set defines third-party-related structures and APIs used from
# outside chrome_elf.dll. The APIs are exported from chrome_elf (add a
# data_dep on //chrome_elf:chrome_elf), which will always be loaded before
# chrome.dll.
source_set("third_party_shared_defines") {
sources = [
"sha1/sha1.h",
"third_party_dlls/packed_list_format.cc",
"third_party_dlls/packed_list_format.h",
"third_party_dlls/public_api.cc",
"third_party_dlls/public_api.h",
"third_party_dlls/status_codes.cc",
"third_party_dlls/status_codes.h",
]
}
##------------------------------------------------------------------------------
## tests
##------------------------------------------------------------------------------
test("chrome_elf_unittests") {
output_name = "chrome_elf_unittests"
sources = [
"blacklist/test/blacklist_test.cc",
"chrome_elf_util_unittest.cc",
"hook_util/test/hook_util_test.cc",
"nt_registry/nt_registry_unittest.cc",
"pe_image_safe/pe_image_safe_unittest.cc",
"run_all_unittests.cc",
"sha1/sha1_unittest.cc",
"third_party_dlls/logs_unittest.cc",
"third_party_dlls/main_unittest.cc",
"third_party_dlls/main_unittest_exe.h",
"third_party_dlls/packed_list_file_unittest.cc",
]
include_dirs = [ "$target_gen_dir" ]
deps = [
":blacklist",
":constants",
":crash",
":hook_util",
":hook_util_test_dll",
":nt_registry",
":pe_image_safe",
":security",
":sha1",
":third_party_dlls",
":third_party_shared_defines",
"//base",
"//base/test:test_support",
"//chrome/common:version_header",
"//chrome/install_static:install_static_util",
"//chrome/install_static/test:test_support",
"//components/crash/content/app:test_support",
"//sandbox",
"//testing/gtest",
]
data_deps = [
":chrome_elf",
":main_unittest_dll_1",
":main_unittest_dll_2",
":third_party_dlls_test_exe",
]
}
test("chrome_elf_import_unittests") {
output_name = "chrome_elf_import_unittests"
sources = [
"elf_imports_unittest.cc",
]
include_dirs = [ "$target_gen_dir" ]
deps = [
"//base",
"//base/test:test_support",
"//chrome",
"//chrome/install_static:install_static_util",
"//chrome/install_static/test:test_support",
"//testing/gtest",
]
# It's not easily possible to have //chrome in data_deps without changing
# the //chrome target to bundle up both initial/chrome.exe and chrome.exe.
# As a workaround, explicitly include a data dep on just chrome.exe, and
# add //chrome to deps above to make sure it's been built.
data = [
"$root_out_dir/chrome.exe",
]
data_deps = [
":chrome_elf",
]
# Don't want the test-specific dependencies to affect ChromeElfLoadSanityTest.
# In particular, a few system DLLs cause user32 to be loaded, which is bad.
ldflags = [
"/DELAYLOAD:advapi32.dll",
"/DELAYLOAD:ole32.dll",
"/DELAYLOAD:shell32.dll",
"/DELAYLOAD:shlwapi.dll",
"/DELAYLOAD:user32.dll",
"/DELAYLOAD:winmm.dll",
]
}
##------------------------------------------------------------------------------
## tests - data_deps
##------------------------------------------------------------------------------
shared_library("hook_util_test_dll") {
testonly = true
sources = [
"hook_util/test/hook_util_test_dll.cc",
"hook_util/test/hook_util_test_dll.h",
]
}
shared_library("main_unittest_dll_1") {
testonly = true
sources = [
"third_party_dlls/main_unittest_dll_1.cc",
]
# Disable sanitizer instrumentation in the test DLLs to avoid unwanted
# exports.
no_default_deps = true
configs -= [
"//build/config/sanitizers:default_sanitizer_flags",
"//build/config:shared_library_config",
]
}
shared_library("main_unittest_dll_2") {
testonly = true
sources = [
"third_party_dlls/main_unittest_dll_2.cc",
"third_party_dlls/main_unittest_dll_2.def",
]
# Disable sanitizer instrumentation in the test DLLs to avoid unwanted
# exports.
no_default_deps = true
configs -= [
"//build/config/sanitizers:default_sanitizer_flags",
"//build/config:shared_library_config",
]
}
executable("third_party_dlls_test_exe") {
testonly = true
sources = [
"third_party_dlls/main_unittest_exe.cc",
"third_party_dlls/main_unittest_exe.h",
]
deps = [
":third_party_dlls",
"//base",
"//base/test:test_support",
"//build/win:default_exe_manifest",
"//chrome/install_static:install_static_util",
"//components/crash/content/app:crash_export_stubs",
]
}