Skip to content

Commit

Permalink
buck2 | xcframeworks | Add module_map as a field to apple_bundle
Browse files Browse the repository at this point in the history
Summary:
Allows adding custom module_map to [xc]frameworks.

We probably want to also allow using an autogenerated module.modulemap file too, but this unblocks work on WA*Kit frameworks, and we potentially want to allow customization here anyway.

Should the field be `module_map` or `modulemap`?
The extension of the file is indeed `modulemap`, but the type of the file is 'module map', so I'm using the underscore.

Reviewed By: chatura-atapattu

Differential Revision: D57209531

fbshipit-source-id: 642749bbba36563a4fa5d4e3cb90227767053709
  • Loading branch information
benb authored and facebook-github-bot committed May 10, 2024
1 parent 14765f7 commit 1fd619a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions prelude/apple/apple_bundle_resources.bzl
Expand Up @@ -131,6 +131,7 @@ def get_apple_bundle_resource_part_list(ctx: AnalysisContext) -> AppleBundleReso
parts.extend(_copy_resources(ctx, resource_specs))
parts.extend(_copy_first_level_bundles(ctx))
parts.extend(_copy_public_headers(ctx))
parts.extend(_copy_module_map(ctx))

return AppleBundleResourcePartListOutput(
resource_parts = parts,
Expand Down Expand Up @@ -198,6 +199,15 @@ def _copy_public_headers(ctx: AnalysisContext) -> list[AppleBundlePart]:

return bundle_parts

def _copy_module_map(ctx: AnalysisContext) -> list[AppleBundlePart]:
extension = get_extension_attr(ctx)
if not extension == "framework":
return []
module_map = ctx.attrs.module_map
if not module_map:
return []
return [AppleBundlePart(source = module_map, destination = AppleBundleDestination("modules"))]

def _copy_resources(ctx: AnalysisContext, specs: list[AppleResourceSpec]) -> list[AppleBundlePart]:
result = []

Expand Down
1 change: 1 addition & 0 deletions prelude/apple/apple_resource_bundle.bzl
Expand Up @@ -51,6 +51,7 @@ _RESOURCE_BUNDLE_FIELDS = [
"ibtool_module_flag",
"info_plist",
"info_plist_substitutions",
"module_map",
"product_name",
"privacy_manifest",
"resource_group",
Expand Down
1 change: 1 addition & 0 deletions prelude/apple/apple_rules_impl_utility.bzl
Expand Up @@ -140,6 +140,7 @@ def apple_bundle_extra_attrs():
"binary": attrs.option(attrs.split_transition_dep(cfg = cpu_split_transition), default = None),
"bundle_type": attrs.option(attrs.enum(AppleBundleTypeAttributeType.values()), default = None),
"copy_public_framework_headers": attrs.option(attrs.bool(), default = None),
"module_map": attrs.option(attrs.source(), default = None),
"resource_group_map": RESOURCE_GROUP_MAP_ATTR,
"selective_debugging": attrs.option(attrs.dep(providers = [AppleSelectiveDebuggingInfo]), default = None),
"split_arch_dsym": attrs.bool(default = False),
Expand Down
1 change: 1 addition & 0 deletions prelude/apple/user/apple_resource_bundle.bzl
Expand Up @@ -38,6 +38,7 @@ def _apple_resource_bundle_attrs():
"info_plist": attrs.source(),
"info_plist_substitutions": attrs.dict(key = attrs.string(), value = attrs.string(), sorted = False, default = {}),
"labels": attrs.list(attrs.string(), default = []),
"module_map": attrs.option(attrs.source(), default = None),
"privacy_manifest": attrs.option(attrs.source(), default = None),
"product_name": attrs.option(attrs.string(), default = None),
"resource_group": attrs.option(attrs.string(), default = None),
Expand Down

0 comments on commit 1fd619a

Please sign in to comment.