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

Remove invalid product type #744

Merged
merged 2 commits into from
Jul 21, 2023
Merged
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
64 changes: 37 additions & 27 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ load("@build_bazel_rules_apple//apple/internal:resource_actions.bzl", "resource_
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/internal:apple_toolchains.bzl", "AppleMacToolsToolchainInfo", "AppleXPlatToolsToolchainInfo")
load("@build_bazel_rules_apple//apple/internal:swift_support.bzl", "swift_support")
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_clang_module_aspect", "swift_common")
Expand Down Expand Up @@ -582,7 +583,7 @@ def _merge_root_infoplists(ctx):
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_mac_toolchain_info = ctx.attr._toolchain[AppleMacToolsToolchainInfo]
rule_descriptor = rule_support.rule_descriptor(ctx)
rule_descriptor = rule_support.rule_descriptor_no_ctx(platform_type, apple_product_type.static_framework)
Copy link
Contributor

Choose a reason for hiding this comment

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

Right, in my other PR I could've passed the attribute we need directly like this 🤦, nice one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NP @thiagohmcruz it just seemed like a small thing to fix up and make a bit easier


resource_actions.merge_root_infoplists(
actions = ctx.actions,
Expand All @@ -596,19 +597,7 @@ def _merge_root_infoplists(ctx):
output_plist = output_plist,
output_pkginfo = None,
output_discriminator = "framework",
platform_prerequisites = platform_support.platform_prerequisites(
apple_fragment = ctx.fragments.apple,
config_vars = ctx.var,
device_families = rule_descriptor.allowed_device_families,
explicit_minimum_os = None,
explicit_minimum_deployment_os = None,
objc_fragment = None,
platform_type_string = platform_type,
uses_swift = False,
xcode_version_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
disabled_features = [],
features = [],
),
platform_prerequisites = _platform_prerequisites(ctx, rule_descriptor, platform_type),
resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool,
rule_descriptor = rule_descriptor,
rule_label = ctx.label,
Expand All @@ -625,6 +614,26 @@ def _attrs_for_split_slice(attrs_by_split_slices, split_slice_key):
else:
return attrs_by_split_slices[split_slice_key]

def _platform_prerequisites(ctx, rule_descriptor, platform_type):
# Consider plumbing this in
deps = getattr(ctx.attr, "deps", None)
uses_swift = swift_support.uses_swift(deps) if deps else False

return platform_support.platform_prerequisites(
apple_fragment = ctx.fragments.apple,
config_vars = ctx.var,
cpp_fragment = ctx.fragments.cpp,
device_families = rule_descriptor.allowed_device_families,
disabled_features = ctx.disabled_features,
explicit_minimum_deployment_os = ctx.attr.minimum_deployment_os_version,
explicit_minimum_os = ctx.attr.minimum_os_version,
features = ctx.features,
objc_fragment = ctx.fragments.objc,
platform_type_string = platform_type,
uses_swift = uses_swift,
xcode_version_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
)

def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
"""Packages this as dynamic framework

Expand All @@ -648,26 +657,28 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
rules_apple_api_version = getattr(bundling_support, "rule_api_version", None)
use_lts_5_rules_apple_api = rules_apple_api_version == 1.0

bundle_name, bundle_extension = bundling_support.bundle_full_name_from_rule_ctx(ctx)
executable_name = bundling_support.executable_name(ctx)
bundle_name = ctx.attr.framework_name
bundle_extension = ".framework"
features = features_support.compute_enabled_features(
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
label = ctx.label
platform_prerequisites = platform_support.platform_prerequisites_from_rule_ctx(ctx)

# This file is used as part of the rules_apple bundling logic
archive = actions.declare_file(ctx.attr.name + ".framework.zip")
predeclared_outputs = struct(archive = archive)

provisioning_profile = None
resource_deps = ctx.attr.deps + ctx.attr.transitive_deps + ctx.attr.data
rule_descriptor = rule_support.rule_descriptor(ctx)
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)
rule_descriptor = rule_support.rule_descriptor_no_ctx(platform_type, apple_product_type.framework)
platform_prerequisites = _platform_prerequisites(ctx, rule_descriptor, platform_type)
signed_frameworks = []
if provisioning_profile:
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
bundle_name + bundle_extension,
]
top_level_resources = resources.collect(
attr = ctx.attr,
Expand Down Expand Up @@ -703,7 +714,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
actions = actions,
bundle_name = bundle_name,
bundle_extension = bundle_extension,
executable_name = executable_name,
executable_name = bundle_name,
label_name = label.name,
rule_descriptor = rule_descriptor,
platform_prerequisites = platform_prerequisites,
Expand All @@ -721,7 +732,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
bundle_extension = bundle_extension,
bundle_id = bundle_id,
bundle_name = bundle_name,
executable_name = executable_name,
executable_name = bundle_name,
label_name = label.name,
platform_prerequisites = platform_prerequisites,
predeclared_outputs = predeclared_outputs,
Expand All @@ -733,7 +744,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
actions = actions,
binary_artifact = binary_artifact,
bundle_name = bundle_name,
executable_name = executable_name,
executable_name = bundle_name,
label_name = label.name,
),
)
Expand Down Expand Up @@ -775,7 +786,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
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,
executable_name = bundle_name,
platform_prerequisites = platform_prerequisites,
bin_root_path = bin_root_path,
),
Expand All @@ -790,7 +801,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
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,
executable_name = bundle_name,
platform_prerequisites = platform_prerequisites,
),
)
Expand Down Expand Up @@ -855,7 +866,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
bundle_id = bundle_id,
bundle_name = bundle_name,
environment_plist = ctx.file.environment_plist,
executable_name = executable_name,
executable_name = bundle_name,
launch_storyboard = None,
platform_prerequisites = platform_prerequisites,
resource_deps = resource_deps,
Expand Down Expand Up @@ -897,7 +908,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
bundle_name = bundle_name,
codesign_inputs = [],
codesignopts = [],
executable_name = executable_name,
executable_name = bundle_name,
features = features,
ipa_post_processor = None,
partials = processor_partials,
Expand Down Expand Up @@ -1210,7 +1221,6 @@ that this target depends on.
If not given, the framework will be built for the platform it inherits from the target that uses
the framework as a dependency.""",
),
"_product_type": attr.string(default = apple_product_type.static_framework),
"_xcode_config": attr.label(
default = configuration_field(
name = "xcode_config_label",
Expand Down