Skip to content

Commit

Permalink
Update rules_apple and rules_swift versions (bazel-ios#493)
Browse files Browse the repository at this point in the history
* Update rules_apple and rules_swift versions
  • Loading branch information
luispadron authored and Yongjin Cho committed Nov 8, 2022
1 parent 174aef4 commit 1f4bddb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 40 deletions.
7 changes: 4 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ build --compilation_mode=dbg

# Use 'worker' strategy for swift compilation
build --strategy=SwiftCompile=worker
build --experimental_worker_allow_json_protocol

# This flips enable_global_index_store - see docs/index_while_building.md for a
# detailed summary
Expand All @@ -35,12 +36,12 @@ build --test_env=PATH=/usr/bin:/bin:/usr/sbin:/sbin
# auto-configured on an ARM64 host but is a flag for the moment. Example usage:

# Setup this config to build x86_64 as arm64 builds with ( --ios_multi_cpus=x86_64 )
common:bazel4_arm64_simulator_arm64_host --features apple.arm64_simulator_use_device_deps
common:bazel4_arm64_simulator_arm64_host --features apple.arm64_simulator_use_device_deps
common:bazel4_arm64_simulator_arm64_host --features bazel4.override_host_cpu_arm64
common:bazel4_arm64_simulator_arm64_host --features bazel4.override_simulator_cpu_arm64

# Similar to above but doesn't override the host CPU
common:bazel4_arm64_simulator_x86_64_host --features apple.arm64_simulator_use_device_deps
# Similar to above but doesn't override the host CPU
common:bazel4_arm64_simulator_x86_64_host --features apple.arm64_simulator_use_device_deps
common:bazel4_arm64_simulator_x86_64_host --features bazel4.override_simulator_cpu_arm64

# Broken on Intel + Bazel 5 so turnoff
Expand Down
52 changes: 28 additions & 24 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ load("@build_bazel_rules_apple//apple/internal:processor.bzl", "processor")
load("@build_bazel_rules_apple//apple/internal:resource_actions.bzl", "resource_actions")
load("@build_bazel_rules_apple//apple/internal:resources.bzl", "resources")
load("@build_bazel_rules_apple//apple/internal:rule_support.bzl", "rule_support")
load("@build_bazel_rules_apple//apple:providers.bzl", "AppleBundleInfo", "AppleSupportToolchainInfo", "IosFrameworkBundleInfo")
load("@build_bazel_rules_apple//apple/internal:apple_toolchains.bzl", "AppleMacToolsToolchainInfo", "AppleXPlatToolsToolchainInfo")
load("@build_bazel_rules_apple//apple/internal/utils:clang_rt_dylibs.bzl", "clang_rt_dylibs")
load("@build_bazel_rules_apple//apple:providers.bzl", "AppleBundleInfo", "IosFrameworkBundleInfo")
load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "swift_common")
load(
"@build_bazel_rules_apple//apple/internal/aspects:resource_aspect.bzl",
Expand Down Expand Up @@ -494,7 +496,7 @@ def _merge_root_infoplists(ctx):
bundle_name = ctx.attr.framework_name
current_apple_platform = transition_support.current_apple_platform(apple_fragment = ctx.fragments.apple, xcode_config = ctx.attr._xcode_config)
platform_type = str(current_apple_platform.platform.platform_type)
apple_toolchain_info = ctx.attr._toolchain[AppleSupportToolchainInfo]
apple_mac_toolchain_info = ctx.attr._toolchain[AppleMacToolsToolchainInfo]
rule_descriptor = rule_support.rule_descriptor(ctx)

resource_actions.merge_root_infoplists(
Expand All @@ -518,12 +520,11 @@ def _merge_root_infoplists(ctx):
objc_fragment = None,
platform_type_string = platform_type,
uses_swift = False,
xcode_path_wrapper = None,
xcode_version_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
disabled_features = [],
features = [],
),
resolved_plisttool = apple_toolchain_info.resolved_plisttool,
resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool,
rule_descriptor = rule_descriptor,
rule_label = ctx.label,
version = None,
Expand All @@ -545,7 +546,8 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
Currently, this doesn't include headers or other interface files.
"""
actions = ctx.actions
apple_toolchain_info = ctx.attr._toolchain[AppleSupportToolchainInfo]
apple_mac_toolchain_info = ctx.attr._toolchain[AppleMacToolsToolchainInfo]
apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo]
bin_root_path = ctx.bin_dir.path
bundle_id = ctx.attr.bundle_id
if not bundle_id:
Expand Down Expand Up @@ -591,7 +593,7 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
attr = ctx.attr,
res_attrs = ["infoplists"],
)
link_result = linking_support.register_linking_action(
link_result = linking_support.register_binary_linking_action(
ctx,
avoid_deps = avoid_deps,
entitlements = None,
Expand All @@ -600,7 +602,7 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
stamp = ctx.attr.stamp,
)
binary_artifact = link_result.binary
debug_outputs_provider = link_result.debug_outputs_provider
debug_outputs = linking_support.debug_outputs_by_architecture(link_result.outputs)

archive_for_embedding = outputs.archive_for_embedding(
actions = actions,
Expand Down Expand Up @@ -637,14 +639,14 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
partials.bitcode_symbols_partial(
actions = actions,
binary_artifact = binary_artifact,
debug_outputs_provider = debug_outputs_provider,
bitcode_symbol_maps = debug_outputs.bitcode_symbol_maps,
dependency_targets = dep_frameworks,
label_name = label.name,
platform_prerequisites = platform_prerequisites,
),
partials.codesigning_dossier_partial(
actions = actions,
apple_toolchain_info = apple_toolchain_info,
apple_mac_toolchain_info = apple_mac_toolchain_info,
bundle_extension = bundle_extension,
bundle_location = processor.location.framework,
bundle_name = bundle_name,
Expand All @@ -657,20 +659,22 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
),
partials.clang_rt_dylibs_partial(
actions = actions,
apple_toolchain_info = apple_toolchain_info,
apple_mac_toolchain_info = apple_mac_toolchain_info,
binary_artifact = binary_artifact,
features = features,
label_name = label.name,
platform_prerequisites = platform_prerequisites,
dylibs = clang_rt_dylibs.get_from_toolchain(ctx),
),
partials.debug_symbols_partial(
actions = actions,
bin_root_path = bin_root_path,
bundle_extension = bundle_extension,
bundle_name = bundle_name,
debug_dependencies = dep_frameworks,
debug_outputs_provider = debug_outputs_provider,
dsym_info_plist_template = apple_toolchain_info.dsym_info_plist_template,
dsym_binaries = debug_outputs.dsym_binaries,
linkmaps = debug_outputs.linkmaps,
dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template,
executable_name = executable_name,
platform_prerequisites = platform_prerequisites,
rule_label = label,
Expand All @@ -695,7 +699,7 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
),
partials.resources_partial(
actions = actions,
apple_toolchain_info = apple_toolchain_info,
apple_mac_toolchain_info = apple_mac_toolchain_info,
bundle_extension = bundle_extension,
bundle_id = bundle_id,
bundle_name = bundle_name,
Expand All @@ -714,7 +718,7 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
),
partials.swift_dylibs_partial(
actions = actions,
apple_toolchain_info = apple_toolchain_info,
apple_mac_toolchain_info = apple_mac_toolchain_info,
binary_artifact = binary_artifact,
dependency_targets = dep_frameworks,
label_name = label.name,
Expand All @@ -723,7 +727,7 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
partials.apple_symbols_file_partial(
actions = actions,
binary_artifact = binary_artifact,
debug_outputs_provider = debug_outputs_provider,
dsym_binaries = debug_outputs.dsym_binaries,
dependency_targets = dep_frameworks,
label_name = label.name,
include_symbols_in_bundle = False,
Expand All @@ -733,7 +737,7 @@ def _bundle_dynamic_framework(ctx, avoid_deps):

processor_result = processor.process(
actions = actions,
apple_toolchain_info = apple_toolchain_info,
apple_mac_toolchain_info = apple_mac_toolchain_info,
bundle_extension = bundle_extension,
bundle_name = bundle_name,
codesign_inputs = [],
Expand All @@ -744,7 +748,8 @@ def _bundle_dynamic_framework(ctx, avoid_deps):
partials = processor_partials,
platform_prerequisites = platform_prerequisites,
predeclared_outputs = predeclared_outputs,
process_and_sign_template = apple_toolchain_info.process_and_sign_template,
process_and_sign_template = apple_mac_toolchain_info.process_and_sign_template,
apple_xplat_toolchain_info = apple_xplat_toolchain_info,
provisioning_profile = provisioning_profile,
rule_descriptor = rule_descriptor,
rule_label = label,
Expand Down Expand Up @@ -1027,8 +1032,12 @@ the framework as a dependency.""",
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
),
"_toolchain": attr.label(
default = Label("@build_bazel_rules_apple//apple/internal:toolchain_support"),
providers = [[AppleSupportToolchainInfo]],
default = Label("@build_bazel_rules_apple//apple/internal:mac_tools_toolchain"),
providers = [[AppleMacToolsToolchainInfo]],
),
"_xplat_toolchain": attr.label(
default = Label("@build_bazel_rules_apple//apple/internal:xplat_tools_toolchain"),
providers = [[AppleXPlatToolsToolchainInfo]],
),
"platform_type": attr.string(
mandatory = False,
Expand All @@ -1047,11 +1056,6 @@ the framework as a dependency.""",
doc = "The bundle identifier of the framework. Currently unused.",
default = "",
),
"_xcode_path_wrapper": attr.label(
cfg = "exec",
executable = True,
default = Label("@build_bazel_apple_support//tools:xcode_path_wrapper"),
),
"_xcrunwrapper": attr.label(
cfg = "exec",
default = Label("@bazel_tools//tools/objc:xcrunwrapper"),
Expand Down
18 changes: 9 additions & 9 deletions rules/precompiled_apple_resource_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ load("@build_bazel_rules_apple//apple/internal:platform_support.bzl", "platform_
load("@build_bazel_rules_apple//apple/internal:resources.bzl", "resources")
load("@build_bazel_rules_apple//apple/internal:resource_actions.bzl", "resource_actions")
load("@build_bazel_rules_apple//apple/internal:rule_factory.bzl", "rule_factory")
load("@build_bazel_rules_apple//apple/internal:apple_toolchains.bzl", "AppleMacToolsToolchainInfo")
load("@build_bazel_rules_apple//apple:providers.bzl", "AppleResourceBundleInfo", "AppleResourceInfo")
load("//rules:transition_support.bzl", "transition_support")
load("@build_bazel_rules_apple//apple:providers.bzl", "AppleResourceBundleInfo", "AppleResourceInfo", "AppleSupportToolchainInfo")
load("//rules:utils.bzl", "bundle_identifier_for_bundle")

_FAKE_BUNDLE_PRODUCT_TYPE_BY_PLATFORM_TYPE = {
Expand Down Expand Up @@ -64,7 +65,6 @@ def _precompiled_apple_resource_bundle_impl(ctx):
objc_fragment = None,
platform_type_string = platform_type,
uses_swift = False,
xcode_path_wrapper = None,
xcode_version_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
disabled_features = [],
features = [],
Expand All @@ -79,10 +79,10 @@ def _precompiled_apple_resource_bundle_impl(ctx):
version = None,
)

apple_toolchain_info = ctx.attr._toolchain[AppleSupportToolchainInfo]
apple_mac_toolchain_info = ctx.attr._toolchain[AppleMacToolsToolchainInfo]
partial_output = partial.call(
partials.resources_partial(
apple_toolchain_info = apple_toolchain_info,
apple_mac_toolchain_info = apple_mac_toolchain_info,
resource_deps = ctx.attr.resources,
top_level_infoplists = resources.collect(
attr = ctx.attr,
Expand All @@ -109,7 +109,7 @@ def _precompiled_apple_resource_bundle_impl(ctx):
output_pkginfo = None,
output_plist = output_plist,
output_discriminator = None,
resolved_plisttool = apple_toolchain_info.resolved_plisttool,
resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool,
**partials_args
)

Expand Down Expand Up @@ -177,10 +177,10 @@ def _precompiled_apple_resource_bundle_impl(ctx):
content = bundletool_instructions.to_json(),
)
ctx.actions.run(
executable = apple_toolchain_info.resolved_bundletool_experimental.executable,
executable = apple_mac_toolchain_info.resolved_bundletool_experimental.executable,
mnemonic = "BundleResources",
progress_message = "Bundling Precompiled Resource Bundle " + bundle_name,
inputs = input_files + [bundletool_instructions_file] + apple_toolchain_info.resolved_bundletool_experimental.inputs.to_list(),
inputs = input_files + [bundletool_instructions_file] + apple_mac_toolchain_info.resolved_bundletool_experimental.inputs.to_list(),
outputs = [output_bundle_dir],
arguments = [bundletool_instructions_file.path],
)
Expand Down Expand Up @@ -271,8 +271,8 @@ the bundle as a dependency.""",
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
),
_toolchain = attr.label(
default = Label("@build_bazel_rules_apple//apple/internal:toolchain_support"),
providers = [[AppleSupportToolchainInfo]],
default = Label("@build_bazel_rules_apple//apple/internal:mac_tools_toolchain"),
providers = [[AppleMacToolsToolchainInfo]],
),
),
)
Expand Down
8 changes: 4 additions & 4 deletions rules/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ def rules_ios_dependencies():
github_repo,
name = "build_bazel_rules_swift",
project = "bazel-ios",
ref = "22192877498705ff1adbecd820fdc2724414b0b2",
ref = "8d4b096b90e47095755e47c27e749ae9b9f83e81",
repo = "rules_swift",
sha256 = "e091dc5b0c727873cec5ffa9622b563e9301d8136f4eed72ebb0ef575956cd3c",
sha256 = "83eb780db78f6c99cd97d3ff8c0e9bed1a6a3a4cba57476c6e1d2d989c52e17a",
)

_maybe(
github_repo,
name = "build_bazel_rules_apple",
ref = "7115f0188d141d57d64a6875735847c975956dae", # tag 0.34
ref = "029eab0a6bbb4147d227d623721b205eb62aca9c",
project = "bazelbuild",
repo = "rules_apple",
sha256 = "ddb53fb63947d068f4f1cc492c144c459e474a05d9db157ccf9457485aad2562",
sha256 = "b12455dbcaa31c4a42194aed59987d6abce6f04b4891389cd8fe5e817ae6b0ee",
)

_maybe(
Expand Down

0 comments on commit 1f4bddb

Please sign in to comment.