From 81025b74dae793344d752118d09567b6976ec172 Mon Sep 17 00:00:00 2001 From: Alexander David Frick Date: Sat, 30 Apr 2022 01:14:42 -0500 Subject: [PATCH] Add rpath patch --- chrome/BUILD.gn | 1846 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1846 insertions(+) create mode 100644 chrome/BUILD.gn diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn new file mode 100644 index 00000000..7aa35946 --- /dev/null +++ b/chrome/BUILD.gn @@ -0,0 +1,1846 @@ +# Copyright 2014 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/chrome_build.gni") +import("//build/config/chromeos/ui_mode.gni") +import("//build/config/compiler/compiler.gni") +import("//build/config/compiler/pgo/pgo.gni") +import("//build/config/features.gni") +import("//build/config/locales.gni") +import("//build/config/python.gni") +import("//build/config/sanitizers/sanitizers.gni") +import("//build/config/ui.gni") +import("//build/config/win/console_app.gni") +import("//build/config/win/manifest.gni") +import("//build/toolchain/toolchain.gni") +import("//chrome/chrome_paks.gni") +import("//chrome/common/features.gni") +import("//chrome/process_version_rc_template.gni") +import("//components/exo/buildflags.gni") +import("//components/gwp_asan/buildflags/buildflags.gni") +import("//components/nacl/features.gni") +import("//components/optimization_guide/features.gni") +import("//extensions/buildflags/buildflags.gni") +import("//media/media_options.gni") +import("//ppapi/buildflags/buildflags.gni") +import("//third_party/blink/public/public_features.gni") +import("//third_party/widevine/cdm/widevine.gni") +import("//tools/resources/generate_resource_allowlist.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") +import("//ui/gl/features.gni") +import("//v8/gni/v8.gni") + +if (is_android) { + import("//build/config/android/rules.gni") +} else if (is_linux || is_chromeos) { + import("//build/linux/extract_symbols.gni") + import("//build/linux/strip_binary.gni") +} else if (is_mac) { + import("//build/apple/compile_entitlements.gni") + import("//build/apple/compile_plist.gni") + import("//build/apple/tweak_info_plist.gni") + import("//build/compiled_action.gni") + import("//build/config/apple/symbols.gni") + import("//build/config/mac/mac_sdk.gni") + import("//build/config/mac/rules.gni") + import("//build/util/branding.gni") + import("//build/util/version.gni") + import("//chrome/browser/buildflags.gni") + import("//chrome/updater/branding.gni") + import("//content/public/app/mac_helpers.gni") + import("//media/cdm/library_cdm/cdm_paths.gni") + import("//third_party/icu/config.gni") +} + +declare_args() { + # Indicates whether keystone registration framework should be enabled (see + # action("keystone_registration_framework") below). There are some tests + # where we'd like for it to be disabled. (https://crbug.com/909080) + enable_keystone_registration_framework = true +} + +assert(!is_ios, "Chromium/iOS shouldn't use anything in //chrome") + +if (is_win && enable_resource_allowlist_generation) { + _chrome_resource_allowlist = "$target_gen_dir/chrome_resource_allowlist.txt" +} + +if (is_win) { + action("reorder_imports") { + script = "//build/win/reorder-imports.py" + + # See comment in chrome_dll.gypi in the hardlink_to_output + # target for why this cannot be 'initial' like the DLL. + inputs = [ "$root_out_dir/initialexe/chrome.exe" ] + outputs = [ + "$root_out_dir/chrome.exe", + "$root_out_dir/chrome.exe.pdb", + ] + args = [ + "-i", + rebase_path("$root_out_dir/initialexe", root_build_dir), + "-o", + rebase_path("$root_out_dir", root_build_dir), + "-a", + current_cpu, + ] + deps = [ ":chrome_initial" ] + } +} + +# This does not currently work. See crbug.com/1311822. +# This target exists above chrome and it's main components in the dependency +# tree as a central place to put assert_no_deps annotations. Since this depends +# on Chrome and the main DLLs it uses, it will transitively assert that those +# targets also have no deps on disallowed things. +group("assert_no_deps") { + deps = [] + + if (is_android) { + deps += [ "//chrome/android:chrome_public_apk" ] + } else { + deps += [ ":chrome" ] + } + + if (is_win) { + deps += [ ":chrome_dll" ] + } + + # This should not pull in installer strings. This is will bloat the binary + # for no reason and is easy to mess up. See the comment at the top of + # //chrome/installer/util/BUILD.gn. + assert_no_deps = [ "//chrome/installer/util:strings" ] +} + +if (!is_android && !is_mac) { + group("chrome") { + public_deps = [ ":chrome_initial" ] + data_deps = [ ":chrome_initial" ] + + # Do not add any more deps or data_deps to group("chrome"). + # Because chrome_initial sets its output name to "chrome", running commands + # such as `ninja chrome` causes chrome_initial to be built instead. All + # deps and data_deps should be added to the chrome_initial target instead. + # Targets added here can only be built by explicitly using //chrome:chrome. + # Windows-only deps are OK because chrome_initial uses initialexe/chrome as + # the output name for that platform. + # See crbug.com/1146571. + if (is_win) { + public_deps += [ ":reorder_imports" ] + data_deps += [ ":reorder_imports" ] + } + } + + executable("chrome_initial") { + configs -= [ "//build/config/compiler:thinlto_optimize_default" ] + configs += [ "//build/config/compiler:thinlto_optimize_max" ] + if (is_win) { + output_name = "initialexe/chrome" + } else { + output_name = "chrome" + } + + # Because the sources list varies so significantly per-platform, generally + # each platform lists its own files rather than relying on filtering or + # removing unused files. + sources = [ "app/chrome_exe_resource.h" ] + defines = [] + public_deps = [] + deps = [ + "//build:chromeos_buildflags", + "//printing/buildflags", + ] + data = [ "$root_out_dir/resources.pak" ] + data_deps = [] + + if (is_chromeos_ash) { + data_deps += [ "//sandbox/linux:chrome_sandbox" ] + deps += [ "//components/exo/wayland:weston_test_stub" ] + } + + if (also_build_lacros_chrome_for_architecture != "") { + data_deps += [ "//chrome:chrome(//build/toolchain/cros:lacros_clang)" ] + } + + if (is_win) { + sources += [ + "app/chrome_exe.rc", + "app/chrome_exe_main_win.cc", + "app/main_dll_loader_win.cc", + "app/main_dll_loader_win.h", + "common/crash_keys.cc", + "common/crash_keys.h", + ] + + deps += [ + ":chrome_dll", + ":chrome_exe_version", + ":copy_first_run", + ":packed_resources_integrity", + ":visual_elements_resources", + "//base", + "//build:branding_buildflags", + "//chrome/app:chrome_exe_main_exports", + "//chrome/app/version_assembly:chrome_exe_manifest", + "//chrome/browser:active_use_util", + "//chrome/browser:chrome_process_finder", + "//chrome/browser/policy:path_parser", + "//chrome/chrome_elf", + "//chrome/common:constants", + "//chrome/install_static:install_static_util", + "//chrome/install_static:secondary_module", + "//chrome/installer/util:constants", + "//chrome/installer/util:did_run_support", + "//components/browser_watcher:browser_watcher_client", + "//components/crash/core/app", + "//components/crash/core/app:run_as_crashpad_handler", + "//components/crash/core/common", + "//components/flags_ui:switches", + "//content:sandbox_helper_win", + "//content/public/common:static_switches", + "//crypto", + "//gpu/command_buffer/service", + "//sandbox", + "//sandbox/policy", + "//sandbox/policy/mojom", + "//third_party/breakpad:breakpad_handler", + "//third_party/breakpad:breakpad_sender", + "//third_party/crashpad/crashpad/util", + "//ui/gl", + ] + data_deps = [ + "//chrome/app/version_assembly:version_assembly_manifest", + "//chrome/browser/web_applications/chrome_pwa_launcher", + "//chrome/chrome_proxy", + "//chrome/elevation_service", + "//chrome/notification_helper", + ] + + defines += [ "CHROME_EXE_MAIN" ] + + if (win_console_app) { + defines += [ "WIN_CONSOLE_APP" ] + } else { + # Set /SUBSYSTEM:WINDOWS for chrome.exe itself, unless a console build + # has been requested. + configs -= [ "//build/config/win:console" ] + configs += [ "//build/config/win:windowed" ] + } + + configs += [ + "//build/config/win:delayloads", + "//build/config/win:delayloads_not_for_child_dll", + ] + + if (current_cpu == "x86") { + # Set the initial stack size to 0.5MiB, instead of the 1.5MiB needed by + # Chrome's main thread. This saves significant memory on threads (like + # those in the Windows thread pool, and others) whose stack size we can + # only control through this setting. Because Chrome's main thread needs + # a minimum 1.5 MiB stack, the main thread (in 32-bit builds only) uses + # fibers to switch to a 1.5 MiB stack before running any other code. + ldflags = [ "/STACK:0x80000" ] + } else { + # Increase the initial stack size. The default is 1MB, this is 8MB. + ldflags = [ "/STACK:0x800000" ] + } + } else if (use_aura) { + # Non-Windows aura entrypoint. + sources += [ "app/chrome_exe_main_aura.cc" ] + } + + if (is_linux || is_chromeos || is_fuchsia) { + sources += [ + "app/chrome_dll_resource.h", + "app/chrome_main.cc", + "app/chrome_main_delegate.cc", + "app/chrome_main_delegate.h", + ] + + deps += [ + # On Linux, link the dependencies (libraries) that make up actual + # Chromium functionality directly into the executable. + ":dependencies", + + # For configuring PartitionAlloc + "//base/allocator:buildflags", + + # For the sampling profiler. + "//chrome/common/profiler", + + # Needed to use the master_preferences functions + "//chrome/installer/util:with_no_strings", + "//content/public/app", + + # For headless mode. + "//headless:headless_shell_lib", + ] + + public_deps = [ "//chrome/common:buildflags" ] + + if (!is_fuchsia) { + public_deps += [ + ":xdg_mime", # Needs to be public for installer to consume files. + ] + + data_deps += [ "//components/crash/core/app:chrome_crashpad_handler" ] + } + + ldflags = [] + + # On Chrome OS builds (for both ash-chrome and lacros-chrome), put + # priority to the library in the installed directory. + # This will avoid conflicting of exposed symbols. + if (is_chromeos_device) { + ldflags += [ "-L" + rebase_path(root_out_dir) ] + } + + # Chrome OS debug builds for arm need to pass --long-plt to the linker. + # See https://bugs.chromium.org/p/chromium/issues/detail?id=583532 + if (is_chromeos_ash && is_debug && target_cpu == "arm") { + ldflags += [ "-Wl,--long-plt" ] + } + + if ((is_linux || is_chromeos_lacros) && !is_component_build && + !using_sanitizer) { + version_script = "//build/linux/chrome.map" + inputs = [ version_script ] + ldflags += [ "-Wl,--version-script=" + + rebase_path(version_script, root_build_dir) ] + } + + if (is_chromeos_ash) { + public_deps += [ "//ui/lottie" ] + } + + if (is_chromeos_lacros) { + deps += [ + "//chromeos/crosapi/mojom", + "//chromeos/startup", + ] + } + + configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] + } + + if (is_chromeos_ash || is_win) { + data_deps += [ "//mojo/core:shared_library" ] + } + + if (is_chromeos_ash) { + data_deps += [ "//mojo/core:shared_libraries_for_arc" ] + if (is_chromeos_device) { + configs += [ "//build/config/chromeos:print_orderfile" ] + configs += [ "//build/config/compiler:chrome_orderfile_config" ] + } + } + + # These files are used by the installer so we need a public dep. + public_deps += [ ":packed_resources" ] + + # The step's output are needed at runtime, so we also need a data_dep. + data_deps += [ ":packed_resources" ] + + # ChromeOS by design is safe to have rpath=$ORIGIN. This simplifies shared + # library usage. + if (is_chromeos_ash && !is_component_build) { + configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] + } + + if (is_chromeos_lacros && is_chromeos_device) { + configs += [ "//build/lacros:optional_shared_libgcc" ] + } + + data_deps += [ + "//chrome/browser/resources/media/mei_preload:component", + "//third_party/widevine/cdm", + ] + } +} # !is_android && !is_mac + +if (is_win) { + shared_library("chrome_dll") { + configs += [ "//build/config/compiler:wexit_time_destructors" ] + configs -= [ "//build/config/compiler:thinlto_optimize_default" ] + configs += [ "//build/config/compiler:thinlto_optimize_max" ] + defines = [] + + sources = [ + "//base/win/dllmain.cc", + "app/chrome_main.cc", + "app/chrome_main_delegate.cc", + "app/chrome_main_delegate.h", + ] + + output_name = "chrome" + + deps = [ + ":chrome_dll_manifest", + ":chrome_dll_version", + ":dependencies", + "//base/allocator:buildflags", + "//chrome/app:chrome_dll_resources", + "//chrome/app:command_ids", + "//chrome/app/theme:chrome_unscaled_resources", + "//chrome/chrome_elf", + "//chrome/common:buildflags", + "//chrome/common/profiler", + "//chrome/install_static:install_static_util", + "//chrome/install_static:secondary_module", + "//components/browser_watcher:stability_client", + "//components/crash/core/app", + "//components/policy:generated", + "//content/app/resources", + "//content/public/app", + "//crypto", + "//headless:headless_renderer", + "//headless:headless_shell_browser_lib", + "//net:net_resources", + "//ppapi/buildflags", + "//sandbox/win:sandbox", + "//third_party/cld_3/src/src:cld_3", + "//third_party/wtl", + "//ui/views", + ] + + configs += [ "//build/config/win:delayloads" ] + + if (use_aura) { + deps += [ "//ui/compositor" ] + } + } + + copy("copy_first_run") { + sources = [ "app/FirstRun" ] + outputs = [ "$root_out_dir/First Run" ] + } +} else if (is_mac) { + chrome_helper_name = chrome_product_full_name + " Helper" + chrome_framework_name = chrome_product_full_name + " Framework" + chrome_framework_version = chrome_version_full + + verify_dynamic_libraries = !is_component_build && !is_asan + if (host_os == "mac") { + objdump_path = mac_bin_path + } else { + objdump_path = rebase_path("$clang_base_path/bin/", root_build_dir) + } + + group("chrome") { + deps = [ ":chrome_app" ] + + data_deps = [ ":chrome_app" ] + + if (verify_dynamic_libraries) { + deps += [ ":verify_libraries_chrome_app" ] + } + + if (is_chrome_branded && is_official_build) { + deps += [ + ":chrome_dsym_archive", + ":chrome_dump_syms", + ] + } + } + + tweak_info_plist("chrome_app_plist") { + info_plist = "app/app-Info.plist" + args = [ + "--breakpad=0", + "--scm=1", + "--bundle_id=$chrome_mac_bundle_id", + ] + if (is_chrome_branded) { + args += [ "--keystone=1" ] + if (current_cpu == "arm64") { + args += [ "--keystone-base-tag=arm64" ] + } + } else { + args += [ "--keystone=0" ] + } + if (enable_chromium_updater) { + args += [ "--privileged_helper_id=$privileged_helper_name" ] + } + } + + mac_app_bundle("chrome_app") { + output_name = chrome_product_full_name + + info_plist_target = ":chrome_app_plist" + extra_substitutions = [ + "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id", + "CHROMIUM_SHORT_NAME=$chrome_product_short_name", + "CHROMIUM_CREATOR=$chrome_mac_creator_code", + ] + + sources = [ "app/chrome_exe_main_mac.cc" ] + + extra_configs = [ "//build/config/compiler:wexit_time_destructors" ] + + deps = [ + ":chrome_app_strings_bundle_data", + ":chrome_resources", + ":chrome_versioned_bundle_data", + "//base/allocator:early_zone_registration_mac", + "//build:branding_buildflags", + "//chrome/common:buildflags", + "//chrome/common:version_header", + ] + + if (enable_stripping) { + # At link time, preserve the global symbols specified in the .exports + # file. All other global symbols will be marked as private. The default + # //build/config/mac:strip_all config will then remove the remaining + # local and debug symbols. + ldflags = [ "-Wl,-exported_symbols_list," + + rebase_path("app/app.exports", root_build_dir) ] + } + + if (is_component_build) { + # In a component build, the framework is directly linked to the + # executable because dlopen() and loading all the dependent dylibs + # is time-consuming, see https://crbug.com/1197495. + deps += [ ":chrome_framework+link" ] + ldflags = [ "-Wl,-rpath,@executable_path/../Frameworks" ] + + # The Framework is packaged inside the .app bundle. But when using the + # component build, all the dependent shared libraries of :chrome_dll are + # not packaged within the framework. This data_deps line makes all of + # those dependent libraries runtime dependencies of the .app bundle. + # This is a bit of a hack, since GN deliberately terminates its search + # for runtime_deps at create_bundle nodes (https://crbug.com/1010347). + data_deps = [ ":chrome_framework" ] + } + + if (enable_chromium_updater) { + deps += [ ":chromium_updater_privileged_helper" ] + } + } + + if (verify_dynamic_libraries) { + action("verify_libraries_chrome_app") { + script = "//chrome/tools/build/mac/verify_dynamic_libraries.py" + inputs = [ "${root_out_dir}/${chrome_product_full_name}.app/Contents/MacOS/${chrome_product_full_name}" ] + outputs = [ "$target_out_dir/run_$target_name.stamp" ] + args = [ + "--stamp", + rebase_path(outputs[0], root_out_dir), + "-B", + objdump_path, + "--image", + rebase_path(inputs[0], root_out_dir), + "--allow", + "/usr/lib/libSystem.B.dylib", + ] + deps = [ ":chrome_app" ] + } + } + + compiled_action("chrome_app_strings") { + tool = "//chrome/tools/build/mac:infoplist_strings_util" + + inputs = [] + + outputs = [] + + foreach(locale, platform_pak_locales) { + if (is_chrome_branded) { + _strings_file = "google_chrome_strings" + } else { + _strings_file = "chromium_strings" + } + + inputs += [ "$root_gen_dir/chrome/${_strings_file}_${locale}.pak" ] + } + + foreach(locale, locales_as_apple_outputs) { + outputs += [ + "$target_gen_dir/app_infoplist_strings/$locale.lproj/InfoPlist.strings", + ] + } + + args = + [ + "-b", + "${branding_path_component}_strings", + "-v", + chrome_version_full, + "-g", + rebase_path("$root_gen_dir/chrome", root_build_dir), + "-o", + rebase_path("$target_gen_dir/app_infoplist_strings", root_build_dir), + "-t", + "main", + ] + platform_pak_locales + + if (is_chrome_branded) { + deps = [ "//chrome/app:google_chrome_strings" ] + } else { + deps = [ "//chrome/app:chromium_strings" ] + } + } + + foreach(locale, locales_as_apple_outputs) { + bundle_data("chrome_app_strings_${locale}_bundle_data") { + sources = [ + "$target_gen_dir/app_infoplist_strings/$locale.lproj/InfoPlist.strings", + ] + outputs = + [ "{{bundle_resources_dir}}/$locale.lproj/{{source_file_part}}" ] + public_deps = [ ":chrome_app_strings" ] + } + } + group("chrome_app_strings_bundle_data") { + public_deps = [] + foreach(locale, locales_as_apple_outputs) { + public_deps += [ ":chrome_app_strings_${locale}_bundle_data" ] + } + } + + bundle_data("chrome_app_icon") { + sources = [ "app/theme/$branding_path_component/mac/app.icns" ] + outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ] + } + + bundle_data("chrome_resources") { + sources = [ + "$root_out_dir/$chrome_mac_bundle_id.manifest", + "app/theme/$branding_path_component/mac/document.icns", + "browser/ui/cocoa/applescript/scripting.sdef", + ] + outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ] + public_deps = [ + ":chrome_app_icon", + ":chrome_app_strings", + "//components/policy:chrome_manifest_bundle", + ] + } + + bundle_data("chrome_versioned_bundle_data") { + sources = [ "$root_out_dir/$chrome_framework_name.framework" ] + outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ] + public_deps = [ + # Before bundling the versioned app components, delete any existing + # versions. + ":clean_up_old_versions", + + # verify_chrome_framework_order depends on :chrome_framework and, for + # non-component builds, will ensure the export symbol table is correct. + ":verify_chrome_framework_order", + ] + + if (enable_widevine_cdm_host_verification) { + # The :chrome_framework_widevine_signature target copies into the + # :chrome_framework bundle. But because the signing file depends on the + # framework itself, that would cause a cyclical dependency. Instead, + # this dependency directly copies the file into the framework's + # resources directory. + public_deps += [ ":chrome_framework_widevine_signature" ] + } + } + + if (enable_chromium_updater) { + bundle_data("chromium_updater_privileged_helper") { + sources = [ "$root_out_dir/$privileged_helper_name" ] + outputs = [ + "{{bundle_contents_dir}}/Library/LaunchServices/{{source_file_part}}", + ] + + public_deps = [ "//chrome/updater/mac:privileged_helper" ] + } + } + + action("clean_up_old_versions") { + script = "//chrome/tools/build/mac/clean_up_old_versions.py" + + _stamp_file = "$root_gen_dir/run_$target_name.stamp" + + outputs = [ _stamp_file ] + + _versions_dir = "$root_out_dir/$chrome_product_full_name.app/Contents/Frameworks/$chrome_framework_name.framework/Versions" + + args = [ + "--versions-dir", + rebase_path(_versions_dir, root_build_dir), + "--stamp", + rebase_path(_stamp_file, root_build_dir), + "--keep", + chrome_version_full, + "--keep", + "Current", + ] + } + + tweak_info_plist("chrome_helper_plist") { + info_plist = "app/helper-Info.plist" + args = [ + "--breakpad=0", + "--keystone=0", + "--scm=0", + ] + } + + compile_entitlements("entitlements") { + entitlements_templates = [ "app/app-entitlements.plist" ] + if (is_chrome_branded) { + # These entitlements are bound to the official Google Chrome signing + # certificate and will not necessarily work in any other build. + entitlements_templates += [ "app/app-entitlements-chrome.plist" ] + } + output_name = "$target_gen_dir/app-entitlements.plist" + substitutions = [ + "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id", + "CHROMIUM_TEAM_ID=$chrome_mac_team_id", + ] + visibility = [ "//chrome/installer/mac:copies" ] + } + + template("chrome_helper_app") { + mac_app_bundle(target_name) { + assert(defined(invoker.helper_name_suffix)) + assert(defined(invoker.helper_bundle_id_suffix)) + + output_name = chrome_helper_name + invoker.helper_name_suffix + + if (defined(invoker.info_plist_target)) { + info_plist_target = invoker.info_plist_target + } else { + info_plist_target = ":chrome_helper_plist" + } + + extra_substitutions = [ + "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id", + "CHROMIUM_SHORT_NAME=$chrome_product_short_name", + "CHROMIUM_HELPER_SUFFIX=${invoker.helper_name_suffix}", + "CHROMIUM_HELPER_BUNDLE_ID_SUFFIX=${invoker.helper_bundle_id_suffix}", + ] + + sources = [ "app/chrome_exe_main_mac.cc" ] + + extra_configs = [ "//build/config/compiler:wexit_time_destructors" ] + + defines = [ "HELPER_EXECUTABLE" ] + + deps = [ + "//base/allocator:early_zone_registration_mac", + "//build:branding_buildflags", + "//chrome/common:version_header", + "//sandbox/mac:seatbelt", + ] + + if (defined(invoker.deps)) { + deps += invoker.deps + } + + ldflags = [] + + if (is_component_build) { + # In a component build, the framework is directly linked to the + # executable because dlopen() and loading all the dependent dylibs + # is time-consuming, see https://crbug.com/1197495. + deps += [ ":chrome_framework+link_nested" ] + + ldflags += [ + # The helper is in Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/X/Helpers/Chromium Helper.app/Contents/MacOS + # so set rpath up to the base. + "-Wl,-rpath,@loader_path/../../../../../../../../../..", + + # ... and up to Contents/Frameworks. + "-Wl,-rpath,@executable_path/../../../../../../..", + ] + } + + if (enable_stripping) { + # At link time, preserve the global symbols specified in the .exports + # file. All other global symbols will be marked as private. The default + # //build/config/mac:strip_all config will then remove the remaining + # local and debug symbols. + ldflags += [ "-Wl,-exported_symbols_list," + + rebase_path("app/app.exports", root_build_dir) ] + } + } + } + + # The following *_helper_params are added to the ones provided by //content + # listed in content_mac_helpers (see //content/public/app/mac_helpers.gni). + # These allow //chrome to add custom helper apps in addition to the ones + # provided by //content. The params here have the same form as the content + # helpers and are defined as a tuple of these elements: + # target name - A short name to be used when defining the target for that + # helper variant. + # bundle ID suffix - A string fragment to append to the CFBundleIdentifier of + # the helper. + # app name suffix - A string fragment to append to the outer bundle name as + # well as the inner executable. This should be reflected in + # the target's output_name. + + # Helper app to display alert notifications. This is necessary as an app can + # only display either banner or alert style notifications and the main app + # will display banners. + alert_helper_params = [ + "alerts", + ".alerts", + " (Alerts)", + ] + + # Merge all helper apps needed by //content and //chrome. + chrome_mac_helpers = content_mac_helpers + [ alert_helper_params ] + + # Create all helper apps required by //content. + foreach(helper_params, content_mac_helpers) { + chrome_helper_app("chrome_helper_app_${helper_params[0]}") { + helper_name_suffix = helper_params[2] + helper_bundle_id_suffix = helper_params[1] + } + } + + # Create app for the alert helper manually here as we want to modify the plist + # to set the alert style and add the app icon to its resources. + tweak_info_plist("chrome_helper_app_alerts_plist") { + deps = [ ":chrome_helper_plist" ] + info_plists = get_target_outputs(":chrome_helper_plist") + + [ "app/helper-alerts-Info.plist" ] + } + + # Create and bundle an InfoPlist.strings for the alert helper app. + # TODO(crbug.com/1182393): Disambiguate and localize alert helper app name. + compile_plist("chrome_helper_app_alerts_plist_strings") { + format = "binary1" + plist_templates = [ "app/helper-alerts-InfoPlist.strings" ] + substitutions = [ "CHROMIUM_FULL_NAME=$chrome_product_full_name" ] + output_name = "$target_gen_dir/helper_alerts_infoplist_strings/base.lproj/InfoPlist.strings" + } + bundle_data("chrome_helper_app_alerts_resources") { + sources = get_target_outputs(":chrome_helper_app_alerts_plist_strings") + outputs = [ "{{bundle_resources_dir}}/base.lproj/{{source_file_part}}" ] + public_deps = [ ":chrome_helper_app_alerts_plist_strings" ] + } + + chrome_helper_app("chrome_helper_app_${alert_helper_params[0]}") { + helper_name_suffix = alert_helper_params[2] + helper_bundle_id_suffix = alert_helper_params[1] + info_plist_target = ":chrome_helper_app_alerts_plist" + deps = [ + ":chrome_app_icon", + ":chrome_helper_app_alerts_resources", + ] + } + + if (verify_dynamic_libraries) { + foreach(helper_params, chrome_mac_helpers) { + _helper_target = helper_params[0] + _helper_bundle_id = helper_params[1] + _helper_suffix = helper_params[2] + + action("verify_libraries_chrome_helper_app_${_helper_target}") { + script = "//chrome/tools/build/mac/verify_dynamic_libraries.py" + inputs = [ "${root_out_dir}/${chrome_helper_name}${_helper_suffix}.app/Contents/MacOS/${chrome_helper_name}${_helper_suffix}" ] + outputs = [ "$target_out_dir/run_$target_name.stamp" ] + args = [ + "--stamp", + rebase_path(outputs[0], root_out_dir), + "-B", + objdump_path, + "--image", + rebase_path(inputs[0], root_out_dir), + + # Do not --allow more libraries here without consulting with the + # security team (security-dev@chromium.org). + "--allow", + "/usr/lib/libsandbox.1.dylib", + "--allow", + "/usr/lib/libSystem.B.dylib", + ] + deps = [ ":chrome_helper_app_${_helper_target}" ] + } + } + } + + bundle_data("chrome_framework_helpers") { + sources = [ + "$root_out_dir/app_mode_loader", + "$root_out_dir/chrome_crashpad_handler", + ] + + outputs = [ "{{bundle_contents_dir}}/Helpers/{{source_file_part}}" ] + + public_deps = [ + "//chrome/app_shim:app_mode_loader", + "//components/crash/core/app:chrome_crashpad_handler", + ] + + foreach(helper_params, chrome_mac_helpers) { + sources += + [ "$root_out_dir/${chrome_helper_name}${helper_params[2]}.app" ] + public_deps += [ ":chrome_helper_app_${helper_params[0]}" ] + if (verify_dynamic_libraries) { + public_deps += + [ ":verify_libraries_chrome_helper_app_${helper_params[0]}" ] + } + } + + if (enable_chromium_updater) { + # A stable updater from CIPD is bundled with official builds only. For + # local builds, a locally built updater will be bundled into the app. + # TODO(crbug.com/1134642): Add ChromiumUpdater app to CIPD for use in + # official builds. + sources += [ "$root_out_dir/${updater_product_full_name}.app" ] + + public_deps += [ + "//chrome/updater/mac:browser_install_script", + "//chrome/updater/mac:updater_bundle", + "//chrome/updater/mac:updater_install_script", + ] + } + } + + bundle_data("chrome_framework_resources") { + sources = [ + # This image is used to badge the lock icon in the + # authentication dialogs, such as those used for installation + # from disk image and Keystone promotion (if so enabled). It + # needs to exist as a file on disk and not just something in a + # resource bundle because that's the interface that + # Authorization Services uses. Also, Authorization Services + # can't deal with .icns files. + "app/theme/default_100_percent/$branding_path_component/product_logo_32.png", + "browser/mac/install.sh", + ] + + outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ] + + public_deps = [ + ":packed_resources", + "//chrome/app_shim:app_mode_loader_plist_bundle_data", + ] + + if (is_chrome_branded) { + sources += [ + "browser/mac/keystone_promote_postflight.sh", + "browser/mac/keystone_promote_preflight.sh", + ] + } + + if (icu_use_data_file) { + sources += [ "$root_out_dir/icudtl.dat" ] + public_deps += [ "//third_party/icu:icudata" ] + } + + if (v8_use_external_startup_data) { + public_deps += [ "//v8" ] + if (use_v8_context_snapshot) { + sources += [ "$root_out_dir/$v8_context_snapshot_filename" ] + public_deps += [ "//tools/v8_context_snapshot" ] + } else { + sources += [ "$root_out_dir/snapshot_blob.bin" ] + } + } + } + + if (enable_nacl) { + bundle_data("chrome_framework_plugins") { + sources = [] + outputs = + [ "{{bundle_contents_dir}}/Internet Plug-Ins/{{source_file_part}}" ] + public_deps = [] + + if (enable_nacl) { + if (current_cpu == "x86") { + sources += [ "$root_out_dir/nacl_irt_x86_32.nexe" ] + } else if (current_cpu == "x64") { + sources += [ "$root_out_dir/nacl_irt_x86_64.nexe" ] + } + public_deps += [ "//ppapi/native_client:irt" ] + } + } + } else { + group("chrome_framework_plugins") { + } + } + + # EGL on MacOS ships with official chrome + bundle_egl_libraries = use_egl + + if (bundle_egl_libraries) { + # Add the ANGLE .dylibs in the MODULE_DIR of Chromium.app + bundle_data("angle_binaries") { + sources = [ + "$root_out_dir/egl_intermediates/libEGL.dylib", + "$root_out_dir/egl_intermediates/libGLESv2.dylib", + ] + outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ] + public_deps = [ "//ui/gl:angle_library_copy" ] + } + + # Add the SwiftShader .dylibs in the MODULE_DIR of Chromium.app + bundle_data("swiftshader_binaries") { + sources = [ + "$root_out_dir/vk_intermediates/libvk_swiftshader.dylib", + "$root_out_dir/vk_intermediates/vk_swiftshader_icd.json", + ] + outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ] + public_deps = [ "//ui/gl:swiftshader_vk_library_copy" ] + } + } + + group("angle_library") { + if (bundle_egl_libraries) { + deps = [ ":angle_binaries" ] + } + } + + group("swiftshader_library") { + if (bundle_egl_libraries) { + deps = [ ":swiftshader_binaries" ] + } + } + + if (bundle_widevine_cdm) { + bundle_data("widevine_cdm_library_binaries") { + sources = [ "$root_out_dir/$widevine_cdm_path/libwidevinecdm.dylib" ] + if (enable_widevine_cdm_host_verification) { + sources += + [ "$root_out_dir/$widevine_cdm_path/libwidevinecdm.dylib.sig" ] + } + outputs = [ "{{bundle_contents_dir}}/Libraries/$widevine_cdm_path/{{source_file_part}}" ] + public_deps = [ "//third_party/widevine/cdm" ] + } + + bundle_data("widevine_cdm_library_manifest_and_license_files") { + sources = [ + "$root_out_dir/WidevineCdm/LICENSE", + "$root_out_dir/WidevineCdm/manifest.json", + ] + outputs = [ + "{{bundle_contents_dir}}/Libraries/WidevineCdm/{{source_file_part}}", + ] + public_deps = [ "//third_party/widevine/cdm" ] + } + } + + group("widevine_cdm_library") { + if (bundle_widevine_cdm) { + deps = [ + ":widevine_cdm_library_binaries", + ":widevine_cdm_library_manifest_and_license_files", + ] + } + } + + if (enable_widevine_cdm_host_verification) { + widevine_sign_file("sign_chrome_framework_for_widevine") { + file = "$root_out_dir/$chrome_framework_name.framework/Versions/$chrome_framework_version/$chrome_framework_name" + flags = 1 + signature_file = "$root_out_dir/$chrome_framework_name.sig" + deps = [ ":chrome_framework" ] + } + + copy("chrome_framework_widevine_signature") { + deps = [ ":sign_chrome_framework_for_widevine" ] + + sources = [ "$root_out_dir/$chrome_framework_name.sig" ] + + outputs = [ "$root_out_dir/$chrome_framework_name.framework/Resources/{{source_file_part}}" ] + } + } + + if (is_chrome_branded && enable_keystone_registration_framework) { + bundle_data("keystone_registration_framework") { + sources = [ "//third_party/googlemac/Releases/Keystone/KeystoneRegistration.framework" ] + + outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ] + } + } else { + group("keystone_registration_framework") { + } + } + + if (build_with_internal_optimization_guide) { + # Add the optimization guide .dylib in the MODULE_DIR of Chromium.app + bundle_data("optimization_guide_library") { + sources = [ + "$root_out_dir/og_intermediates/liboptimization_guide_internal.dylib", + ] + outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ] + public_deps = [ "//components/optimization_guide/core:optimization_guide_internal_library_copy" ] + } + } else { + group("optimization_guide_library") { + } + } + + tweak_info_plist("chrome_framework_plist") { + info_plist = "app/framework-Info.plist" + args = [ + "--breakpad=0", + "--keystone=0", + "--scm=1", + "--branding", + chrome_product_short_name, + ] + } + + # On Mac, speed up the component build by not re-bundling the framework + # every time it changes. Instead, place all the sources and their deps in + # a library that the bundled framework links (and re-exports). That way + # only the library needs to be re-linked when it changes. + if (is_component_build) { + _dll_target_type = "shared_library" + } else { + _dll_target_type = "source_set" + } + target(_dll_target_type, "chrome_dll") { + visibility = [ + ":chrome_framework", + ":chrome_framework_create_bundle", + ":chrome_framework_shared_library", + ] + + sources = [ + "app/chrome_crash_reporter_client.cc", + "app/chrome_crash_reporter_client.h", + "app/chrome_crash_reporter_client_mac.mm", + "app/chrome_dll_resource.h", + "app/chrome_main.cc", + "app/chrome_main_delegate.cc", + "app/chrome_main_delegate.h", + "app/chrome_main_mac.h", + "app/chrome_main_mac.mm", + ] + + deps = [ + ":dependencies", + "//base/allocator:buildflags", + "//build:chromeos_buildflags", + "//chrome/app:command_ids", + "//chrome/app:notification_metrics", + "//chrome/common:buildflags", + "//chrome/common/profiler", + "//components/crash/core/app", + "//components/policy:generated", + "//content/public/app", + "//headless:headless_shell_lib", + "//third_party/cld_3/src/src:cld_3", + ] + + if (is_component_build) { + frameworks = [ "Carbon.framework" ] + } + + ldflags = [ + "-Wl,-order_file", + "-Wl," + rebase_path("app/framework.order", root_build_dir), + "-ObjC", + ] + + configs += [ "//build/config/compiler:wexit_time_destructors" ] + } + + mac_framework_bundle("chrome_framework") { + output_name = chrome_framework_name + + framework_version = chrome_framework_version + framework_contents = [ + "Helpers", + "Libraries", + "Resources", + ] + + if (is_chrome_branded) { + framework_contents += [ "Default Apps" ] + if (enable_keystone_registration_framework) { + # For KeystoneRegistration.framework. + framework_contents += [ "Frameworks" ] + } + } + + if (enable_nacl) { + framework_contents += [ "Internet Plug-Ins" ] + } + + configs += [ "//build/config/compiler:wexit_time_destructors" ] + configs -= [ "//build/config/compiler:thinlto_optimize_default" ] + configs += [ "//build/config/compiler:thinlto_optimize_max" ] + + info_plist_target = ":chrome_framework_plist" + extra_substitutions = [ + "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id", + "CHROMIUM_SHORT_NAME=$chrome_product_short_name", + ] + + public_deps = [ ":chrome_dll" ] + + bundle_deps = [ + ":angle_library", + ":chrome_framework_helpers", + ":chrome_framework_plugins", + ":chrome_framework_resources", + ":keystone_registration_framework", + ":optimization_guide_library", + ":swiftshader_library", + ":widevine_cdm_library", + "//chrome/browser/resources/media/mei_preload:component_bundle", + ] + + if (is_chrome_branded) { + bundle_deps += [ ":preinstalled_apps" ] + } + + ldflags = [ + "-compatibility_version", + chrome_dylib_version, + "-current_version", + chrome_dylib_version, + "-Wl,-order_file," + rebase_path("app/framework.order", root_build_dir), + ] + + if (!is_component_build) { + # Specify a sensible install_name for static builds. The library is + # dlopen()ed so this is not used to resolve the module. + ldflags += [ "-Wl,-install_name,@executable_path/../Frameworks/$chrome_framework_name.framework/Versions/$chrome_version_full/$chrome_framework_name" ] + } else { + # In the component build, both the :chrome_app and various + # :chrome_helper* targets directly link to the Framework target. Use + # @rpath-based loading so that the dylib ID does not have to be changed + # with install_name_tool. + ldflags += [ + "-Wl,-install_name,@rpath/$chrome_framework_name.framework/$chrome_framework_name", + "-Wl,-rpath,@loader_path/../../../../../..", + "-Wl,-reexport_library,libchrome_dll.dylib", + ] + + data_deps = [ ":chrome_dll" ] + } + } + + _framework_binary_path = "$root_out_dir/$chrome_framework_name.framework/Versions/$chrome_framework_version/$chrome_framework_name" + assert(_framework_binary_path != "", + "Ignore configuration-dependent unused variable warning") + + # TOOD(crbug/1163903#c8) - thakis@ look into why profile and coverage + # instrumentation adds these symbols in different orders + if (!is_component_build && chrome_pgo_phase != 1 && !using_sanitizer) { + action("verify_chrome_framework_order") { + script = "//chrome/tools/build/mac/verify_order.py" + stamp_file = "$target_out_dir/run_$target_name.stamp" + inputs = [ script ] + args = [ + "--stamp=" + rebase_path(stamp_file, root_out_dir), + "--binary=" + rebase_path(_framework_binary_path, root_out_dir), + "--symbol-file=" + rebase_path("app/framework.order", root_build_dir), + ] + if (host_os == "mac") { + args += [ "--nm-path=$mac_bin_path/nm" ] + } else { + args += [ "--nm-path=" + + rebase_path("$clang_base_path/bin/llvm-nm", root_build_dir) ] + } + outputs = [ stamp_file ] + public_deps = [ ":chrome_framework" ] + } + } else { + group("verify_chrome_framework_order") { + if (is_component_build) { + # In a component build, the framework is directly linked to the + # executable because dlopen() and loading all the dependent dylibs + # is time-consuming, see https://crbug.com/1197495. + public_deps = [ ":chrome_framework+link" ] + } else { + public_deps = [ ":chrome_framework" ] + } + } + } + + if (enable_dsyms && !is_component_build) { + # It is possible to run dump_syms on unstripped products without dSYMs, but + # doing so isn't logical and won't happen in practice. It's also pointless + # to run dump_syms or archive dSYMs in a component build, where all of the + # interesting symbols and debug info are tucked away in other libraries + # beyond the set explicitly listed here. + + # This list must be updated with the two targets' deps list below, and + # the list of _dsyms in :chrome_dsym_archive. + _chrome_symbols_sources = [ + "$root_out_dir/$chrome_product_full_name.app/Contents/MacOS/$chrome_product_full_name", + "$root_out_dir/chrome_crashpad_handler", + "$root_out_dir/libEGL.dylib", + "$root_out_dir/libGLESv2.dylib", + "$root_out_dir/libvk_swiftshader.dylib", + _framework_binary_path, + ] + if (build_with_internal_optimization_guide) { + _chrome_symbols_sources += + [ "$root_out_dir/liboptimization_guide_internal.dylib" ] + } + + foreach(helper_params, chrome_mac_helpers) { + _chrome_symbols_sources += [ "$root_out_dir/${chrome_helper_name}${helper_params[2]}.app/Contents/MacOS/${chrome_helper_name}${helper_params[2]}" ] + } + + action_foreach("chrome_dump_syms") { + script = "//build/redirect_stdout.py" + + sources = _chrome_symbols_sources + + outputs = + [ "$root_out_dir/{{source_file_part}}-$chrome_version_full.breakpad" ] + + dump_syms = "//third_party/breakpad:dump_syms($host_toolchain)" + args = rebase_path(outputs, root_build_dir) + [ + rebase_path(get_label_info(dump_syms, "root_out_dir") + "/" + + get_label_info(dump_syms, "name"), + root_build_dir), + "-g", + rebase_path( + "$root_out_dir/{{source_file_part}}.dSYM/Contents/Resources/DWARF/{{source_file_part}}", + root_build_dir), + "{{source}}", + ] + + deps = [ + ":chrome_app", + ":chrome_framework", + "//components/crash/core/app:chrome_crashpad_handler", + "//third_party/angle:libEGL", + "//third_party/angle:libGLESv2", + "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan", + dump_syms, + ] + if (build_with_internal_optimization_guide) { + deps += [ "//components/optimization_guide/internal:optimization_guide_internal" ] + } + + foreach(helper_params, chrome_mac_helpers) { + deps += [ ":chrome_helper_app_${helper_params[0]}" ] + } + } + + action("chrome_dsym_archive") { + script = "//chrome/tools/build/mac/archive_symbols.py" + + # These are the dSYMs that will be archived. The sources list must be + # the target outputs that correspond to the dSYMs (since a dSYM is a + # directory it cannot be listed as a source file). The targets that + # generate both the dSYM and binary image are listed in deps. + _dsyms = [ + "$root_out_dir/$chrome_framework_name.dSYM", + "$root_out_dir/$chrome_product_full_name.dSYM", + "$root_out_dir/chrome_crashpad_handler.dSYM", + "$root_out_dir/libEGL.dylib.dSYM", + "$root_out_dir/libGLESv2.dylib.dSYM", + "$root_out_dir/libvk_swiftshader.dylib.dSYM", + ] + if (build_with_internal_optimization_guide) { + _dsyms += [ "$root_out_dir/liboptimization_guide_internal.dylib.dSYM" ] + } + + deps = [ + ":chrome_app", + ":chrome_framework", + "//components/crash/core/app:chrome_crashpad_handler", + "//third_party/angle:libEGL", + "//third_party/angle:libGLESv2", + "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan", + ] + if (build_with_internal_optimization_guide) { + deps += [ "//components/optimization_guide/internal:optimization_guide_internal" ] + } + + foreach(helper_params, chrome_mac_helpers) { + _dsyms += + [ "$root_out_dir/${chrome_helper_name}${helper_params[2]}.dSYM" ] + deps += [ ":chrome_helper_app_${helper_params[0]}" ] + } + + sources = _chrome_symbols_sources + + _output = "$root_out_dir/$chrome_product_full_name.dSYM.tar.bz2" + + outputs = [ _output ] + + args = [ rebase_path(_output, root_out_dir) ] + + rebase_path(_dsyms, root_out_dir) + } + } else { + group("chrome_dump_syms") { + } + group("chrome_dsym_archive") { + } + } +} + +group("dependencies") { + public_deps = [ + "//build:branding_buildflags", + "//build:chromeos_buildflags", + "//chrome/browser", + "//chrome/browser/policy:path_parser", + "//chrome/child", + "//chrome/common", + "//chrome/gpu", + "//chrome/renderer", + "//chrome/utility", + "//components/gwp_asan/buildflags", + "//components/heap_profiling/in_process", + "//components/power_scheduler", + "//components/services/heap_profiling", + "//components/startup_metric_utils/browser", + "//components/sync", + "//components/upload_list:upload_list", + "//content/public/child", + "//pdf", + "//services/tracing/public/cpp", + "//third_party/blink/public:blink_devtools_frontend_resources", + "//third_party/blink/public:blink_devtools_inspector_resources", + "//v8:v8_headers", + ] + + if (enable_plugins) { + public_deps += [ "//ppapi/host" ] + } + + if (enable_basic_printing) { + public_deps += [ "//printing" ] + } + + if (enable_gwp_asan) { + public_deps += [ "//components/gwp_asan/client" ] + } + + if (enable_nacl) { + public_deps += [ + "//components/nacl/browser", + "//components/nacl/renderer/plugin:nacl_trusted_plugin", + ] + } + + if (is_chromeos) { + public_deps += [ "//chromeos/dbus/constants" ] + } + + if (is_chromeos_lacros) { + public_deps += [ + "//chromeos/lacros", + "//chromeos/lacros/dbus", + ] + } + + if (is_chromeos_ash) { + public_deps += [ + "//ash/constants", + "//chrome/browser/ash", + "//chromeos", + "//chromeos/memory", + ] + } + + if (!is_fuchsia) { + public_deps += [ "//components/crash/core/app" ] + } +} + +if (is_win) { + process_version_rc_template("chrome_exe_version") { + sources = [ "app/chrome_exe.ver" ] + output = "$target_gen_dir/chrome_exe_version.rc" + } + + process_version_rc_template("chrome_dll_version") { + sources = [ "app/chrome_dll.ver" ] + output = "$target_gen_dir/chrome_dll_version.rc" + } + + # This manifest matches what GYP produced. It may not even be necessary. + windows_manifest("chrome_dll_manifest") { + sources = [ + as_invoker_manifest, + common_controls_manifest, + ] + } + + process_version_rc_template("nacl64_exe_version") { + sources = [ "app/nacl64_exe.ver" ] + output = "$target_gen_dir/nacl64_exe_version.rc" + } + + process_version_rc_template("other_version") { + sources = [ "app/other.ver" ] + output = "$target_gen_dir/other_version.rc" + } +} + +copy("visual_elements_resources") { + sources = [ + "//chrome/app/theme/$branding_path_component/win/tiles/Logo.png", + "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogo.png", + "app/visual_elements_resources/chrome.VisualElementsManifest.xml", + ] + + if (is_chrome_branded) { + sources += [ + "//chrome/app/theme/$branding_path_component/win/tiles/LogoBeta.png", + "//chrome/app/theme/$branding_path_component/win/tiles/LogoCanary.png", + "//chrome/app/theme/$branding_path_component/win/tiles/LogoDev.png", + "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogoBeta.png", + "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogoCanary.png", + "//chrome/app/theme/$branding_path_component/win/tiles/SmallLogoDev.png", + ] + } + + outputs = [ "$root_out_dir/{{source_file_part}}" ] +} + +group("resources") { + public_deps = [ + "//chrome/browser:resources", + "//chrome/common:resources", + "//chrome/renderer:resources", + ] +} + +group("extra_resources") { + # Deps should be same as those in chrome_extra_paks() within chrome_paks.gni. + public_deps = [ + "//chrome/browser/resources:resources", + "//components/autofill/core/browser:autofill_address_rewriter_resources", + ] +} + +if (is_chrome_branded && !is_android) { + if (!is_mac) { + _preinstalled_apps_target_type = "copy" + } else { + _preinstalled_apps_target_type = "bundle_data" + } + + target(_preinstalled_apps_target_type, "preinstalled_apps") { + visibility = [ ":packed_resources" ] + if (is_mac) { + visibility += [ + ":chrome_framework", + ":chrome_framework_shared_library", + ] + } + + sources = [ "browser/resources/default_apps/external_extensions.json" ] + + if (!is_mac) { + outputs = [ "$root_out_dir/default_apps/{{source_file_part}}" ] + } else { + outputs = [ "{{bundle_contents_dir}}/Default Apps/{{source_file_part}}" ] + } + + # Force anybody that depends on this to get the default apps as data files. + data = process_file_template(sources, outputs) + } +} + +if (!is_android) { + chrome_paks("packed_resources") { + if (is_mac) { + output_dir = "$root_gen_dir/repack" + copy_data_to_bundle = true + } else { + output_dir = root_out_dir + mark_as_data = true + } + + if (enable_resource_allowlist_generation) { + repack_allowlist = _chrome_resource_allowlist + deps = [ ":resource_allowlist" ] + } + + if (is_chrome_branded && !is_mac) { + public_deps = [ ":preinstalled_apps" ] + } + + files_to_hash = [ + "resources.pak", + "chrome_100_percent.pak", + ] + if (enable_hidpi) { + files_to_hash += [ "chrome_200_percent.pak" ] + } + } +} + +repack("unit_tests_pak") { + sources = [ "$root_gen_dir/chrome/chrome_test_resources.pak" ] + output = "$root_out_dir/unit_tests.pak" + deps = [ "//chrome/test/data:chrome_test_resources" ] +} + +repack("browser_tests_pak") { + sources = [ "$root_gen_dir/chrome/webui_test_resources.pak" ] + output = "$root_out_dir/browser_tests.pak" + deps = [ "//chrome/test/data:webui_test_resources" ] + if (!is_android) { + sources += [ "$root_gen_dir/chrome/webui_generated_test_resources.pak" ] + deps += [ "//chrome/test/data/webui:resources" ] + } +} + +group("strings") { + public_deps = [ + "//chrome/app:chromium_strings", + "//chrome/app:generated_resources", + "//chrome/app:google_chrome_strings", + "//chrome/app/resources:locale_settings", + ] +} + +if (is_android) { + java_cpp_enum("assist_ranker_prediction_enum_javagen") { + sources = [ + "browser/android/contextualsearch/contextual_search_ranker_logger_impl.h", + ] + } + + java_cpp_enum("partner_bookmarks_javagen") { + sources = [ "browser/android/bookmarks/partner_bookmarks_reader.h" ] + } + + java_cpp_enum("quick_action_category_enum_javagen") { + sources = [ "browser/android/contextualsearch/resolved_search_term.h" ] + } + + java_cpp_enum("offline_pages_enum_javagen") { + sources = [ "browser/offline_pages/offline_page_utils.h" ] + } + + java_cpp_enum("download_enum_javagen") { + sources = [ + "browser/download/android/download_open_source.h", + "browser/download/download_dialog_types.h", + "browser/download/download_prompt_status.h", + ] + } + + java_cpp_enum("instant_apps_reasons_enum_javagen") { + sources = [ "browser/android/instantapps/instant_apps_settings.cc" ] + } + + java_cpp_enum("supervised_user_url_filter_enum_javagen") { + sources = [ "browser/supervised_user/supervised_user_url_filter.h" ] + } + + java_cpp_enum("context_menu_image_format_enum_javagen") { + sources = + [ "browser/android/context_menu/context_menu_native_delegate_impl.h" ] + } + + source_set("chrome_android_core") { + sources = [ + "app/android/chrome_jni_onload.cc", + "app/android/chrome_jni_onload.h", + "app/android/chrome_main_delegate_android.cc", + "app/android/chrome_main_delegate_android.h", + "app/chrome_main_delegate.cc", + "app/chrome_main_delegate.h", + ] + + libs = [ + "android", + "jnigraphics", + ] + + public_deps = [ + "//chrome/browser", + "//chrome/utility", + ] + + deps = [ + ":dependencies", + "//chrome/browser/ui", + "//chrome/child", + "//chrome/common", + "//chrome/common/profiler", + "//chrome/gpu", + "//chrome/renderer", + "//components/gwp_asan/buildflags", + "//components/heap_profiling/in_process", + "//components/minidump_uploader", + "//components/safe_browsing:buildflags", + "//components/safe_browsing/android:safe_browsing_api_handler", + "//components/safe_browsing/android:safe_browsing_mobile", + "//components/services/heap_profiling", + "//content/public/app", + ] + + # Explicit dependency required for JNI registration to be able to + # find the native side functions. + if (is_android && is_component_build) { + deps += [ + "//components/viz/service", + "//device/gamepad", + "//ui/events/devices", + ] + } + + if (is_android) { + deps += [ "//components/crash/android:crash_android" ] + } + + if (is_chromeos_ash) { + public_deps += [ "//ui/lottie" ] + } + + if (enable_vr) { + deps += [ "//third_party/gvr-android-sdk:gvr_shim" ] + } + + if (enable_gwp_asan) { + deps += [ "//components/gwp_asan/client" ] + } + } +} + +# Android also supports this, but uses +# //chrome/android:${_variant}_resource_allowlist. +if (is_win && enable_resource_allowlist_generation) { + generate_resource_allowlist("resource_allowlist") { + deps = [ ":chrome_dll" ] + inputs = [ "$root_out_dir/chrome.dll.pdb" ] + output = _chrome_resource_allowlist + } +} + +if (is_linux || is_chromeos) { + if (is_official_build) { + group("linux_symbols") { + deps = [ + ":angle_egl_symbols", + ":angle_gles_symbols", + ":chrome_crashpad_symbols", + ":chrome_symbols", + ] + if (is_linux) { + deps += [ ":swiftshader_vk_symbols" ] + } + if (!is_chromeos) { + deps += [ ":angle_libvulkan_symbols" ] + } + if (build_with_internal_optimization_guide) { + deps += [ ":optimization_guide_symbols" ] + } + } + extract_symbols("chrome_symbols") { + binary = "$root_out_dir/chrome" + + if (current_cpu == "x86") { + # GYP used "ia32" so keep that naming for back-compat. + symbol_file = "$root_out_dir/chrome.breakpad.ia32" + } else { + symbol_file = "$root_out_dir/chrome.breakpad.$current_cpu" + } + + deps = [ ":chrome" ] + } + extract_symbols("chrome_crashpad_symbols") { + binary = "$root_out_dir/chrome_crashpad_handler" + + if (current_cpu == "x86") { + # GYP used "ia32" so keep that naming for back-compat. + symbol_file = "$root_out_dir/crashpad.breakpad.ia32" + } else { + symbol_file = "$root_out_dir/crashpad.breakpad.$current_cpu" + } + + deps = [ "//components/crash/core/app:chrome_crashpad_handler" ] + } + extract_symbols("swiftshader_vk_symbols") { + binary = "$root_out_dir/libvk_swiftshader.so" + + if (current_cpu == "x86") { + # GYP used "ia32" so keep that naming for back-compat. + symbol_file = "$root_out_dir/libvk_swiftshader.breakpad.ia32" + } else { + symbol_file = "$root_out_dir/libvk_swiftshader.breakpad.$current_cpu" + } + + deps = [ "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan" ] + } + extract_symbols("angle_egl_symbols") { + binary = "$root_out_dir/libEGL.so" + + if (current_cpu == "x86") { + # GYP used "ia32" so keep that naming for back-compat. + symbol_file = "$root_out_dir/angle_libegl.breakpad.ia32" + } else { + symbol_file = "$root_out_dir/angle_libegl.breakpad.$current_cpu" + } + + deps = [ "//third_party/angle:libEGL" ] + } + extract_symbols("angle_gles_symbols") { + binary = "$root_out_dir/libGLESv2.so" + + if (current_cpu == "x86") { + # GYP used "ia32" so keep that naming for back-compat. + symbol_file = "$root_out_dir/angle_libgles.breakpad.ia32" + } else { + symbol_file = "$root_out_dir/angle_libgles.breakpad.$current_cpu" + } + + deps = [ "//third_party/angle:libGLESv2" ] + } + if (!is_chromeos) { + extract_symbols("angle_libvulkan_symbols") { + binary = "$root_out_dir/libvulkan.so.1" + + if (current_cpu == "x86") { + # GYP used "ia32" so keep that naming for back-compat. + symbol_file = "$root_out_dir/angle_libvulkan.breakpad.ia32" + } else { + symbol_file = "$root_out_dir/angle_libvulkan.breakpad.$current_cpu" + } + + deps = [ "//third_party/vulkan-deps/vulkan-loader/src:libvulkan" ] + } + } + if (build_with_internal_optimization_guide) { + extract_symbols("optimization_guide_symbols") { + binary = "$root_out_dir/liboptimization_guide_internal.so" + if (current_cpu == "x86") { + # GYP used "ia32" so keep that naming for back-compat. + symbol_file = + "$root_out_dir/optimization_guide_internal.breakpad.ia32" + } else { + symbol_file = + "$root_out_dir/optimization_guide_internal.breakpad.$current_cpu" + } + + deps = [ "//components/optimization_guide/internal:optimization_guide_internal" ] + } + } + } + + # Copies some scripts and resources that are used for desktop integration. + copy("xdg_mime") { + sources = [ + "//chrome/tools/build/linux/chrome-wrapper", + "//third_party/xdg-utils/scripts/xdg-mime", + "//third_party/xdg-utils/scripts/xdg-settings", + ] + if (is_linux) { + sources += + [ "//chrome/app/theme/$branding_path_component/product_logo_48.png" ] + } else { + sources += [ + "//chrome/app/theme/$branding_path_component/linux/product_logo_48.png", + ] + } + outputs = [ "$root_out_dir/{{source_file_part}}" ] + } +} + +if (is_chromeos_lacros && is_official_build) { + # This will strip chrome binary and produce chrome.debug with symbols. + strip_binary("strip_chrome_binary") { + binary_input = "$root_out_dir/chrome" + symbol_output = "$root_out_dir/chrome.debug" + stripped_binary_output = "$root_out_dir/chrome.stripped" + deps = [ ":chrome" ] + } +}