Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 549131342
  • Loading branch information
googlewalt authored and swiple-rules-gardener committed Jul 18, 2023
1 parent f1daf41 commit 1d81068
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
10 changes: 5 additions & 5 deletions apple/apple_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ def _apple_binary_impl(ctx):
bundle_loader = ctx.attr.bundle_loader

extra_linkopts = []
extra_requested_features = []

if binary_type == "dylib":
extra_linkopts.append("-dynamiclib")
extra_requested_features.append("link_dylib")
elif binary_type == "loadable_bundle":
extra_linkopts.extend([
"-bundle",
"-Wl,-rpath,@loader_path/Frameworks",
])
extra_linkopts.append("-Wl,-rpath,@loader_path/Frameworks")
extra_requested_features.append("link_bundle")

extra_linkopts.extend([
_linker_flag_for_sdk_dylib(dylib)
Expand All @@ -82,6 +81,7 @@ def _apple_binary_impl(ctx):
bundle_loader = bundle_loader,
exported_symbols_lists = ctx.files.exported_symbols_lists,
extra_linkopts = extra_linkopts,
extra_requested_features = extra_requested_features,
platform_prerequisites = None,
rule_descriptor = None,
stamp = ctx.attr.stamp,
Expand Down
2 changes: 1 addition & 1 deletion apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -816,13 +816,13 @@ def _ios_framework_impl(ctx):
entitlements = None,
exported_symbols_lists = ctx.files.exported_symbols_lists,
extra_linkopts = [
"-dynamiclib",
"-install_name",
"@rpath/{name}{extension}/{name}".format(
extension = bundle_extension,
name = bundle_name,
),
],
extra_requested_features = ["link_dylib"],
platform_prerequisites = platform_prerequisites,
rule_descriptor = rule_descriptor,
stamp = ctx.attr.stamp,
Expand Down
4 changes: 4 additions & 0 deletions apple/internal/linking_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def _register_binary_linking_action(
entitlements = None,
exported_symbols_lists = [],
extra_linkopts = [],
extra_requested_features = [],
extra_disabled_features = [],
platform_prerequisites = None,
rule_descriptor = None,
stamp = -1):
Expand Down Expand Up @@ -204,6 +206,8 @@ def _register_binary_linking_action(
avoid_deps = all_avoid_deps,
extra_linkopts = linkopts,
extra_link_inputs = link_inputs,
extra_requested_features = extra_requested_features,
extra_disabled_features = extra_disabled_features,
stamp = stamp,
)

Expand Down
6 changes: 3 additions & 3 deletions apple/internal/macos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def _macos_bundle_impl(ctx):
bundle_loader = ctx.attr.bundle_loader,
entitlements = entitlements,
exported_symbols_lists = ctx.files.exported_symbols_lists,
extra_linkopts = ["-bundle"],
extra_requested_features = ["link_bundle"],
platform_prerequisites = platform_prerequisites,
rule_descriptor = rule_descriptor,
stamp = ctx.attr.stamp,
Expand Down Expand Up @@ -932,7 +932,6 @@ def _macos_quick_look_plugin_impl(ctx):
)

extra_linkopts = [
"-dynamiclib",
"-install_name",
"\"/Library/Frameworks/{0}.qlgenerator/{0}\"".format(ctx.attr.bundle_name),
]
Expand All @@ -941,6 +940,7 @@ def _macos_quick_look_plugin_impl(ctx):
entitlements = entitlements,
exported_symbols_lists = ctx.files.exported_symbols_lists,
extra_linkopts = extra_linkopts,
extra_requested_features = ["link_dylib"],
platform_prerequisites = platform_prerequisites,
rule_descriptor = rule_descriptor,
stamp = ctx.attr.stamp,
Expand Down Expand Up @@ -1920,7 +1920,7 @@ def _macos_dylib_impl(ctx):
# Dynamic libraries do not have entitlements.
entitlements = None,
exported_symbols_lists = ctx.files.exported_symbols_lists,
extra_linkopts = ["-dynamiclib"],
extra_requested_features = ["link_dylib"],
platform_prerequisites = platform_prerequisites,
rule_descriptor = rule_descriptor,
stamp = ctx.attr.stamp,
Expand Down
2 changes: 1 addition & 1 deletion apple/internal/testing/apple_test_bundle_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ def _apple_test_bundle_impl(*, ctx, product_type):
extra_linkopts = [
"-framework",
"XCTest",
"-bundle",
]

link_result = linking_support.register_binary_linking_action(
Expand All @@ -354,6 +353,7 @@ def _apple_test_bundle_impl(*, ctx, product_type):
entitlements = None,
exported_symbols_lists = ctx.files.exported_symbols_lists,
extra_linkopts = extra_linkopts,
extra_requested_features = ["link_bundle"],
platform_prerequisites = platform_prerequisites,
rule_descriptor = rule_descriptor,
stamp = ctx.attr.stamp,
Expand Down
2 changes: 1 addition & 1 deletion apple/internal/tvos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,13 @@ def _tvos_framework_impl(ctx):
entitlements = None,
exported_symbols_lists = ctx.files.exported_symbols_lists,
extra_linkopts = [
"-dynamiclib",
"-install_name",
"@rpath/{name}{extension}/{name}".format(
extension = bundle_extension,
name = bundle_name,
),
],
extra_requested_features = ["link_dylib"],
platform_prerequisites = platform_prerequisites,
rule_descriptor = rule_descriptor,
stamp = ctx.attr.stamp,
Expand Down
2 changes: 1 addition & 1 deletion apple/internal/xcframework_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,13 @@ def _apple_xcframework_impl(ctx):
# executables. Only macOS (which is not yet supported) is an outlier; this will require
# changes to native Bazel linking logic for Apple binary targets.
"-Wl,-rpath,@executable_path/Frameworks",
"-dynamiclib",
"-install_name",
"@rpath/{name}{extension}/{name}".format(
extension = nested_bundle_extension,
name = bundle_name,
),
],
extra_requested_features = ["link_dylib"],
platform_prerequisites = None,
# All required knowledge for 3P facing frameworks is passed directly through the given
# `extra_linkopts`; no rule_descriptor is needed to share with this linking action.
Expand Down

1 comment on commit 1d81068

@keith
Copy link
Member

@keith keith commented on 1d81068 Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.