diff --git a/apple/internal/BUILD b/apple/internal/BUILD index d512f86969..9e450c5a76 100644 --- a/apple/internal/BUILD +++ b/apple/internal/BUILD @@ -288,7 +288,9 @@ bzl_library( "//apple:providers", "//apple/internal/utils:clang_rt_dylibs", "@bazel_skylib//lib:collections", + "@bazel_skylib//rules:common_settings", "@build_bazel_rules_swift//swift", + "@build_bazel_rules_swift//swift:providers", ], ) @@ -593,7 +595,9 @@ bzl_library( ":transition_support", "//apple:providers", "//apple/internal/utils:clang_rt_dylibs", + "@bazel_skylib//rules:common_settings", "@build_bazel_rules_swift//swift", + "@build_bazel_rules_swift//swift:providers", ], ) diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index b4810bee68..b9a77b9b78 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -115,6 +115,7 @@ load( "IosStickerPackExtensionBundleInfo", ) load("@bazel_skylib//lib:collections.bzl", "collections") +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") def _ios_application_impl(ctx): """Experimental implementation of ios_application.""" @@ -690,6 +691,14 @@ def _ios_framework_impl(ctx): bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name_from_rule_ctx(ctx) executable_name = bundling_support.executable_name(ctx) + cc_toolchain = find_cpp_toolchain(ctx) + cc_features = cc_common.configure_features( + ctx = ctx, + cc_toolchain = cc_toolchain, + language = "objc", + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) features = features_support.compute_enabled_features( requested_features = ctx.features, unsupported_features = ctx.disabled_features, @@ -828,7 +837,9 @@ def _ios_framework_impl(ctx): binary_artifact = binary_artifact, bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, + cc_features = cc_features, cc_info = link_result.cc_info, + cc_toolchain = cc_toolchain, objc_provider = link_result.objc, rule_label = label, ), diff --git a/apple/internal/partials/framework_provider.bzl b/apple/internal/partials/framework_provider.bzl index a90720c182..7dab7ef32f 100644 --- a/apple/internal/partials/framework_provider.bzl +++ b/apple/internal/partials/framework_provider.bzl @@ -30,7 +30,9 @@ def _framework_provider_partial_impl( binary_artifact, bundle_name, bundle_only, + cc_features, cc_info, + cc_toolchain, objc_provider, rule_label): """Implementation for the framework provider partial.""" @@ -61,9 +63,30 @@ def _framework_provider_partial_impl( providers = [objc_provider], ) + library_to_link = cc_common.create_library_to_link( + actions = actions, + cc_toolchain = cc_toolchain, + feature_configuration = cc_features, + dynamic_library = binary_artifact, + ) + linker_input = cc_common.create_linker_input( + owner = rule_label, + libraries = depset([library_to_link]), + ) + wrapper_cc_info = cc_common.merge_cc_infos( + cc_infos = [ + CcInfo( + linking_context = cc_common.create_linking_context( + linker_inputs = depset(direct = [linker_input]), + ), + ), + cc_info, + ], + ) + framework_provider = apple_common.new_dynamic_framework_provider( binary = binary_artifact, - cc_info = cc_info, + cc_info = wrapper_cc_info, framework_dirs = depset([absolute_framework_dir]), framework_files = depset([framework_file]), objc = legacy_objc_provider, @@ -80,7 +103,9 @@ def framework_provider_partial( binary_artifact, bundle_name, bundle_only, + cc_features, cc_info, + cc_toolchain, objc_provider, rule_label): """Constructor for the framework provider partial. @@ -96,8 +121,10 @@ def framework_provider_partial( binary_artifact: The linked dynamic framework binary. bundle_name: The name of the output bundle. bundle_only: Only include the bundle but do not link the framework + cc_features: List of enabled C++ features. cc_info: The CcInfo provider containing information about the targets linked into the dynamic framework. + cc_toolchain: The C++ toolchain to use. objc_provider: The `apple_common.Objc` provider containing information about the targets linked into the dynamic framework. rule_label: The label of the target being analyzed. @@ -114,7 +141,9 @@ def framework_provider_partial( binary_artifact = binary_artifact, bundle_name = bundle_name, bundle_only = bundle_only, + cc_features = cc_features, cc_info = cc_info, + cc_toolchain = cc_toolchain, objc_provider = objc_provider, rule_label = rule_label, ) diff --git a/apple/internal/tvos_rules.bzl b/apple/internal/tvos_rules.bzl index ae6dea8664..2e068cd7a3 100644 --- a/apple/internal/tvos_rules.bzl +++ b/apple/internal/tvos_rules.bzl @@ -106,6 +106,7 @@ load( "TvosFrameworkBundleInfo", "TvosStaticFrameworkBundleInfo", ) +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") def _tvos_application_impl(ctx): """Experimental implementation of tvos_application.""" @@ -393,6 +394,14 @@ def _tvos_dynamic_framework_impl(ctx): bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name_from_rule_ctx(ctx) executable_name = bundling_support.executable_name(ctx) + cc_toolchain = find_cpp_toolchain(ctx) + cc_features = cc_common.configure_features( + ctx = ctx, + cc_toolchain = cc_toolchain, + language = "objc", + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) features = features_support.compute_enabled_features( requested_features = ctx.features, unsupported_features = ctx.disabled_features, @@ -750,7 +759,9 @@ def _tvos_framework_impl(ctx): binary_artifact = binary_artifact, bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, + cc_features = cc_features, cc_info = link_result.cc_info, + cc_toolchain = cc_toolchain, objc_provider = link_result.objc, rule_label = label, ),