Skip to content

Commit

Permalink
[ios][mac] Prefer invoker extra_substitutions to template ones
Browse files Browse the repository at this point in the history
The plist substitutions are evaluated in order they are passed on
the command line. The substitutions passed by the invoker should
have priority over those defined in the template (otherwise there
would be no way to override the substitutions from a template).
This mean that if the same `key=value` is defined multiple time on
the command-line, the last pair will be used by the script.

To give the preference to the substitutions defined by the invoker,
do not use the `forward_variable_from(invoker, ...)`. Instead set
the value in the template, and if defined in the invoker, append
them.

Bug: 1257954
Change-Id: I19bed9a1424f6e7c0394fd437381fc2067c97ace
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211733
Reviewed-by: Olivier Robin <olivierrobin@chromium.org>
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#929648}
  • Loading branch information
sdefresne authored and Chromium LUCI CQ committed Oct 8, 2021
1 parent 1d86228 commit b544cac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
25 changes: 10 additions & 15 deletions build/config/ios/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,7 @@ template("ios_info_plist") {

apple_info_plist(target_name) {
format = "binary1"
extra_substitutions = []
if (defined(invoker.extra_substitutions)) {
extra_substitutions = invoker.extra_substitutions
}
extra_substitutions += [
extra_substitutions = [
"IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix",
"IOS_PLATFORM_BUILD=$ios_platform_build",
"IOS_PLATFORM_NAME=$ios_sdk_name",
Expand All @@ -550,6 +546,9 @@ template("ios_info_plist") {
"XCODE_BUILD=$xcode_build",
"XCODE_VERSION=$xcode_version",
]
if (defined(invoker.extra_substitutions)) {
extra_substitutions += invoker.extra_substitutions
}
plist_templates = [
"//build/config/ios/BuildInfo.plist",
_info_plist,
Expand Down Expand Up @@ -830,18 +829,16 @@ template("ios_app_bundle") {
ios_info_plist(_generate_info_plist) {
forward_variables_from(invoker,
[
"extra_substitutions",
"info_plist",
"info_plist_target",
])

executable_name = _output_name

if (!defined(extra_substitutions)) {
extra_substitutions = []
extra_substitutions = [ "BUNDLE_IDENTIFIER=$_bundle_identifier" ]
if (defined(invoker.extra_substitutions)) {
extra_substitutions += invoker.extra_substitutions
}

extra_substitutions += [ "BUNDLE_IDENTIFIER=$_bundle_identifier" ]
}

if (!is_fat_secondary_toolchain) {
Expand Down Expand Up @@ -1557,16 +1554,14 @@ template("ios_framework_bundle") {
executable_name = _output_name
forward_variables_from(invoker,
[
"extra_substitutions",
"info_plist",
"info_plist_target",
])

if (!defined(extra_substitutions)) {
extra_substitutions = []
extra_substitutions = [ "BUNDLE_IDENTIFIER=$_bundle_identifier" ]
if (defined(invoker.extra_substitutions)) {
extra_substitutions += invoker.extra_substitutions
}

extra_substitutions += [ "BUNDLE_IDENTIFIER=$_bundle_identifier" ]
}

bundle_data(_info_plist_bundle) {
Expand Down
9 changes: 4 additions & 5 deletions build/config/mac/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ template("mac_info_plist") {

apple_info_plist(target_name) {
format = "xml1"
extra_substitutions = []
if (defined(invoker.extra_substitutions)) {
extra_substitutions = invoker.extra_substitutions
}
extra_substitutions += [
extra_substitutions = [
"MAC_SDK_BUILD=$mac_sdk_version",
"MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version",
"MACOSX_DEPLOYMENT_TARGET=$mac_deployment_target",
"CHROMIUM_MIN_SYSTEM_VERSION=$mac_min_system_version",
"XCODE_BUILD=$xcode_build",
"XCODE_VERSION=$xcode_version",
]
if (defined(invoker.extra_substitutions)) {
extra_substitutions += invoker.extra_substitutions
}
plist_templates = [
"//build/config/mac/BuildInfo.plist",
_info_plist,
Expand Down
5 changes: 1 addition & 4 deletions ios/chrome/test/earl_grey2/chrome_ios_eg2_test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ template("chrome_ios_eg2_test_app_host") {
ios_application_icons_target,
]

if (!defined(extra_substitutions)) {
extra_substitutions = []
}
extra_substitutions += [
extra_substitutions = [
"CHROMIUM_BUNDLE_ID=$bundle_identifier",
"CHROMIUM_HANDOFF_ID=$chromium_handoff_id",
"CHROMIUM_SHORT_NAME=$target_name",
Expand Down

0 comments on commit b544cac

Please sign in to comment.