Skip to content

Optionally allow WriteTargetBuildSettings to use remote cache or RBE #3149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def _write_target_build_settings_test_impl(ctx):
params,
) = pbxproj_partials.write_target_build_settings(
actions = actions.mock,
allow_remote = ctx.attr.allow_remote,
apple_generate_dsym = ctx.attr.apple_generate_dsym,
certificate_name = ctx.attr.certificate_name,
colorize = ctx.attr.colorize,
Expand Down Expand Up @@ -167,6 +168,7 @@ write_target_build_settings_test = unittest.make(
# @unsorted-dict-items
attrs = {
# Inputs
"allow_remote": attr.bool(mandatory = True),
"apple_generate_dsym": attr.bool(mandatory = True),
"certificate_name": attr.string(),
"colorize": attr.bool(mandatory = True),
Expand Down Expand Up @@ -210,6 +212,7 @@ def write_target_build_settings_test_suite(name):
name,

# Inputs
allow_remote = False,
apple_generate_dsym = False,
certificate_name = None,
colorize = False,
Expand Down Expand Up @@ -241,6 +244,7 @@ def write_target_build_settings_test_suite(name):
name = name,

# Inputs
allow_remote = allow_remote,
apple_generate_dsym = apple_generate_dsym,
certificate_name = certificate_name,
colorize = colorize,
Expand Down
14 changes: 14 additions & 0 deletions xcodeproj/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ bool_flag(
visibility = ["//visibility:public"],
)

# `WriteTargetBuildSettings` is very fast, and there are potentially thousands
# of the action for a project, which results in caching overhead slowing down
# clean builds. So by default we disable remote cache/execution. This also
# prevents DDoSing the remote cache.
#
# Currently on Linux you need to enable this flag and use multi-platform RBE,
# since `WriteTargetBuildSettings` is precompiled for macOS. It might also be
# beneficial to enable this on CI to speed up project generation validation.
bool_flag(
name = "allow_remote_write_target_build_settings",
build_setting_default = False,
visibility = ["//visibility:public"],
)

string_flag(
name = "extra_common_flags",
build_setting_default = "",
Expand Down
15 changes: 8 additions & 7 deletions xcodeproj/internal/pbxproj_partials.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ def _write_swift_debug_settings(
def _write_target_build_settings(
*,
actions,
allow_remote,
apple_generate_dsym,
certificate_name = None,
colorize,
Expand All @@ -1100,6 +1101,8 @@ def _write_target_build_settings(

Args:
actions: `ctx.actions`.
allow_remote: A `bool` indicating whether to allow remote cache or
remote execution of the `WriteTargetBuildSettings` action.
apple_generate_dsym: `cpp_fragment.apple_generate_dsym`.
certificate_name: The name of the certificate to use for code signing.
colorize: A `bool` indicating whether to colorize the output.
Expand Down Expand Up @@ -1266,6 +1269,10 @@ def _write_target_build_settings(
# cxxParams
cxx_output_args.add(cxx_params)

execution_requirements = {}
if not allow_remote:
execution_requirements["no-remote"] = "1"

actions.run(
arguments = (
[args] + swift_args + [c_output_args] + conly_args +
Expand All @@ -1276,13 +1283,7 @@ def _write_target_build_settings(
outputs = outputs,
progress_message = "Generating %{output}",
mnemonic = "WriteTargetBuildSettings",
execution_requirements = {
# This action is very fast, and there are potentially thousands of
# this action for a project, which results in caching overhead
# slowing down clean builds. So, we disable remote cache/execution.
# This also prevents DDoSing the remote cache.
"no-remote": "1",
},
execution_requirements = execution_requirements,
)

return build_settings_output, debug_settings_output, params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def _process_incremental_library_target(
params_files,
) = pbxproj_partials.write_target_build_settings(
actions = actions,
allow_remote = (
ctx.attr._allow_remote_write_target_build_settings[BuildSettingInfo]
.value
),
apple_generate_dsym = ctx.fragments.cpp.apple_generate_dsym,
colorize = ctx.attr._colorize[BuildSettingInfo].value,
conly_args = args.conly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ def _process_focused_top_level_target(
params_files,
) = pbxproj_partials.write_target_build_settings(
actions = actions,
allow_remote = (
ctx.attr._allow_remote_write_target_build_settings[BuildSettingInfo]
.value
),
apple_generate_dsym = ctx.fragments.cpp.apple_generate_dsym,
certificate_name = provisioning_profile_props.certificate_name,
colorize = ctx.attr._colorize[BuildSettingInfo].value,
Expand Down Expand Up @@ -778,6 +782,10 @@ def _process_unfocused_top_level_target(
_,
) = pbxproj_partials.write_target_build_settings(
actions = actions,
allow_remote = (
ctx.attr._allow_remote_write_target_build_settings[BuildSettingInfo]
.value
),
apple_generate_dsym = False,
colorize = ctx.attr._colorize[BuildSettingInfo].value,
# FIXME: Should this be args.conly?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def _process_mixed_language_library_target(
params_files,
) = pbxproj_partials.write_target_build_settings(
actions = actions,
allow_remote = (
ctx.attr._allow_remote_write_target_build_settings[BuildSettingInfo]
.value
),
apple_generate_dsym = ctx.fragments.cpp.apple_generate_dsym,
colorize = ctx.attr._colorize[BuildSettingInfo].value,
conly_args = args.conly,
Expand Down
4 changes: 4 additions & 0 deletions xcodeproj/internal/xcodeproj_incremental_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def _xcodeproj_incremental_aspect_attrs(
generator_name,
unfocused_labels):
return {
"_allow_remote_write_target_build_settings": attr.label(
default = Label("//xcodeproj:color"),
providers = [BuildSettingInfo],
),
"_cc_compiler_params_processor": attr.label(
cfg = "exec",
default = Label(
Expand Down
Loading