Skip to content

Commit

Permalink
Create apple_ipa_package() private targets
Browse files Browse the repository at this point in the history
Summary: For each `apple_package()` target, create a "private" `apple_ipa_package()` target - to be used for the .ipa creation.

Reviewed By: manicaesar

Differential Revision: D61264637

fbshipit-source-id: 300971adcb21b25a073d7ffeb19bb5a1aee8a469
  • Loading branch information
milend authored and facebook-github-bot committed Aug 14, 2024
1 parent 2434d26 commit b3ba9de
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apple/apple_macro_layer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.

load("@prelude//apple/user:apple_ipa_package.bzl", "make_apple_ipa_package_target")
load(":apple_bundle_config.bzl", "apple_bundle_config")
load(":apple_dsym_config.bzl", "apple_dsym_config")
load(":apple_info_plist_substitutions_parsing.bzl", "parse_codesign_entitlements")
Expand Down Expand Up @@ -149,9 +150,10 @@ def apple_binary_macro_impl(apple_binary_rule = None, apple_universal_executable

apple_binary_rule(name = binary_name, **kwargs)

def apple_package_macro_impl(apple_package_rule = None, **kwargs):
def apple_package_macro_impl(apple_package_rule = None, apple_ipa_package_rule = None, **kwargs):
kwargs.update(apple_package_config())
apple_package_rule(
_ipa_package = make_apple_ipa_package_target(apple_ipa_package_rule, **kwargs),
**kwargs
)

Expand Down
1 change: 1 addition & 0 deletions apple/apple_rules_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ extra_attributes = {
"_apple_toolchain": get_apple_bundle_toolchain_attr(),
"_apple_tools": attrs.exec_dep(default = "prelude//apple/tools:apple-tools", providers = [AppleToolsInfo]),
"_ipa_compression_level": attrs.enum(IpaCompressionLevel.values()),
"_ipa_package": attrs.dep(),
},
"apple_resource": {
"codesign_entitlements": attrs.option(attrs.source(), default = None),
Expand Down
30 changes: 30 additions & 0 deletions apple/user/apple_ipa_package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

load("@prelude//apple:apple_bundle_types.bzl", "AppleBundleInfo", "ApplePackageExtension")
load("@prelude//apple:apple_package_config.bzl", "IpaCompressionLevel")
load("@prelude//apple:apple_rules_impl_utility.bzl", "get_apple_bundle_toolchain_attr")
load("@prelude//apple:apple_toolchain_types.bzl", "AppleToolsInfo")
load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec")

Expand All @@ -20,6 +21,7 @@ def _apple_ipa_package_attribs():
"ext": attrs.enum(ApplePackageExtension.values(), default = "ipa"),
"labels": attrs.list(attrs.string(), default = []),
"package_name": attrs.option(attrs.string(), default = None),
"_apple_toolchain": get_apple_bundle_toolchain_attr(),
"_apple_tools": attrs.exec_dep(default = "prelude//apple/tools:apple-tools", providers = [AppleToolsInfo]),
"_ipa_compression_level": attrs.enum(IpaCompressionLevel.values()),
}
Expand All @@ -30,3 +32,31 @@ registration_spec = RuleRegistrationSpec(
impl = _apple_ipa_package_impl,
attrs = _apple_ipa_package_attribs(),
)

_IPA_PACKAGE_FORWARDED_FIELDS = [
"bundle",
"ext",
"package_name",
"_ipa_compression_level",
"compatible_with",
"exec_compatible_with",
"target_compatible_with",
"default_target_platform",
"within_view",
"visibility",
]

def make_apple_ipa_package_target(apple_ipa_package_rule, **kwargs) -> [None, str]:
ipa_package_kwargs = {
"labels": ["generated"],
}
for field_name in _IPA_PACKAGE_FORWARDED_FIELDS:
ipa_package_kwargs[field_name] = kwargs.get(field_name)

ipa_package_target_name = kwargs["name"] + "__IPA_Package_Private"
apple_ipa_package_rule(
name = ipa_package_target_name,
**ipa_package_kwargs
)

return ":{}".format(ipa_package_target_name)
1 change: 1 addition & 0 deletions native.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def _apple_library_macro_stub(**kwargs):
def _apple_package_macro_stub(**kwargs):
apple_package_macro_impl(
apple_package_rule = __rules__["apple_package"],
apple_ipa_package_rule = _user_rules["apple_ipa_package"],
**kwargs
)

Expand Down

0 comments on commit b3ba9de

Please sign in to comment.