Skip to content
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

Add framework linking info to CcInfo of framework rules #1845

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
21 changes: 21 additions & 0 deletions apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -1158,6 +1169,14 @@ def _ios_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,
Expand Down Expand Up @@ -1300,7 +1319,9 @@ def _ios_dynamic_framework_impl(ctx):
binary_artifact = binary_artifact,
bundle_name = bundle_name,
bundle_only = False,
cc_features = cc_features,
cc_info = link_result.cc_info,
cc_toolchain = cc_toolchain,
objc_provider = link_result.objc,
rule_label = label,
),
Expand Down
31 changes: 30 additions & 1 deletion apple/internal/partials/framework_provider.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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,
)
21 changes: 21 additions & 0 deletions apple/internal/tvos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -527,7 +536,9 @@ def _tvos_dynamic_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,
),
Expand Down Expand Up @@ -619,6 +630,14 @@ def _tvos_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,
Expand Down Expand Up @@ -750,7 +769,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,
),
Expand Down
21 changes: 21 additions & 0 deletions apple/internal/watchos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ load(
"@build_bazel_rules_swift//swift:swift.bzl",
"SwiftInfo",
)
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

def _watchos_framework_impl(ctx):
"""Experimental implementation of watchos_framework."""
Expand All @@ -120,6 +121,14 @@ def _watchos_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,
Expand Down Expand Up @@ -256,7 +265,9 @@ def _watchos_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,
),
Expand Down Expand Up @@ -352,6 +363,14 @@ def _watchos_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,
Expand Down Expand Up @@ -493,7 +512,9 @@ def _watchos_dynamic_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,
),
Expand Down