Skip to content

Commit

Permalink
[6.x.x] sim_arm64 middleman fixes
Browse files Browse the repository at this point in the history
In Bazel 6.x.x the `static_framework_file` was migrated onto
`imported_library` this PR completes the migration and is followup to
the Bazel 6 work.

The related rules_apple change which updated `static_framework_file`:
bazelbuild/rules_apple@8d84134
  • Loading branch information
jerrymarino committed Sep 14, 2023
1 parent 35c7197 commit 94cb5b1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions rules/import_middleman.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,18 @@ def _file_collector_rule_impl(ctx):
existing_static_framework = objc_provider_fields.get("static_framework_file", depset([]))

deduped_static_framework = depset(_deduplicate_test_deps(test_linker_deps[0], existing_static_framework.to_list()))

replaced_static_framework = _replace_inputs(ctx, deduped_static_framework, input_static_frameworks, _update_framework)
objc_provider_fields["static_framework_file"] = depset(replaced_static_framework.inputs)
rules_apple_api_version = getattr(bundling_support, "rule_api_version", None)
use_lts_5_rules_apple_api = rules_apple_api_version == 1.0
if use_lts_5_rules_apple_api:
objc_provider_fields["static_framework_file"] = depset(replaced_static_framework.inputs)
else:
# See comment in file above regarding this name in 6.x.x
objc_provider_fields["imported_library"] = depset([], transitive = [
depset(replaced_static_framework.inputs),
objc_provider_fields.get("imported_library", depset([])),
])

# Update dynamic frameworks - note that we need to do some additional
# processing for the ad-hoc files e.g. ( Info.plist )
Expand Down Expand Up @@ -239,11 +249,17 @@ def _file_collector_rule_impl(ctx):
dynamic_framework_dirs.append(f)
objc_provider_fields["dynamic_framework_file"] = depset(dynamic_framework_file)

replaced_frameworks = replaced_dyanmic_framework.values() + replaced_static_framework.replaced.values()
all_replaced_frameworks = replaced_dyanmic_framework.values() + replaced_static_framework.replaced.values()

# This slightly varies in Bazel 6.x.x
if use_lts_5_rules_apple_api:
replaced_frameworks = all_replaced_frameworks
else:
replaced_frameworks = replaced_dyanmic_framework.values()

compat_link_opt = ["-L__BAZEL_XCODE_DEVELOPER_DIR__/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator", "-Wl,-weak-lswiftCompatibility51"]

if len(replaced_frameworks):
if len(all_replaced_frameworks):
# Triple quote the new path to put them first. Eliminating other paths
# may possible but needs more handling of other kinds of frameworks and
# has edge cases that require baking assumptions to handle.
Expand All @@ -255,7 +271,7 @@ def _file_collector_rule_impl(ctx):
objc_provider_fields["link_inputs"] = depset(
transitive = [
objc_provider_fields.get("link_inputs", depset([])),
depset(replaced_frameworks),
depset(all_replaced_frameworks),
],
)

Expand Down

0 comments on commit 94cb5b1

Please sign in to comment.