From 69670b9e27c3e1071e2a8685c1b5193f8fea9dc3 Mon Sep 17 00:00:00 2001 From: Nicholas Levin Date: Tue, 28 Sep 2021 16:03:23 -0700 Subject: [PATCH] Perform the necessary forwarding `load` to expose the apple_xcframework rule from internal. PiperOrigin-RevId: 399550213 (cherry picked from commit 22948ba11b8903c57d5954ebc149afa3279e6a44) --- apple/BUILD | 1 + apple/apple.bzl | 5 +++ apple/internal/BUILD | 27 ++++++++++++++ doc/rules-apple.md | 35 +++++++++++++++++++ .../targets_under_test/apple/BUILD | 10 +++--- 5 files changed, 72 insertions(+), 6 deletions(-) diff --git a/apple/BUILD b/apple/BUILD index 0fccc0ba74..a967f9874c 100644 --- a/apple/BUILD +++ b/apple/BUILD @@ -34,6 +34,7 @@ bzl_library( srcs = ["apple.bzl"], deps = [ "//apple/internal:apple_framework_import", + "//apple/internal:xcframework_rules", ], ) diff --git a/apple/apple.bzl b/apple/apple.bzl index bc7332e1df..4827d21f19 100644 --- a/apple/apple.bzl +++ b/apple/apple.bzl @@ -19,6 +19,11 @@ load( _apple_dynamic_framework_import = "apple_dynamic_framework_import", _apple_static_framework_import = "apple_static_framework_import", ) +load( + "@build_bazel_rules_apple//apple/internal:xcframework_rules.bzl", + _apple_xcframework = "apple_xcframework", +) apple_dynamic_framework_import = _apple_dynamic_framework_import apple_static_framework_import = _apple_static_framework_import +apple_xcframework = _apple_xcframework diff --git a/apple/internal/BUILD b/apple/internal/BUILD index 16f75260e5..d94ca506c1 100644 --- a/apple/internal/BUILD +++ b/apple/internal/BUILD @@ -490,6 +490,33 @@ bzl_library( ], ) +bzl_library( + name = "xcframework_rules", + srcs = ["xcframework_rules.bzl"], + visibility = [ + "//apple:__subpackages__", + ], + deps = [ + ":apple_product_type", + ":experimental", + ":intermediates", + ":linking_support", + ":outputs", + ":partials", + ":platform_support", + ":processor", + ":resources", + ":rule_support", + ":swift_support", + ":transition_support", + "//apple:providers", + "//apple/internal/aspects:resource_aspect", + "@build_bazel_apple_support//lib:apple_support", + "@build_bazel_apple_support//lib:lipo", + "@build_bazel_rules_swift//swift", + ], +) + # Consumed by bazel tests. filegroup( name = "for_bazel_tests", diff --git a/doc/rules-apple.md b/doc/rules-apple.md index ecfcf460be..bbd1abc5db 100644 --- a/doc/rules-apple.md +++ b/doc/rules-apple.md @@ -88,3 +88,38 @@ objc_library( | weak_sdk_frameworks | Names of SDK frameworks to weakly link with. For instance, MediaAccessibility. In difference to regularly linked SDK frameworks, symbols from weakly linked frameworks do not cause an error if they are not present at runtime. | List of strings | optional | [] | + + +## apple_xcframework + +
+apple_xcframework(name, bundle_id, bundle_name, data, deps, exported_symbols_lists,
+                  families_required, framework_type, infoplists, ios, linkopts,
+                  minimum_deployment_os_versions, minimum_os_versions, public_hdrs, stamp, version)
+
+ + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| bundle_id | The bundle ID (reverse-DNS path followed by app name) for each of the embedded frameworks. If present, this value will be embedded in an Info.plist within each framework bundle. | String | optional | "" | +| bundle_name | The desired name of the xcframework bundle (without the extension) and the bundles for all embedded frameworks. If this attribute is not set, then the name of the target will be used instead. | String | optional | "" | +| data | A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within each of the embedded framework bundles. | List of labels | optional | [] | +| deps | A list of dependencies targets that will be linked into this each of the framework target's individual binaries. Any resources, such as asset catalogs, that are referenced by those targets will also be transitively included in the framework bundles. | List of labels | optional | [] | +| exported_symbols_lists | A list of targets containing exported symbols lists files for the linker to control symbol resolution.

Each file is expected to have a list of global symbol names that will remain as global symbols in the compiled binary owned by this framework. All other global symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden) and will not be global in the output file.

See the man page documentation for ld(1) on macOS for more details. | List of labels | optional | [] | +| families_required | A list of device families supported by this extension, with platforms such as ios as keys. Valid values are iphone and ipad for ios; at least one must be specified if a platform is defined. Currently, this only affects processing of ios resources. | Dictionary: String -> List of strings | optional | {} | +| framework_type | Indicates what type of framework the output should be, if defined. Currently only dynamic is supported. If this is not given, the default is to have all contained frameworks built as dynamic frameworks. | List of strings | optional | [] | +| infoplists | A list of .plist files that will be merged to form the Info.plist for each of the embedded frameworks. At least one file must be specified. Please see [Info.plist Handling](https://github.com/bazelbuild/rules_apple/blob/master/doc/common_info.md#infoplist-handling) for what is supported. | List of labels | required | | +| ios | A dictionary of strings indicating which platform variants should be built for the ios platform ( device or simulator) as keys, and arrays of strings listing which architectures should be built for those platform variants (for example, x86_64, arm64) as their values. | Dictionary: String -> List of strings | optional | {} | +| linkopts | A list of strings representing extra flags that should be passed to the linker. | List of strings | optional | [] | +| minimum_deployment_os_versions | A dictionary of strings indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0") as values, with their respective platforms such as ios as keys. This is different from minimum_os_versions, which is effective at compile time. Ensure version specific APIs are guarded with available clauses. | Dictionary: String -> String | optional | {} | +| minimum_os_versions | A dictionary of strings indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "8.0") as values, with their respective platforms such as ios as keys. | Dictionary: String -> String | required | | +| public_hdrs | A list of files directly referencing header files to be used as the publicly visible interface for each of these embedded frameworks. These header files will be embedded within each bundle, typically in a subdirectory such as Headers. | List of labels | optional | [] | +| stamp | Enable link stamping. Whether to encode build information into the binaries. Possible values:

* stamp = 1: Stamp the build information into the binaries. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information. * stamp = 0: Always replace build information by constant values. This gives good build result caching. * stamp = -1: Embedding of build information is controlled by the --[no]stamp flag. | Integer | optional | -1 | +| version | An apple_bundle_version target that represents the version for this target. See [apple_bundle_version](https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-general.md?cl=head#apple_bundle_version). | Label | optional | None | + + diff --git a/test/starlark_tests/targets_under_test/apple/BUILD b/test/starlark_tests/targets_under_test/apple/BUILD index 11e1a02b30..2b86bc32a8 100644 --- a/test/starlark_tests/targets_under_test/apple/BUILD +++ b/test/starlark_tests/targets_under_test/apple/BUILD @@ -1,3 +1,7 @@ +load( + "//apple:apple.bzl", + "apple_xcframework", +) load( "//apple:versioning.bzl", "apple_bundle_version", @@ -11,12 +15,6 @@ load( "apple_core_data_model", ) -# TODO(b/135122463): Replace internal domain load(...) with a public import when the rule is ready. -load( - "//apple/internal:xcframework_rules.bzl", - "apple_xcframework", -) # buildifier: disable=bzl-visibility - licenses(["notice"]) package(