blob: 885bf6f7188c53c7f2e8b6d845888acecebe02ab [file] [log] [blame]
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/apple/compile_entitlements.gni")
import("//build/apple/tweak_info_plist.gni")
import("//build/config/apple/mobile_config.gni")
import("//build/config/ios/rules.gni")
import("//build/ios/extension_bundle_data.gni")
import("//ios/build/chrome_build.gni")
import("//ios/chrome/features.gni")
import("//ios/features.gni")
declare_args() {
# When true, modifies the chrome_app template to additionally build
# a framework with a single ChromeMain() entry point. This framework
# is not used or linked against, but can be uploaded as a build
# artifact.
ios_force_build_chrome_framework = false
}
# Template used to create a Chrome-like app bundle that depends on
# EarlyMallocZoneRegistration.
#
template("chrome_app") {
_target_name = target_name
if (ios_force_build_chrome_framework || use_blink) {
ios_framework_bundle("${_target_name}_framework") {
forward_variables_from(invoker,
[
"bundle_deps",
"deps",
"framework_dirs",
"frameworks",
"public_configs",
"public_deps",
"sources",
"testonly",
])
# Explicitly clobber configs inherited from `set_defaults(...)`, then
# add back `//build/config:shared_library_config` since this builds a
# shared library.
if (defined(invoker.configs)) {
configs = []
configs = invoker.configs + [ "//build/config:shared_library_config" ]
}
output_name = "${_target_name}_framework"
transparent = use_blink
# When variants are present, the ios_app_bundle rule has logic to copy
# bundle_deps from the first variant. Replicate that logic here as well.
if (!transparent) {
if (defined(invoker.variants) && invoker.variants != []) {
_variants = invoker.variants
_default_variant = _variants[0]
bundle_deps += _default_variant.bundle_deps
}
}
info_plist = "//ios/chrome/app/resources/EarlyPAFrameworkInfo.plist"
}
}
if (use_blink) {
template("browserkit_extension") {
_process_target = target_name
_outer_target = _target_name
tweak_info_plist("tweak_${_outer_target}_${_process_target}_plist") {
info_plist = "//content/app/ios/appex/${_process_target}.plist"
}
extension_bundle_data("${_outer_target}_${_process_target}_bundle") {
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
extension_dir = "Extensions"
extension_name = "${_outer_target}_${_process_target}.appex"
extension_target = ":${_outer_target}_${_process_target}"
}
compile_entitlements("${_outer_target}_${_process_target}_entitlements") {
substitutions = [ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix" ]
output_name = "$target_gen_dir/${target_name}.appex.entitlements"
entitlements_templates =
[ "//content/app/ios/appex/${_process_target}.appex.entitlements" ]
}
# We don't use ios_appex_bundle here because we don't want to mess with multiple
# toolkits as the core framework is built with the default toolkit.
ios_app_bundle("${_outer_target}_${_process_target}") {
forward_variables_from(invoker,
"*",
[
"defines",
"deps",
"framework_dirs",
"frameworks",
"public_deps",
"sources",
"target_name",
])
output_name = target_name
transparent = true
deps = [
":${_outer_target}_framework+link",
"//content/app/ios/appex:${_process_target}",
]
if (!defined(ldflags)) {
ldflags = []
}
ldflags += [
"-Wl,--ignore-auto-link-option=CoreAudioTypes",
"-Wl,-no_application_extension",
"-Wl,-rpath,@executable_path/../../Frameworks",
]
product_type = "com.apple.product-type.app-extension"
entitlements_target = ":${target_name}_entitlements"
info_plist_target = ":tweak_${target_name}_plist"
}
}
set_defaults("browserkit_extension") {
configs = [ "//build/config/ios:ios_extension_executable_flags" ]
}
browserkit_extension("gpu_process") {
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
bundle_identifier = "$ios_chromium_bundle_id.GPUProcessExtension"
}
browserkit_extension("network_process") {
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
bundle_identifier = "$ios_chromium_bundle_id.NetworkProcessExtension"
}
browserkit_extension("content_process") {
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
bundle_identifier = "$ios_chromium_bundle_id.ContentProcessExtension"
}
ios_app_bundle(_target_name) {
forward_variables_from(invoker,
"*",
[
"defines",
"deps",
"framework_dirs",
"frameworks",
"public_deps",
"sources",
])
configs = []
configs = default_executable_configs
deps = [
":${_target_name}_framework+link",
":${target_name}_content_process_bundle",
":${target_name}_gpu_process_bundle",
":${target_name}_network_process_bundle",
"//ios/chrome/app:app_trampoline",
"//ios/chrome/app:early_partition_alloc_framework+bundle",
"//ios/chrome/app:early_partition_alloc_framework+link",
]
bundle_deps += [
":${_target_name}_framework+bundle",
"//ios/chrome/app:early_partition_alloc_framework+bundle",
]
}
} else {
ios_app_bundle(_target_name) {
forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY)
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
deps += [
"//ios/chrome/app:app_trampoline",
"//ios/chrome/app:early_partition_alloc_framework+link",
]
bundle_deps +=
[ "//ios/chrome/app:early_partition_alloc_framework+bundle" ]
}
}
}