[M108 Migration][HBBTV] Implement ewk_context_register_jsplugin_mime_types API
[platform/framework/web/chromium-efl.git] / chrome / BUILD.gn
1 # Copyright 2014 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.
4
5 import("//build/config/chrome_build.gni")
6 import("//build/config/chromeos/ui_mode.gni")
7 import("//build/config/compiler/compiler.gni")
8 import("//build/config/compiler/pgo/pgo.gni")
9 import("//build/config/features.gni")
10 import("//build/config/locales.gni")
11 import("//build/config/python.gni")
12 import("//build/config/sanitizers/sanitizers.gni")
13 import("//build/config/ui.gni")
14 import("//build/config/win/console_app.gni")
15 import("//build/config/win/manifest.gni")
16 import("//build/toolchain/toolchain.gni")
17 import("//chrome/chrome_paks.gni")
18 import("//chrome/common/features.gni")
19 import("//chrome/process_version_rc_template.gni")
20 import("//components/exo/buildflags.gni")
21 import("//components/gwp_asan/buildflags/buildflags.gni")
22 import("//components/nacl/features.gni")
23 import("//components/optimization_guide/features.gni")
24 import("//extensions/buildflags/buildflags.gni")
25 import("//media/media_options.gni")
26 import("//ppapi/buildflags/buildflags.gni")
27 import("//third_party/blink/public/public_features.gni")
28 import("//third_party/widevine/cdm/widevine.gni")
29 import("//tools/resources/generate_resource_allowlist.gni")
30 import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
31 import("//ui/gl/features.gni")
32 import("//v8/gni/v8.gni")
33
34 if (is_android) {
35   import("//build/config/android/rules.gni")
36 } else if (is_linux || is_chromeos || is_tizen) {
37   import("//build/linux/extract_symbols.gni")
38   import("//build/linux/strip_binary.gni")
39 } else if (is_mac) {
40   import("//build/apple/compile_entitlements.gni")
41   import("//build/apple/compile_plist.gni")
42   import("//build/apple/tweak_info_plist.gni")
43   import("//build/compiled_action.gni")
44   import("//build/config/apple/symbols.gni")
45   import("//build/config/mac/mac_sdk.gni")
46   import("//build/config/mac/rules.gni")
47   import("//build/util/branding.gni")
48   import("//chrome/browser/buildflags.gni")
49   import("//chrome/updater/branding.gni")
50   import("//chrome/version.gni")
51   import("//content/public/app/mac_helpers.gni")
52   import("//media/cdm/library_cdm/cdm_paths.gni")
53   import("//third_party/icu/config.gni")
54 }
55
56 declare_args() {
57   # Indicates whether keystone registration framework should be enabled (see
58   # action("keystone_registration_framework") below).  There are some tests
59   # where we'd like for it to be disabled. (https://crbug.com/909080)
60   enable_keystone_registration_framework = true
61
62   # On macOS, `is_chrome_branded` builds that have been signed locally will not
63   # launch because certain entitlements are tied to the official Google code
64   # signing identity. If `include_branded_entitlements` is set to false, these
65   # entitlements will be skipped.
66   include_branded_entitlements = true
67 }
68
69 assert(!is_ios, "Chromium/iOS shouldn't use anything in //chrome")
70
71 if (is_win && enable_resource_allowlist_generation) {
72   _chrome_resource_allowlist = "$target_gen_dir/chrome_resource_allowlist.txt"
73 }
74
75 if (is_win) {
76   action("reorder_imports") {
77     script = "//build/win/reorder-imports.py"
78
79     # See comment in chrome_dll.gypi in the hardlink_to_output
80     # target for why this cannot be 'initial' like the DLL.
81     inputs = [ "$root_out_dir/initialexe/chrome.exe" ]
82     outputs = [
83       "$root_out_dir/chrome.exe",
84       "$root_out_dir/chrome.exe.pdb",
85     ]
86     args = [
87       "-i",
88       rebase_path("$root_out_dir/initialexe", root_build_dir),
89       "-o",
90       rebase_path("$root_out_dir", root_build_dir),
91       "-a",
92       current_cpu,
93     ]
94     deps = [ ":chrome_initial" ]
95   }
96 }
97
98 # This does not currently work. See crbug.com/1311822.
99 # This target exists above chrome and it's main components in the dependency
100 # tree as a central place to put assert_no_deps annotations. Since this depends
101 # on Chrome and the main DLLs it uses, it will transitively assert that those
102 # targets also have no deps on disallowed things.
103 group("assert_no_deps") {
104   deps = []
105
106   if (is_android) {
107     deps += [ "//chrome/android:chrome_public_apk" ]
108   } else if (!is_tizen) {
109     deps += [ ":chrome" ]
110   }
111
112   if (is_win) {
113     deps += [ ":chrome_dll" ]
114   }
115
116   # This should not pull in installer strings. This is will bloat the binary
117   # for no reason and is easy to mess up. See the comment at the top of
118   # //chrome/installer/util/BUILD.gn.
119   assert_no_deps = [ "//chrome/installer/util:strings" ]
120 }
121 if (!is_android && !is_mac) {
122   group("chrome") {
123     public_deps = [ ":chrome_initial" ]
124     data_deps = [ ":chrome_initial" ]
125
126     # Do not add any more deps or data_deps to group("chrome").
127     # Because chrome_initial sets its output name to "chrome", running commands
128     # such as `ninja chrome` causes chrome_initial to be built instead. All
129     # deps and data_deps should be added to the chrome_initial target instead.
130     # Targets added here can only be built by explicitly using //chrome:chrome.
131     # Windows-only deps are OK because chrome_initial uses initialexe/chrome as
132     # the output name for that platform.
133     # See crbug.com/1146571.
134     if (is_win) {
135       public_deps += [ ":reorder_imports" ]
136       data_deps += [ ":reorder_imports" ]
137     }
138   }
139
140   executable("chrome_initial") {
141     configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
142     configs += [ "//build/config/compiler:thinlto_optimize_max" ]
143     if (is_win) {
144       output_name = "initialexe/chrome"
145     } else {
146       output_name = "chrome"
147     }
148
149     # Because the sources list varies so significantly per-platform, generally
150     # each platform lists its own files rather than relying on filtering or
151     # removing unused files.
152     sources = [ "app/chrome_exe_resource.h" ]
153     defines = []
154     public_deps = []
155     deps = [
156       "//build:chromeos_buildflags",
157       "//printing/buildflags",
158     ]
159     data = [ "$root_out_dir/resources.pak" ]
160     data_deps = []
161
162     if (is_chromeos_ash) {
163       data_deps += [ "//sandbox/linux:chrome_sandbox" ]
164       deps += [ "//components/exo/wayland:weston_test_stub" ]
165     }
166
167     if (also_build_lacros_chrome_for_architecture != "") {
168       data_deps += [ "//chrome:chrome(//build/toolchain/cros:lacros_clang)" ]
169     }
170
171     if (is_win) {
172       sources += [
173         "app/chrome_exe.rc",
174         "app/chrome_exe_main_win.cc",
175         "app/delay_load_failure_hook_win.cc",
176         "app/delay_load_failure_hook_win.h",
177         "app/main_dll_loader_win.cc",
178         "app/main_dll_loader_win.h",
179         "common/crash_keys.cc",
180         "common/crash_keys.h",
181       ]
182
183       deps += [
184         ":chrome_dll",
185         ":chrome_exe_version",
186         ":copy_first_run",
187         ":packed_resources_integrity",
188         ":visual_elements_resources",
189         "//base",
190         "//build:branding_buildflags",
191         "//chrome/app:chrome_exe_main_exports",
192         "//chrome/app/version_assembly:chrome_exe_manifest",
193         "//chrome/browser:active_use_util",
194         "//chrome/browser:chrome_process_finder",
195         "//chrome/browser/policy:path_parser",
196         "//chrome/chrome_elf",
197         "//chrome/common:constants",
198         "//chrome/install_static:install_static_util",
199         "//chrome/install_static:secondary_module",
200         "//chrome/installer/util:constants",
201         "//chrome/installer/util:did_run_support",
202         "//components/browser_watcher:browser_watcher_client",
203         "//components/crash/core/app",
204         "//components/crash/core/app:run_as_crashpad_handler",
205         "//components/crash/core/common",
206         "//components/crash/win:chrome_wer",
207         "//components/flags_ui:switches",
208         "//content:sandbox_helper_win",
209         "//content/public/common:static_switches",
210         "//crypto",
211         "//gpu/command_buffer/service",
212         "//sandbox",
213         "//sandbox/policy",
214         "//sandbox/policy/mojom",
215         "//third_party/breakpad:breakpad_handler",
216         "//third_party/breakpad:breakpad_sender",
217         "//third_party/crashpad/crashpad/util",
218         "//ui/gl",
219       ]
220       data_deps = [
221         "//chrome/app/version_assembly:version_assembly_manifest",
222         "//chrome/browser/web_applications/chrome_pwa_launcher",
223         "//chrome/chrome_proxy",
224         "//chrome/elevation_service",
225         "//chrome/notification_helper",
226       ]
227
228       defines += [ "CHROME_EXE_MAIN" ]
229
230       if (win_console_app) {
231         defines += [ "WIN_CONSOLE_APP" ]
232       } else {
233         # Set /SUBSYSTEM:WINDOWS for chrome.exe itself, unless a console build
234         # has been requested.
235         configs -= [ "//build/config/win:console" ]
236         configs += [ "//build/config/win:windowed" ]
237       }
238
239       configs += [
240         "//build/config/win:delayloads",
241         "//build/config/win:delayloads_not_for_child_dll",
242       ]
243
244       if (current_cpu == "x86") {
245         # Set the initial stack size to 0.5MiB, instead of the 1.5MiB needed by
246         # Chrome's main thread. This saves significant memory on threads (like
247         # those in the Windows thread pool, and others) whose stack size we can
248         # only control through this setting. Because Chrome's main thread needs
249         # a minimum 1.5 MiB stack, the main thread (in 32-bit builds only) uses
250         # fibers to switch to a 1.5 MiB stack before running any other code.
251         ldflags = [ "/STACK:0x80000" ]
252       } else {
253         # Increase the initial stack size. The default is 1MB, this is 8MB.
254         ldflags = [ "/STACK:0x800000" ]
255       }
256     } else if (use_aura) {
257       # Non-Windows aura entrypoint.
258       sources += [ "app/chrome_exe_main_aura.cc" ]
259     }
260
261     if (is_linux || is_chromeos || is_fuchsia || is_tizen) {
262       sources += [
263         "app/chrome_dll_resource.h",
264         "app/chrome_main.cc",
265         "app/chrome_main_delegate.cc",
266         "app/chrome_main_delegate.h",
267       ]
268
269       deps += [
270         # On Linux, link the dependencies (libraries) that make up actual
271         # Chromium functionality directly into the executable.
272         ":dependencies",
273
274         # For configuring PartitionAlloc
275         "//base/allocator:buildflags",
276
277         # For the sampling profiler.
278         "//chrome/common/profiler",
279
280         # Needed to use the master_preferences functions
281         "//chrome/installer/util:with_no_strings",
282         "//content/public/app",
283
284         # For headless mode.
285         "//headless:headless_shell_lib",
286       ]
287
288       public_deps = [ "//chrome/common:buildflags" ]
289
290       if (!is_fuchsia) {
291         public_deps += [
292           ":xdg_mime",  # Needs to be public for installer to consume files.
293         ]
294
295         data_deps += [ "//components/crash/core/app:chrome_crashpad_handler" ]
296       }
297
298       ldflags = []
299
300       # On Chrome OS builds (for both ash-chrome and lacros-chrome), put
301       # priority to the library in the installed directory.
302       # This will avoid conflicting of exposed symbols.
303       if (is_chromeos_device) {
304         ldflags += [ "-L" + rebase_path(root_out_dir) ]
305       }
306
307       # On Chrome OS builds (for both ash-chrome and lacros-chrome), put
308       # a metadata.json file in root directory containing Chrome version.
309       if (is_chromeos) {
310         data_deps += [ "//build:version_metadata" ]
311       }
312
313       # Chrome OS debug builds for arm need to pass --long-plt to the linker.
314       # See https://bugs.chromium.org/p/chromium/issues/detail?id=583532
315       if (is_chromeos_ash && is_debug && target_cpu == "arm") {
316         ldflags += [ "-Wl,--long-plt" ]
317       }
318
319       if ((is_linux || is_chromeos_lacros) && !is_component_build &&
320           !using_sanitizer) {
321         version_script = "//build/linux/chrome.map"
322         inputs = [ version_script ]
323         ldflags += [ "-Wl,--version-script=" +
324                      rebase_path(version_script, root_build_dir) ]
325       }
326
327       if (is_chromeos_ash) {
328         public_deps += [ "//ui/lottie" ]
329       }
330
331       if (is_chromeos_lacros) {
332         deps += [
333           "//chromeos/crosapi/cpp:crosapi_constants",
334           "//chromeos/crosapi/mojom",
335           "//chromeos/lacros:lacros_paths",
336           "//chromeos/startup",
337           "//ui/base",
338         ]
339       }
340     }
341
342     if (is_chromeos_ash || is_win) {
343       data_deps += [ "//mojo/core:shared_library" ]
344     }
345
346     if (is_chromeos_ash) {
347       data_deps += [ "//mojo/core:shared_libraries_for_arc" ]
348       if (is_chromeos_device) {
349         configs += [ "//build/config/chromeos:print_orderfile" ]
350         configs += [ "//build/config/compiler:chrome_orderfile_config" ]
351       }
352     }
353
354     # These files are used by the installer so we need a public dep.
355     public_deps += [ ":packed_resources" ]
356
357     # The step's output are needed at runtime, so we also need a data_dep.
358     data_deps += [ ":packed_resources" ]
359
360     # ChromeOS by design is safe to have rpath=$ORIGIN. This simplifies shared
361     # library usage.
362     if (is_chromeos_ash && !is_component_build) {
363       configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
364     }
365
366     if (is_chromeos_lacros && is_chromeos_device) {
367       configs += [ "//build/lacros:optional_shared_libgcc" ]
368     }
369
370     data_deps += [
371       "//chrome/browser/resources/media/mei_preload:component",
372       "//third_party/widevine/cdm",
373     ]
374   }
375 }  # !is_android && !is_mac
376
377 if (is_win) {
378   shared_library("chrome_dll") {
379     configs += [ "//build/config/compiler:wexit_time_destructors" ]
380     configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
381     configs += [ "//build/config/compiler:thinlto_optimize_max" ]
382     defines = []
383
384     sources = [
385       "//base/win/dllmain.cc",
386       "app/chrome_main.cc",
387       "app/chrome_main_delegate.cc",
388       "app/chrome_main_delegate.h",
389     ]
390
391     output_name = "chrome"
392
393     deps = [
394       ":chrome_dll_manifest",
395       ":chrome_dll_version",
396       ":dependencies",
397       "//base/allocator:buildflags",
398       "//chrome/app:chrome_dll_resources",
399       "//chrome/app:command_ids",
400       "//chrome/app/theme:chrome_unscaled_resources",
401       "//chrome/chrome_elf",
402       "//chrome/common:buildflags",
403       "//chrome/common/profiler",
404       "//chrome/install_static:install_static_util",
405       "//chrome/install_static:secondary_module",
406       "//components/browser_watcher:stability_client",
407       "//components/crash/core/app",
408       "//components/policy:generated",
409       "//content/public/app",
410       "//crypto",
411       "//headless:headless_renderer",
412       "//headless:headless_shell_browser_lib",
413       "//net:net_resources",
414       "//ppapi/buildflags",
415       "//sandbox/win:sandbox",
416       "//third_party/cld_3/src/src:cld_3",
417       "//third_party/wtl",
418       "//ui/views",
419     ]
420
421     configs += [ "//build/config/win:delayloads" ]
422
423     if (use_aura) {
424       deps += [ "//ui/compositor" ]
425     }
426   }
427
428   copy("copy_first_run") {
429     sources = [ "app/FirstRun" ]
430     outputs = [ "$root_out_dir/First Run" ]
431   }
432 } else if (is_mac) {
433   chrome_helper_name = chrome_product_full_name + " Helper"
434   chrome_framework_name = chrome_product_full_name + " Framework"
435   chrome_framework_version = chrome_version_full
436
437   verify_dynamic_libraries = !is_component_build && !is_asan
438   if (host_os == "mac") {
439     objdump_path = mac_bin_path
440   } else {
441     objdump_path = rebase_path("$clang_base_path/bin/", root_build_dir)
442   }
443
444   group("chrome") {
445     deps = [ ":chrome_app" ]
446
447     data_deps = [ ":chrome_app" ]
448
449     if (verify_dynamic_libraries) {
450       deps += [ ":verify_libraries_chrome_app" ]
451     }
452
453     if (is_chrome_branded && is_official_build) {
454       deps += [
455         ":chrome_dsym_archive",
456         ":chrome_dump_syms",
457       ]
458     }
459   }
460
461   tweak_info_plist("chrome_app_plist") {
462     info_plist = "app/app-Info.plist"
463     args = [
464       "--breakpad=0",
465       "--scm=1",
466       "--bundle_id=$chrome_mac_bundle_id",
467     ]
468     if (is_chrome_branded) {
469       args += [ "--keystone=1" ]
470       if (current_cpu == "arm64") {
471         args += [ "--keystone-base-tag=arm64" ]
472       }
473     } else {
474       args += [ "--keystone=0" ]
475     }
476     if (enable_chromium_updater) {
477       args += [ "--privileged_helper_id=$privileged_helper_name" ]
478     }
479   }
480
481   mac_app_bundle("chrome_app") {
482     output_name = chrome_product_full_name
483
484     info_plist_target = ":chrome_app_plist"
485     extra_substitutions = [
486       "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id",
487       "CHROMIUM_SHORT_NAME=$chrome_product_short_name",
488       "CHROMIUM_CREATOR=$chrome_mac_creator_code",
489     ]
490
491     sources = [ "app/chrome_exe_main_mac.cc" ]
492
493     extra_configs = [ "//build/config/compiler:wexit_time_destructors" ]
494
495     deps = [
496       ":chrome_app_strings_bundle_data",
497       ":chrome_resources",
498       ":chrome_versioned_bundle_data",
499       "//base/allocator:early_zone_registration_mac",
500       "//build:branding_buildflags",
501       "//chrome/common:buildflags",
502       "//chrome/common:version_header",
503     ]
504
505     if (enable_stripping) {
506       # At link time, preserve the global symbols specified in the .exports
507       # file. All other global symbols will be marked as private. The default
508       # //build/config/mac:strip_all config will then remove the remaining
509       # local and debug symbols.
510       ldflags = [ "-Wl,-exported_symbols_list," +
511                   rebase_path("app/app.exports", root_build_dir) ]
512     }
513
514     if (is_component_build) {
515       # In a component build, the framework is directly linked to the
516       # executable because dlopen() and loading all the dependent dylibs
517       # is time-consuming, see https://crbug.com/1197495.
518       deps += [ ":chrome_framework+link" ]
519       ldflags = [ "-Wl,-rpath,@executable_path/../Frameworks" ]
520
521       # The Framework is packaged inside the .app bundle. But when using the
522       # component build, all the dependent shared libraries of :chrome_dll are
523       # not packaged within the framework. This data_deps line makes all of
524       # those dependent libraries runtime dependencies of the .app bundle.
525       # This is a bit of a hack, since GN deliberately terminates its search
526       # for runtime_deps at create_bundle nodes (https://crbug.com/1010347).
527       data_deps = [ ":chrome_framework" ]
528     }
529
530     if (enable_chromium_updater) {
531       deps += [ ":chromium_updater_privileged_helper" ]
532     }
533   }
534
535   if (verify_dynamic_libraries) {
536     action("verify_libraries_chrome_app") {
537       script = "//chrome/tools/build/mac/verify_dynamic_libraries.py"
538       inputs = [ "${root_out_dir}/${chrome_product_full_name}.app/Contents/MacOS/${chrome_product_full_name}" ]
539       outputs = [ "$target_out_dir/run_$target_name.stamp" ]
540       args = [
541         "--stamp",
542         rebase_path(outputs[0], root_out_dir),
543         "-B",
544         objdump_path,
545         "--image",
546         rebase_path(inputs[0], root_out_dir),
547         "--allow",
548         "/usr/lib/libSystem.B.dylib",
549       ]
550       deps = [ ":chrome_app" ]
551     }
552   }
553
554   compiled_action("chrome_app_strings") {
555     tool = "//chrome/tools/build/mac:infoplist_strings_util"
556
557     inputs = []
558
559     outputs = []
560
561     foreach(locale, platform_pak_locales) {
562       if (is_chrome_branded) {
563         _strings_file = "google_chrome_strings"
564       } else {
565         _strings_file = "chromium_strings"
566       }
567
568       inputs += [ "$root_gen_dir/chrome/${_strings_file}_${locale}.pak" ]
569     }
570
571     foreach(locale, locales_as_apple_outputs) {
572       outputs += [
573         "$target_gen_dir/app_infoplist_strings/$locale.lproj/InfoPlist.strings",
574       ]
575     }
576
577     args =
578         [
579           "-b",
580           "${branding_path_product}_strings",
581           "-v",
582           chrome_version_full,
583           "-g",
584           rebase_path("$root_gen_dir/chrome", root_build_dir),
585           "-o",
586           rebase_path("$target_gen_dir/app_infoplist_strings", root_build_dir),
587           "-t",
588           "main",
589         ] + platform_pak_locales
590
591     if (is_chrome_branded) {
592       deps = [ "//chrome/app:google_chrome_strings" ]
593     } else {
594       deps = [ "//chrome/app:chromium_strings" ]
595     }
596   }
597
598   foreach(locale, locales_as_apple_outputs) {
599     bundle_data("chrome_app_strings_${locale}_bundle_data") {
600       sources = [
601         "$target_gen_dir/app_infoplist_strings/$locale.lproj/InfoPlist.strings",
602       ]
603       outputs =
604           [ "{{bundle_resources_dir}}/$locale.lproj/{{source_file_part}}" ]
605       public_deps = [ ":chrome_app_strings" ]
606     }
607   }
608   group("chrome_app_strings_bundle_data") {
609     public_deps = []
610     foreach(locale, locales_as_apple_outputs) {
611       public_deps += [ ":chrome_app_strings_${locale}_bundle_data" ]
612     }
613   }
614
615   bundle_data("chrome_app_icon") {
616     sources = [ "app/theme/$branding_path_component/mac/app.icns" ]
617     outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
618   }
619
620   bundle_data("chrome_resources") {
621     sources = [
622       "$root_out_dir/$chrome_mac_bundle_id.manifest",
623       "app/theme/$branding_path_component/mac/document.icns",
624       "browser/ui/cocoa/applescript/scripting.sdef",
625     ]
626     outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
627     public_deps = [
628       ":chrome_app_icon",
629       ":chrome_app_strings",
630       "//components/policy:chrome_manifest_bundle",
631     ]
632   }
633
634   bundle_data("chrome_versioned_bundle_data") {
635     sources = [ "$root_out_dir/$chrome_framework_name.framework" ]
636     outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
637     public_deps = [
638       # Before bundling the versioned app components, delete any existing
639       # versions.
640       ":clean_up_old_versions",
641
642       # verify_chrome_framework_order depends on :chrome_framework and, for
643       # non-component builds, will ensure the export symbol table is correct.
644       ":verify_chrome_framework_order",
645     ]
646
647     if (enable_widevine_cdm_host_verification) {
648       # The :chrome_framework_widevine_signature target copies into the
649       # :chrome_framework bundle. But because the signing file depends on the
650       # framework itself, that would cause a cyclical dependency. Instead,
651       # this dependency directly copies the file into the framework's
652       # resources directory.
653       public_deps += [ ":chrome_framework_widevine_signature" ]
654     }
655   }
656
657   if (enable_chromium_updater) {
658     bundle_data("chromium_updater_privileged_helper") {
659       sources = [ "$root_out_dir/$privileged_helper_name" ]
660       outputs = [
661         "{{bundle_contents_dir}}/Library/LaunchServices/{{source_file_part}}",
662       ]
663
664       public_deps = [ "//chrome/updater/mac:privileged_helper" ]
665     }
666   }
667
668   action("clean_up_old_versions") {
669     script = "//chrome/tools/build/mac/clean_up_old_versions.py"
670
671     _stamp_file = "$root_gen_dir/run_$target_name.stamp"
672
673     outputs = [ _stamp_file ]
674
675     _versions_dir = "$root_out_dir/$chrome_product_full_name.app/Contents/Frameworks/$chrome_framework_name.framework/Versions"
676
677     args = [
678       "--versions-dir",
679       rebase_path(_versions_dir, root_build_dir),
680       "--stamp",
681       rebase_path(_stamp_file, root_build_dir),
682       "--keep",
683       chrome_version_full,
684       "--keep",
685       "Current",
686     ]
687   }
688
689   tweak_info_plist("chrome_helper_plist") {
690     info_plist = "app/helper-Info.plist"
691     args = [
692       "--breakpad=0",
693       "--keystone=0",
694       "--scm=0",
695     ]
696   }
697
698   compile_entitlements("entitlements") {
699     entitlements_templates = [ "app/app-entitlements.plist" ]
700     if (is_chrome_branded && include_branded_entitlements) {
701       # These entitlements are bound to the official Google Chrome signing
702       # certificate and will not necessarily work in any other build.
703       entitlements_templates += [ "app/app-entitlements-chrome.plist" ]
704     }
705     output_name = "$target_gen_dir/app-entitlements.plist"
706     substitutions = [
707       "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id",
708       "CHROMIUM_TEAM_ID=$chrome_mac_team_id",
709     ]
710     visibility = [ "//chrome/installer/mac:copies" ]
711   }
712
713   template("chrome_helper_app") {
714     mac_app_bundle(target_name) {
715       assert(defined(invoker.helper_name_suffix))
716       assert(defined(invoker.helper_bundle_id_suffix))
717
718       output_name = chrome_helper_name + invoker.helper_name_suffix
719
720       if (defined(invoker.info_plist_target)) {
721         info_plist_target = invoker.info_plist_target
722       } else {
723         info_plist_target = ":chrome_helper_plist"
724       }
725
726       extra_substitutions = [
727         "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id",
728         "CHROMIUM_SHORT_NAME=$chrome_product_short_name",
729         "CHROMIUM_HELPER_SUFFIX=${invoker.helper_name_suffix}",
730         "CHROMIUM_HELPER_BUNDLE_ID_SUFFIX=${invoker.helper_bundle_id_suffix}",
731       ]
732
733       sources = [ "app/chrome_exe_main_mac.cc" ]
734
735       extra_configs = [ "//build/config/compiler:wexit_time_destructors" ]
736
737       defines = [ "HELPER_EXECUTABLE" ]
738
739       deps = [
740         "//base/allocator:early_zone_registration_mac",
741         "//build:branding_buildflags",
742         "//chrome/common:version_header",
743         "//sandbox/mac:seatbelt",
744       ]
745
746       if (defined(invoker.deps)) {
747         deps += invoker.deps
748       }
749
750       ldflags = []
751
752       if (is_component_build) {
753         # In a component build, the framework is directly linked to the
754         # executable because dlopen() and loading all the dependent dylibs
755         # is time-consuming, see https://crbug.com/1197495.
756         deps += [ ":chrome_framework+link_nested" ]
757
758         ldflags += [
759           # The helper is in Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/X/Helpers/Chromium Helper.app/Contents/MacOS
760           # so set rpath up to the base.
761           "-Wl,-rpath,@loader_path/../../../../../../../../../..",
762
763           # ... and up to Contents/Frameworks.
764           "-Wl,-rpath,@executable_path/../../../../../../..",
765         ]
766       }
767
768       if (enable_stripping) {
769         # At link time, preserve the global symbols specified in the .exports
770         # file. All other global symbols will be marked as private. The default
771         # //build/config/mac:strip_all config will then remove the remaining
772         # local and debug symbols.
773         ldflags += [ "-Wl,-exported_symbols_list," +
774                      rebase_path("app/app.exports", root_build_dir) ]
775       }
776     }
777   }
778
779   # The following *_helper_params are added to the ones provided by //content
780   # listed in content_mac_helpers (see //content/public/app/mac_helpers.gni).
781   # These allow //chrome to add custom helper apps in addition to the ones
782   # provided by //content. The params here have the same form as the content
783   # helpers and are defined as a tuple of these elements:
784   #   target name - A short name to be used when defining the target for that
785   #                 helper variant.
786   #   bundle ID suffix - A string fragment to append to the CFBundleIdentifier of
787   #                      the helper.
788   #   app name suffix - A string fragment to append to the outer bundle name as
789   #                     well as the inner executable. This should be reflected in
790   #                     the target's output_name.
791
792   # Helper app to display alert notifications. This is necessary as an app can
793   # only display either banner or alert style notifications and the main app
794   # will display banners.
795   alert_helper_params = [
796     "alerts",
797     ".alerts",
798     " (Alerts)",
799   ]
800
801   # Merge all helper apps needed by //content and //chrome.
802   chrome_mac_helpers = content_mac_helpers + [ alert_helper_params ]
803
804   # Create all helper apps required by //content.
805   foreach(helper_params, content_mac_helpers) {
806     chrome_helper_app("chrome_helper_app_${helper_params[0]}") {
807       helper_name_suffix = helper_params[2]
808       helper_bundle_id_suffix = helper_params[1]
809     }
810   }
811
812   # Create app for the alert helper manually here as we want to modify the plist
813   # to set the alert style and add the app icon to its resources.
814   tweak_info_plist("chrome_helper_app_alerts_plist") {
815     deps = [ ":chrome_helper_plist" ]
816     info_plists = get_target_outputs(":chrome_helper_plist") +
817                   [ "app/helper-alerts-Info.plist" ]
818   }
819
820   # Create and bundle an InfoPlist.strings for the alert helper app.
821   # TODO(crbug.com/1182393): Disambiguate and localize alert helper app name.
822   compile_plist("chrome_helper_app_alerts_plist_strings") {
823     format = "binary1"
824     plist_templates = [ "app/helper-alerts-InfoPlist.strings" ]
825     substitutions = [ "CHROMIUM_FULL_NAME=$chrome_product_full_name" ]
826     output_name = "$target_gen_dir/helper_alerts_infoplist_strings/base.lproj/InfoPlist.strings"
827   }
828   bundle_data("chrome_helper_app_alerts_resources") {
829     sources = get_target_outputs(":chrome_helper_app_alerts_plist_strings")
830     outputs = [ "{{bundle_resources_dir}}/base.lproj/{{source_file_part}}" ]
831     public_deps = [ ":chrome_helper_app_alerts_plist_strings" ]
832   }
833
834   chrome_helper_app("chrome_helper_app_${alert_helper_params[0]}") {
835     helper_name_suffix = alert_helper_params[2]
836     helper_bundle_id_suffix = alert_helper_params[1]
837     info_plist_target = ":chrome_helper_app_alerts_plist"
838     deps = [
839       ":chrome_app_icon",
840       ":chrome_helper_app_alerts_resources",
841     ]
842   }
843
844   if (verify_dynamic_libraries) {
845     foreach(helper_params, chrome_mac_helpers) {
846       _helper_target = helper_params[0]
847       _helper_bundle_id = helper_params[1]
848       _helper_suffix = helper_params[2]
849
850       action("verify_libraries_chrome_helper_app_${_helper_target}") {
851         script = "//chrome/tools/build/mac/verify_dynamic_libraries.py"
852         inputs = [ "${root_out_dir}/${chrome_helper_name}${_helper_suffix}.app/Contents/MacOS/${chrome_helper_name}${_helper_suffix}" ]
853         outputs = [ "$target_out_dir/run_$target_name.stamp" ]
854         args = [
855           "--stamp",
856           rebase_path(outputs[0], root_out_dir),
857           "-B",
858           objdump_path,
859           "--image",
860           rebase_path(inputs[0], root_out_dir),
861
862           # Do not --allow more libraries here without consulting with the
863           # security team (security-dev@chromium.org).
864           "--allow",
865           "/usr/lib/libsandbox.1.dylib",
866           "--allow",
867           "/usr/lib/libSystem.B.dylib",
868         ]
869         deps = [ ":chrome_helper_app_${_helper_target}" ]
870       }
871     }
872   }
873
874   bundle_data("chrome_framework_helpers") {
875     sources = [
876       "$root_out_dir/app_mode_loader",
877       "$root_out_dir/chrome_crashpad_handler",
878     ]
879
880     outputs = [ "{{bundle_contents_dir}}/Helpers/{{source_file_part}}" ]
881
882     public_deps = [
883       "//chrome/app_shim:app_mode_loader",
884       "//components/crash/core/app:chrome_crashpad_handler",
885     ]
886
887     foreach(helper_params, chrome_mac_helpers) {
888       sources +=
889           [ "$root_out_dir/${chrome_helper_name}${helper_params[2]}.app" ]
890       public_deps += [ ":chrome_helper_app_${helper_params[0]}" ]
891       if (verify_dynamic_libraries) {
892         public_deps +=
893             [ ":verify_libraries_chrome_helper_app_${helper_params[0]}" ]
894       }
895     }
896
897     if (enable_chromium_updater) {
898       if (is_chrome_branded) {
899         sources += [ "//third_party/updater/chrome_mac_universal_prod/${updater_product_full_name}.app" ]
900       } else {
901         sources += [ "$root_out_dir/${updater_product_full_name}.app" ]
902
903         public_deps += [
904           "//chrome/updater/mac:browser_install_script",
905           "//chrome/updater/mac:updater_bundle",
906           "//chrome/updater/mac:updater_install_script",
907         ]
908       }
909     }
910   }
911
912   bundle_data("chrome_framework_resources") {
913     sources = [
914       # This image is used to badge the lock icon in the
915       # authentication dialogs, such as those used for installation
916       # from disk image and Keystone promotion (if so enabled).  It
917       # needs to exist as a file on disk and not just something in a
918       # resource bundle because that's the interface that
919       # Authorization Services uses.  Also, Authorization Services
920       # can't deal with .icns files.
921       "app/theme/default_100_percent/$branding_path_component/product_logo_32.png",
922       "browser/mac/install.sh",
923     ]
924
925     outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
926
927     public_deps = [
928       ":packed_resources",
929       "//chrome/app_shim:app_mode_loader_plist_bundle_data",
930     ]
931
932     if (is_chrome_branded) {
933       sources += [
934         "browser/mac/keystone_promote_postflight.sh",
935         "browser/mac/keystone_promote_preflight.sh",
936       ]
937     }
938
939     if (icu_use_data_file) {
940       sources += [ "$root_out_dir/icudtl.dat" ]
941       public_deps += [ "//third_party/icu:icudata" ]
942     }
943
944     if (v8_use_external_startup_data) {
945       public_deps += [ "//v8" ]
946       if (use_v8_context_snapshot) {
947         sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
948         public_deps += [ "//tools/v8_context_snapshot" ]
949       } else {
950         sources += [ "$root_out_dir/snapshot_blob.bin" ]
951       }
952     }
953   }
954
955   if (enable_nacl) {
956     bundle_data("chrome_framework_plugins") {
957       sources = []
958       outputs =
959           [ "{{bundle_contents_dir}}/Internet Plug-Ins/{{source_file_part}}" ]
960       public_deps = []
961
962       if (enable_nacl) {
963         if (current_cpu == "x86") {
964           sources += [ "$root_out_dir/nacl_irt_x86_32.nexe" ]
965         } else if (current_cpu == "x64") {
966           sources += [ "$root_out_dir/nacl_irt_x86_64.nexe" ]
967         }
968         public_deps += [ "//ppapi/native_client:irt" ]
969       }
970     }
971   } else {
972     group("chrome_framework_plugins") {
973     }
974   }
975
976   # EGL on MacOS ships with official chrome
977   bundle_egl_libraries = use_egl
978
979   if (bundle_egl_libraries) {
980     # Add the ANGLE .dylibs in the MODULE_DIR of Chromium.app
981     bundle_data("angle_binaries") {
982       sources = [
983         "$root_out_dir/egl_intermediates/libEGL.dylib",
984         "$root_out_dir/egl_intermediates/libGLESv2.dylib",
985       ]
986       outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
987       public_deps = [ "//ui/gl:angle_library_copy" ]
988     }
989
990     # Add the SwiftShader .dylibs in the MODULE_DIR of Chromium.app
991     bundle_data("swiftshader_binaries") {
992       sources = [
993         "$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
994         "$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
995       ]
996       outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
997       public_deps = [ "//ui/gl:swiftshader_vk_library_copy" ]
998     }
999   }
1000
1001   group("angle_library") {
1002     if (bundle_egl_libraries) {
1003       deps = [ ":angle_binaries" ]
1004     }
1005   }
1006
1007   group("swiftshader_library") {
1008     if (bundle_egl_libraries) {
1009       deps = [ ":swiftshader_binaries" ]
1010     }
1011   }
1012
1013   if (bundle_widevine_cdm) {
1014     bundle_data("widevine_cdm_library_binaries") {
1015       sources = [ "$root_out_dir/$widevine_cdm_path/libwidevinecdm.dylib" ]
1016       if (enable_widevine_cdm_host_verification) {
1017         sources +=
1018             [ "$root_out_dir/$widevine_cdm_path/libwidevinecdm.dylib.sig" ]
1019       }
1020       outputs = [ "{{bundle_contents_dir}}/Libraries/$widevine_cdm_path/{{source_file_part}}" ]
1021       public_deps = [ "//third_party/widevine/cdm" ]
1022     }
1023
1024     bundle_data("widevine_cdm_library_manifest_and_license_files") {
1025       sources = [
1026         "$root_out_dir/WidevineCdm/LICENSE",
1027         "$root_out_dir/WidevineCdm/manifest.json",
1028       ]
1029       outputs = [
1030         "{{bundle_contents_dir}}/Libraries/WidevineCdm/{{source_file_part}}",
1031       ]
1032       public_deps = [ "//third_party/widevine/cdm" ]
1033     }
1034   }
1035
1036   group("widevine_cdm_library") {
1037     if (bundle_widevine_cdm) {
1038       deps = [
1039         ":widevine_cdm_library_binaries",
1040         ":widevine_cdm_library_manifest_and_license_files",
1041       ]
1042     }
1043   }
1044
1045   if (enable_widevine_cdm_host_verification) {
1046     widevine_sign_file("sign_chrome_framework_for_widevine") {
1047       file = "$root_out_dir/$chrome_framework_name.framework/Versions/$chrome_framework_version/$chrome_framework_name"
1048       flags = 1
1049       signature_file = "$root_out_dir/$chrome_framework_name.sig"
1050       deps = [ ":chrome_framework" ]
1051     }
1052
1053     copy("chrome_framework_widevine_signature") {
1054       deps = [ ":sign_chrome_framework_for_widevine" ]
1055
1056       sources = [ "$root_out_dir/$chrome_framework_name.sig" ]
1057
1058       outputs = [ "$root_out_dir/$chrome_framework_name.framework/Resources/{{source_file_part}}" ]
1059     }
1060   }
1061
1062   if (is_chrome_branded && enable_keystone_registration_framework) {
1063     bundle_data("keystone_registration_framework") {
1064       sources = [ "//third_party/googlemac/Releases/Keystone/KeystoneRegistration.framework" ]
1065
1066       outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
1067     }
1068   } else {
1069     group("keystone_registration_framework") {
1070     }
1071   }
1072
1073   if (build_with_internal_optimization_guide) {
1074     # Add the optimization guide .dylib in the MODULE_DIR of Chromium.app
1075     bundle_data("optimization_guide_library") {
1076       sources = [
1077         "$root_out_dir/og_intermediates/liboptimization_guide_internal.dylib",
1078       ]
1079       outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
1080       public_deps = [ "//components/optimization_guide/core:optimization_guide_internal_library_copy" ]
1081     }
1082   } else {
1083     group("optimization_guide_library") {
1084     }
1085   }
1086
1087   tweak_info_plist("chrome_framework_plist") {
1088     info_plist = "app/framework-Info.plist"
1089     args = [
1090       "--breakpad=0",
1091       "--keystone=0",
1092       "--scm=1",
1093       "--branding",
1094       chrome_product_short_name,
1095     ]
1096   }
1097
1098   # On Mac, speed up the component build by not re-bundling the framework
1099   # every time it changes. Instead, place all the sources and their deps in
1100   # a library that the bundled framework links (and re-exports). That way
1101   # only the library needs to be re-linked when it changes.
1102   if (is_component_build) {
1103     _dll_target_type = "shared_library"
1104   } else {
1105     _dll_target_type = "source_set"
1106   }
1107   target(_dll_target_type, "chrome_dll") {
1108     visibility = [
1109       ":chrome_framework",
1110       ":chrome_framework_create_bundle",
1111       ":chrome_framework_shared_library",
1112     ]
1113
1114     sources = [
1115       "app/chrome_crash_reporter_client.cc",
1116       "app/chrome_crash_reporter_client.h",
1117       "app/chrome_crash_reporter_client_mac.mm",
1118       "app/chrome_dll_resource.h",
1119       "app/chrome_main.cc",
1120       "app/chrome_main_delegate.cc",
1121       "app/chrome_main_delegate.h",
1122       "app/chrome_main_mac.h",
1123       "app/chrome_main_mac.mm",
1124     ]
1125
1126     deps = [
1127       ":dependencies",
1128       "//base/allocator:buildflags",
1129       "//build:chromeos_buildflags",
1130       "//chrome/app:command_ids",
1131       "//chrome/app:notification_metrics",
1132       "//chrome/common:buildflags",
1133       "//chrome/common/profiler",
1134       "//components/crash/core/app",
1135       "//components/policy:generated",
1136       "//content/public/app",
1137       "//headless:headless_shell_lib",
1138       "//third_party/cld_3/src/src:cld_3",
1139     ]
1140
1141     if (is_component_build) {
1142       frameworks = [ "Carbon.framework" ]
1143     }
1144
1145     ldflags = [
1146       "-Wl,-order_file",
1147       "-Wl," + rebase_path("app/framework.order", root_build_dir),
1148       "-ObjC",
1149     ]
1150
1151     configs += [ "//build/config/compiler:wexit_time_destructors" ]
1152   }
1153
1154   mac_framework_bundle("chrome_framework") {
1155     output_name = chrome_framework_name
1156
1157     framework_version = chrome_framework_version
1158     framework_contents = [
1159       "Helpers",
1160       "Libraries",
1161       "Resources",
1162     ]
1163
1164     if (is_chrome_branded) {
1165       framework_contents += [ "Default Apps" ]
1166       if (enable_keystone_registration_framework) {
1167         # For KeystoneRegistration.framework.
1168         framework_contents += [ "Frameworks" ]
1169       }
1170     }
1171
1172     if (enable_nacl) {
1173       framework_contents += [ "Internet Plug-Ins" ]
1174     }
1175
1176     configs += [ "//build/config/compiler:wexit_time_destructors" ]
1177     configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
1178     configs += [ "//build/config/compiler:thinlto_optimize_max" ]
1179
1180     info_plist_target = ":chrome_framework_plist"
1181     extra_substitutions = [
1182       "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id",
1183       "CHROMIUM_SHORT_NAME=$chrome_product_short_name",
1184     ]
1185
1186     public_deps = [ ":chrome_dll" ]
1187
1188     bundle_deps = [
1189       ":angle_library",
1190       ":chrome_framework_helpers",
1191       ":chrome_framework_plugins",
1192       ":chrome_framework_resources",
1193       ":keystone_registration_framework",
1194       ":optimization_guide_library",
1195       ":swiftshader_library",
1196       ":widevine_cdm_library",
1197       "//chrome/browser/resources/media/mei_preload:component_bundle",
1198     ]
1199
1200     if (is_chrome_branded) {
1201       bundle_deps += [ ":preinstalled_apps" ]
1202     }
1203
1204     ldflags = [
1205       "-compatibility_version",
1206       chrome_dylib_version,
1207       "-current_version",
1208       chrome_dylib_version,
1209       "-Wl,-order_file," + rebase_path("app/framework.order", root_build_dir),
1210     ]
1211
1212     if (!is_component_build) {
1213       # Specify a sensible install_name for static builds. The library is
1214       # dlopen()ed so this is not used to resolve the module.
1215       ldflags += [ "-Wl,-install_name,@executable_path/../Frameworks/$chrome_framework_name.framework/Versions/$chrome_version_full/$chrome_framework_name" ]
1216     } else {
1217       # In the component build, both the :chrome_app and various
1218       # :chrome_helper* targets directly link to the Framework target. Use
1219       # @rpath-based loading so that the dylib ID does not have to be changed
1220       # with install_name_tool.
1221       ldflags += [
1222         "-Wl,-install_name,@rpath/$chrome_framework_name.framework/$chrome_framework_name",
1223         "-Wl,-rpath,@loader_path/../../../../../..",
1224         "-Wl,-reexport_library,libchrome_dll.dylib",
1225       ]
1226
1227       data_deps = [ ":chrome_dll" ]
1228     }
1229   }
1230
1231   _framework_binary_path = "$root_out_dir/$chrome_framework_name.framework/Versions/$chrome_framework_version/$chrome_framework_name"
1232   assert(_framework_binary_path != "",
1233          "Ignore configuration-dependent unused variable warning")
1234
1235   # TOOD(crbug/1163903#c8) - thakis@ look into why profile and coverage
1236   # instrumentation adds these symbols in different orders
1237   if (!is_component_build && chrome_pgo_phase != 1 && !using_sanitizer) {
1238     action("verify_chrome_framework_order") {
1239       script = "//chrome/tools/build/mac/verify_order.py"
1240       stamp_file = "$target_out_dir/run_$target_name.stamp"
1241       inputs = [ script ]
1242       args = [
1243         "--stamp=" + rebase_path(stamp_file, root_out_dir),
1244         "--binary=" + rebase_path(_framework_binary_path, root_out_dir),
1245         "--symbol-file=" + rebase_path("app/framework.order", root_build_dir),
1246       ]
1247       if (host_os == "mac") {
1248         args += [ "--nm-path=$mac_bin_path/nm" ]
1249       } else {
1250         args += [ "--nm-path=" +
1251                   rebase_path("$clang_base_path/bin/llvm-nm", root_build_dir) ]
1252       }
1253       outputs = [ stamp_file ]
1254       public_deps = [ ":chrome_framework" ]
1255     }
1256   } else {
1257     group("verify_chrome_framework_order") {
1258       if (is_component_build) {
1259         # In a component build, the framework is directly linked to the
1260         # executable because dlopen() and loading all the dependent dylibs
1261         # is time-consuming, see https://crbug.com/1197495.
1262         public_deps = [ ":chrome_framework+link" ]
1263       } else {
1264         public_deps = [ ":chrome_framework" ]
1265       }
1266     }
1267   }
1268
1269   if (enable_dsyms && !is_component_build) {
1270     # It is possible to run dump_syms on unstripped products without dSYMs, but
1271     # doing so isn't logical and won't happen in practice. It's also pointless
1272     # to run dump_syms or archive dSYMs in a component build, where all of the
1273     # interesting symbols and debug info are tucked away in other libraries
1274     # beyond the set explicitly listed here.
1275
1276     # This list must be updated with the two targets' deps list below, and
1277     # the list of _dsyms in :chrome_dsym_archive.
1278     _chrome_symbols_sources = [
1279       "$root_out_dir/$chrome_product_full_name.app/Contents/MacOS/$chrome_product_full_name",
1280       "$root_out_dir/chrome_crashpad_handler",
1281       "$root_out_dir/libEGL.dylib",
1282       "$root_out_dir/libGLESv2.dylib",
1283       "$root_out_dir/libvk_swiftshader.dylib",
1284       _framework_binary_path,
1285     ]
1286     if (build_with_internal_optimization_guide) {
1287       _chrome_symbols_sources +=
1288           [ "$root_out_dir/liboptimization_guide_internal.dylib" ]
1289     }
1290
1291     foreach(helper_params, chrome_mac_helpers) {
1292       _chrome_symbols_sources += [ "$root_out_dir/${chrome_helper_name}${helper_params[2]}.app/Contents/MacOS/${chrome_helper_name}${helper_params[2]}" ]
1293     }
1294
1295     action_foreach("chrome_dump_syms") {
1296       script = "//build/redirect_stdout.py"
1297
1298       sources = _chrome_symbols_sources
1299
1300       outputs =
1301           [ "$root_out_dir/{{source_file_part}}-$chrome_version_full.breakpad" ]
1302
1303       dump_syms = "//third_party/breakpad:dump_syms($host_toolchain)"
1304       args = rebase_path(outputs, root_build_dir) + [
1305                rebase_path(get_label_info(dump_syms, "root_out_dir") + "/" +
1306                                get_label_info(dump_syms, "name"),
1307                            root_build_dir),
1308                "-g",
1309                rebase_path(
1310                    "$root_out_dir/{{source_file_part}}.dSYM/Contents/Resources/DWARF/{{source_file_part}}",
1311                    root_build_dir),
1312                "{{source}}",
1313              ]
1314
1315       deps = [
1316         ":chrome_app",
1317         ":chrome_framework",
1318         "//components/crash/core/app:chrome_crashpad_handler",
1319         "//third_party/angle:libEGL",
1320         "//third_party/angle:libGLESv2",
1321         "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan",
1322         dump_syms,
1323       ]
1324       if (build_with_internal_optimization_guide) {
1325         deps += [ "//components/optimization_guide/internal:optimization_guide_internal" ]
1326       }
1327
1328       foreach(helper_params, chrome_mac_helpers) {
1329         deps += [ ":chrome_helper_app_${helper_params[0]}" ]
1330       }
1331     }
1332
1333     action("chrome_dsym_archive") {
1334       script = "//chrome/tools/build/mac/archive_symbols.py"
1335
1336       # These are the dSYMs that will be archived. The sources list must be
1337       # the target outputs that correspond to the dSYMs (since a dSYM is a
1338       # directory it cannot be listed as a source file). The targets that
1339       # generate both the dSYM and binary image are listed in deps.
1340       _dsyms = [
1341         "$root_out_dir/$chrome_framework_name.dSYM",
1342         "$root_out_dir/$chrome_product_full_name.dSYM",
1343         "$root_out_dir/chrome_crashpad_handler.dSYM",
1344         "$root_out_dir/libEGL.dylib.dSYM",
1345         "$root_out_dir/libGLESv2.dylib.dSYM",
1346         "$root_out_dir/libvk_swiftshader.dylib.dSYM",
1347       ]
1348       if (build_with_internal_optimization_guide) {
1349         _dsyms += [ "$root_out_dir/liboptimization_guide_internal.dylib.dSYM" ]
1350       }
1351
1352       deps = [
1353         ":chrome_app",
1354         ":chrome_framework",
1355         "//components/crash/core/app:chrome_crashpad_handler",
1356         "//third_party/angle:libEGL",
1357         "//third_party/angle:libGLESv2",
1358         "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan",
1359       ]
1360       if (build_with_internal_optimization_guide) {
1361         deps += [ "//components/optimization_guide/internal:optimization_guide_internal" ]
1362       }
1363
1364       foreach(helper_params, chrome_mac_helpers) {
1365         _dsyms +=
1366             [ "$root_out_dir/${chrome_helper_name}${helper_params[2]}.dSYM" ]
1367         deps += [ ":chrome_helper_app_${helper_params[0]}" ]
1368       }
1369
1370       sources = _chrome_symbols_sources
1371
1372       _output = "$root_out_dir/$chrome_product_full_name.dSYM.tar.bz2"
1373
1374       outputs = [ _output ]
1375
1376       args = [ rebase_path(_output, root_out_dir) ] +
1377              rebase_path(_dsyms, root_out_dir)
1378     }
1379   } else {
1380     group("chrome_dump_syms") {
1381     }
1382     group("chrome_dsym_archive") {
1383     }
1384   }
1385 }
1386
1387 group("dependencies") {
1388   public_deps = [
1389     "//build:branding_buildflags",
1390     "//build:chromeos_buildflags",
1391     "//chrome/browser",
1392     "//chrome/browser/policy:path_parser",
1393     "//chrome/child",
1394     "//chrome/common",
1395     "//chrome/gpu",
1396     "//chrome/renderer",
1397     "//chrome/utility",
1398     "//components/about_ui",
1399     "//components/gwp_asan/buildflags",
1400     "//components/heap_profiling/in_process",
1401     "//components/power_scheduler",
1402     "//components/services/heap_profiling",
1403     "//components/startup_metric_utils/browser",
1404     "//components/sync",
1405     "//components/upload_list:upload_list",
1406     "//content/public/child",
1407     "//pdf",
1408     "//services/tracing/public/cpp",
1409     "//third_party/blink/public:blink_devtools_frontend_resources",
1410     "//third_party/blink/public:blink_devtools_inspector_resources",
1411     "//v8:v8_headers",
1412   ]
1413
1414   if (enable_ppapi) {
1415     public_deps += [ "//ppapi/host" ]
1416   }
1417
1418   if (enable_basic_printing) {
1419     public_deps += [ "//printing" ]
1420   }
1421
1422   if (enable_gwp_asan) {
1423     public_deps += [ "//components/gwp_asan/client" ]
1424   }
1425
1426   if (enable_nacl) {
1427     public_deps += [
1428       "//components/nacl/browser",
1429       "//components/nacl/renderer/plugin:nacl_trusted_plugin",
1430     ]
1431   }
1432
1433   if (is_chromeos) {
1434     public_deps += [ "//chromeos/dbus/constants" ]
1435   }
1436
1437   if (is_chromeos_lacros) {
1438     public_deps += [
1439       "//chromeos/lacros",
1440       "//chromeos/lacros/dbus",
1441     ]
1442   }
1443
1444   if (is_chromeos_ash) {
1445     public_deps += [
1446       "//ash/constants",
1447       "//chrome/browser/ash",
1448       "//chromeos",
1449       "//chromeos/ash/components/memory",
1450     ]
1451   }
1452
1453   if (!is_fuchsia) {
1454     public_deps += [ "//components/crash/core/app" ]
1455   }
1456 }
1457
1458 if (is_win) {
1459   process_version_rc_template("chrome_exe_version") {
1460     sources = [ "app/chrome_exe.ver" ]
1461     output = "$target_gen_dir/chrome_exe_version.rc"
1462   }
1463
1464   process_version_rc_template("chrome_dll_version") {
1465     sources = [ "app/chrome_dll.ver" ]
1466     output = "$target_gen_dir/chrome_dll_version.rc"
1467   }
1468
1469   # This manifest matches what GYP produced. It may not even be necessary.
1470   windows_manifest("chrome_dll_manifest") {
1471     sources = [
1472       as_invoker_manifest,
1473       common_controls_manifest,
1474     ]
1475   }
1476
1477   process_version_rc_template("nacl64_exe_version") {
1478     sources = [ "app/nacl64_exe.ver" ]
1479     output = "$target_gen_dir/nacl64_exe_version.rc"
1480   }
1481
1482   process_version_rc_template("other_version") {
1483     sources = [ "app/other.ver" ]
1484     output = "$target_gen_dir/other_version.rc"
1485   }
1486 }
1487
1488 copy("visual_elements_resources") {
1489   sources = [
1490     "//chrome/app/theme/$branding_path_component/win/tiles/Logo.png",
1491     "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogo.png",
1492     "app/visual_elements_resources/chrome.VisualElementsManifest.xml",
1493   ]
1494
1495   if (is_chrome_branded) {
1496     sources += [
1497       "//chrome/app/theme/$branding_path_component/win/tiles/LogoBeta.png",
1498       "//chrome/app/theme/$branding_path_component/win/tiles/LogoCanary.png",
1499       "//chrome/app/theme/$branding_path_component/win/tiles/LogoDev.png",
1500       "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogoBeta.png",
1501       "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogoCanary.png",
1502       "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogoDev.png",
1503     ]
1504   }
1505
1506   outputs = [ "$root_out_dir/{{source_file_part}}" ]
1507 }
1508
1509 group("resources") {
1510   public_deps = [
1511     "//chrome/browser:resources",
1512     "//chrome/common:resources",
1513     "//chrome/renderer:resources",
1514   ]
1515 }
1516
1517 group("extra_resources") {
1518   # Deps should be same as those in chrome_extra_paks() within chrome_paks.gni.
1519   public_deps = [
1520     "//chrome/browser/resources:resources",
1521     "//components/autofill/core/browser:autofill_address_rewriter_resources",
1522   ]
1523 }
1524
1525 if (is_chrome_branded && !is_android) {
1526   if (!is_mac) {
1527     _preinstalled_apps_target_type = "copy"
1528   } else {
1529     _preinstalled_apps_target_type = "bundle_data"
1530   }
1531
1532   target(_preinstalled_apps_target_type, "preinstalled_apps") {
1533     visibility = [ ":packed_resources" ]
1534     if (is_mac) {
1535       visibility += [
1536         ":chrome_framework",
1537         ":chrome_framework_shared_library",
1538       ]
1539     }
1540
1541     sources = [ "browser/resources/default_apps/external_extensions.json" ]
1542
1543     if (!is_mac) {
1544       outputs = [ "$root_out_dir/default_apps/{{source_file_part}}" ]
1545     } else {
1546       outputs = [ "{{bundle_contents_dir}}/Default Apps/{{source_file_part}}" ]
1547     }
1548
1549     # Force anybody that depends on this to get the default apps as data files.
1550     data = process_file_template(sources, outputs)
1551   }
1552 }
1553
1554 if (!is_android) {
1555   chrome_paks("packed_resources") {
1556     if (is_mac) {
1557       output_dir = "$root_gen_dir/repack"
1558       copy_data_to_bundle = true
1559     } else {
1560       output_dir = root_out_dir
1561       mark_as_data = true
1562     }
1563
1564     if (enable_resource_allowlist_generation) {
1565       repack_allowlist = _chrome_resource_allowlist
1566       deps = [ ":resource_allowlist" ]
1567     }
1568
1569     if (is_chrome_branded && !is_mac) {
1570       public_deps = [ ":preinstalled_apps" ]
1571     }
1572
1573     files_to_hash = [
1574       "resources.pak",
1575       "chrome_100_percent.pak",
1576     ]
1577     if (enable_hidpi) {
1578       files_to_hash += [ "chrome_200_percent.pak" ]
1579     }
1580   }
1581 }
1582
1583 repack("unit_tests_pak") {
1584   testonly = true
1585   sources = [ "$root_gen_dir/chrome/chrome_test_resources.pak" ]
1586   output = "$root_out_dir/unit_tests.pak"
1587   deps = [ "//chrome/test/data:chrome_test_resources" ]
1588 }
1589
1590 repack("browser_tests_pak") {
1591   testonly = true
1592   sources = [ "$root_gen_dir/chrome/webui_test_resources.pak" ]
1593   output = "$root_out_dir/browser_tests.pak"
1594   deps = [ "//chrome/test/data:webui_test_resources" ]
1595   if (!is_android) {
1596     sources += [ "$root_gen_dir/chrome/webui_generated_test_resources.pak" ]
1597     deps += [ "//chrome/test/data/webui:resources" ]
1598   }
1599 }
1600
1601 group("strings") {
1602   public_deps = [
1603     "//chrome/app:chromium_strings",
1604     "//chrome/app:generated_resources",
1605     "//chrome/app:google_chrome_strings",
1606     "//chrome/app/resources:locale_settings",
1607   ]
1608 }
1609
1610 if (is_android) {
1611   java_cpp_enum("partner_bookmarks_javagen") {
1612     sources = [ "browser/android/bookmarks/partner_bookmarks_reader.h" ]
1613   }
1614
1615   java_cpp_enum("offline_pages_enum_javagen") {
1616     sources = [ "browser/offline_pages/offline_page_utils.h" ]
1617   }
1618
1619   java_cpp_enum("download_enum_javagen") {
1620     sources = [
1621       "browser/download/android/download_open_source.h",
1622       "browser/download/download_dialog_types.h",
1623       "browser/download/download_prompt_status.h",
1624     ]
1625   }
1626
1627   java_cpp_enum("instant_apps_reasons_enum_javagen") {
1628     sources = [ "browser/android/instantapps/instant_apps_settings.cc" ]
1629   }
1630
1631   java_cpp_enum("supervised_user_url_filter_enum_javagen") {
1632     sources = [ "browser/supervised_user/supervised_user_url_filter.h" ]
1633   }
1634
1635   java_cpp_enum("context_menu_image_format_enum_javagen") {
1636     sources =
1637         [ "browser/android/context_menu/context_menu_native_delegate_impl.h" ]
1638   }
1639
1640   source_set("chrome_android_core") {
1641     sources = [
1642       "app/android/chrome_jni_onload.cc",
1643       "app/android/chrome_jni_onload.h",
1644       "app/android/chrome_main_delegate_android.cc",
1645       "app/android/chrome_main_delegate_android.h",
1646       "app/chrome_main_delegate.cc",
1647       "app/chrome_main_delegate.h",
1648     ]
1649
1650     libs = [
1651       "android",
1652       "jnigraphics",
1653     ]
1654
1655     public_deps = [
1656       "//chrome/browser",
1657       "//chrome/utility",
1658     ]
1659
1660     deps = [
1661       ":dependencies",
1662       "//chrome/browser/ui",
1663       "//chrome/child",
1664       "//chrome/common",
1665       "//chrome/common/profiler",
1666       "//chrome/gpu",
1667       "//chrome/renderer",
1668       "//components/gwp_asan/buildflags",
1669       "//components/heap_profiling/in_process",
1670       "//components/minidump_uploader",
1671       "//components/safe_browsing:buildflags",
1672       "//components/safe_browsing/android:safe_browsing_api_handler",
1673       "//components/safe_browsing/android:safe_browsing_mobile",
1674       "//components/services/heap_profiling",
1675       "//content/public/app",
1676     ]
1677
1678     # Explicit dependency required for JNI registration to be able to
1679     # find the native side functions.
1680     if (is_android && is_component_build) {
1681       deps += [
1682         "//components/viz/service",
1683         "//device/gamepad",
1684         "//ui/events/devices",
1685       ]
1686     }
1687
1688     if (is_android) {
1689       deps += [
1690         "//chrome/browser/flags:flags_android",
1691         "//components/crash/android:crash_android",
1692       ]
1693     }
1694
1695     if (is_chromeos_ash) {
1696       public_deps += [ "//ui/lottie" ]
1697     }
1698
1699     if (enable_vr) {
1700       deps += [ "//third_party/gvr-android-sdk:gvr_shim" ]
1701     }
1702
1703     if (enable_gwp_asan) {
1704       deps += [ "//components/gwp_asan/client" ]
1705     }
1706   }
1707 }
1708
1709 # Android also supports this, but uses
1710 # //chrome/android:${_variant}_resource_allowlist.
1711 if (is_win && enable_resource_allowlist_generation) {
1712   generate_resource_allowlist("resource_allowlist") {
1713     deps = [ ":chrome_dll" ]
1714     inputs = [ "$root_out_dir/chrome.dll.pdb" ]
1715     output = _chrome_resource_allowlist
1716   }
1717 }
1718
1719 if (is_linux || is_chromeos || is_tizen) {
1720   if (is_official_build) {
1721     group("linux_symbols") {
1722       deps = [
1723         ":angle_egl_symbols",
1724         ":angle_gles_symbols",
1725         ":chrome_crashpad_symbols",
1726         ":chrome_symbols",
1727       ]
1728       if (is_linux) {
1729         deps += [ ":swiftshader_vk_symbols" ]
1730       }
1731       if (!is_chromeos && !is_tizen) {
1732         deps += [ ":angle_libvulkan_symbols" ]
1733       }
1734       if (build_with_internal_optimization_guide) {
1735         deps += [ ":optimization_guide_symbols" ]
1736       }
1737     }
1738     extract_symbols("chrome_symbols") {
1739       binary = "$root_out_dir/chrome"
1740
1741       if (current_cpu == "x86") {
1742         # GYP used "ia32" so keep that naming for back-compat.
1743         symbol_file = "$root_out_dir/chrome.breakpad.ia32"
1744       } else {
1745         symbol_file = "$root_out_dir/chrome.breakpad.$current_cpu"
1746       }
1747
1748       deps = [ ":chrome" ]
1749     }
1750     extract_symbols("chrome_crashpad_symbols") {
1751       binary = "$root_out_dir/chrome_crashpad_handler"
1752
1753       if (current_cpu == "x86") {
1754         # GYP used "ia32" so keep that naming for back-compat.
1755         symbol_file = "$root_out_dir/crashpad.breakpad.ia32"
1756       } else {
1757         symbol_file = "$root_out_dir/crashpad.breakpad.$current_cpu"
1758       }
1759
1760       deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
1761     }
1762     extract_symbols("swiftshader_vk_symbols") {
1763       binary = "$root_out_dir/libvk_swiftshader.so"
1764
1765       if (current_cpu == "x86") {
1766         # GYP used "ia32" so keep that naming for back-compat.
1767         symbol_file = "$root_out_dir/libvk_swiftshader.breakpad.ia32"
1768       } else {
1769         symbol_file = "$root_out_dir/libvk_swiftshader.breakpad.$current_cpu"
1770       }
1771
1772       deps = [ "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan" ]
1773     }
1774     extract_symbols("angle_egl_symbols") {
1775       binary = "$root_out_dir/libEGL.so"
1776
1777       if (current_cpu == "x86") {
1778         # GYP used "ia32" so keep that naming for back-compat.
1779         symbol_file = "$root_out_dir/angle_libegl.breakpad.ia32"
1780       } else {
1781         symbol_file = "$root_out_dir/angle_libegl.breakpad.$current_cpu"
1782       }
1783
1784       deps = [ "//third_party/angle:libEGL" ]
1785     }
1786     extract_symbols("angle_gles_symbols") {
1787       binary = "$root_out_dir/libGLESv2.so"
1788
1789       if (current_cpu == "x86") {
1790         # GYP used "ia32" so keep that naming for back-compat.
1791         symbol_file = "$root_out_dir/angle_libgles.breakpad.ia32"
1792       } else {
1793         symbol_file = "$root_out_dir/angle_libgles.breakpad.$current_cpu"
1794       }
1795
1796       deps = [ "//third_party/angle:libGLESv2" ]
1797     }
1798     if (!is_chromeos && !is_tizen) {
1799       extract_symbols("angle_libvulkan_symbols") {
1800         binary = "$root_out_dir/libvulkan.so.1"
1801
1802         if (current_cpu == "x86") {
1803           # GYP used "ia32" so keep that naming for back-compat.
1804           symbol_file = "$root_out_dir/angle_libvulkan.breakpad.ia32"
1805         } else {
1806           symbol_file = "$root_out_dir/angle_libvulkan.breakpad.$current_cpu"
1807         }
1808
1809         deps = [ "//third_party/vulkan-deps/vulkan-loader/src:libvulkan" ]
1810       }
1811     }
1812     if (build_with_internal_optimization_guide) {
1813       extract_symbols("optimization_guide_symbols") {
1814         binary = "$root_out_dir/liboptimization_guide_internal.so"
1815         if (current_cpu == "x86") {
1816           # GYP used "ia32" so keep that naming for back-compat.
1817           symbol_file =
1818               "$root_out_dir/optimization_guide_internal.breakpad.ia32"
1819         } else {
1820           symbol_file =
1821               "$root_out_dir/optimization_guide_internal.breakpad.$current_cpu"
1822         }
1823
1824         deps = [ "//components/optimization_guide/internal:optimization_guide_internal" ]
1825       }
1826     }
1827   }
1828
1829   # Copies some scripts and resources that are used for desktop integration.
1830   copy("xdg_mime") {
1831     sources = [
1832       "//chrome/tools/build/linux/chrome-wrapper",
1833       "//third_party/xdg-utils/scripts/xdg-mime",
1834       "//third_party/xdg-utils/scripts/xdg-settings",
1835     ]
1836     if (is_linux) {
1837       sources +=
1838           [ "//chrome/app/theme/$branding_path_component/product_logo_48.png" ]
1839     } else {
1840       sources += [
1841         "//chrome/app/theme/$branding_path_component/linux/product_logo_48.png",
1842       ]
1843     }
1844     outputs = [ "$root_out_dir/{{source_file_part}}" ]
1845   }
1846 }
1847
1848 if (is_chromeos_lacros && is_official_build) {
1849   # This will strip chrome binary and produce chrome.debug with symbols.
1850   strip_binary("strip_chrome_binary") {
1851     binary_input = "$root_out_dir/chrome"
1852     symbol_output = "$root_out_dir/chrome.debug"
1853     stripped_binary_output = "$root_out_dir/chrome.stripped"
1854     deps = [ ":chrome" ]
1855   }
1856 }