diff --git a/bazel/swift_static_framework.bzl b/bazel/swift_static_framework.bzl index fa02d40961..6a272a5e86 100644 --- a/bazel/swift_static_framework.bzl +++ b/bazel/swift_static_framework.bzl @@ -8,17 +8,19 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "swift_library") MINIMUM_IOS_VERSION = "11.0" _PLATFORM_TO_SWIFTMODULE = { + "ios_armv7": "arm", "ios_arm64": "arm64", + "ios_i386": "i386", "ios_x86_64": "x86_64", } -def _tar_binary_arg(module_name, input_file): +def _zip_binary_arg(module_name, input_file): return "{module_name}.framework/{module_name}={file_path}".format( module_name = module_name, file_path = input_file.path, ) -def _tar_swift_arg(module_name, swift_identifier, input_file): +def _zip_swift_arg(module_name, swift_identifier, input_file): return "{module_name}.framework/Modules/{module_name}.swiftmodule/{swift_identifier}.{ext}={file_path}".format( module_name = module_name, swift_identifier = swift_identifier, @@ -26,28 +28,28 @@ def _tar_swift_arg(module_name, swift_identifier, input_file): file_path = input_file.path, ) -def _prebuilt_swift_static_framework_impl(ctx): +def _swift_static_framework_impl(ctx): module_name = ctx.attr.framework_name fat_file = ctx.outputs.fat_file input_archives = [] input_modules_docs = [] - tar_args = [_tar_binary_arg(module_name, fat_file)] + zip_args = [_zip_binary_arg(module_name, fat_file)] for platform, archive in ctx.split_attr.archive.items(): swiftmodule_identifier = _PLATFORM_TO_SWIFTMODULE[platform] if not swiftmodule_identifier: fail("Unhandled platform '{}'".format(platform)) - library = archive[CcInfo].linking_context.libraries_to_link.to_list()[0].pic_static_library + library = archive[CcInfo].linking_context.libraries_to_link[0].pic_static_library swift_info = archive[SwiftInfo] swiftdoc = swift_info.direct_swiftdocs[0] swiftmodule = swift_info.direct_swiftmodules[0] input_archives.append(library) input_modules_docs += [swiftdoc, swiftmodule] - tar_args += [ - _tar_swift_arg(module_name, swiftmodule_identifier, swiftdoc), - _tar_swift_arg(module_name, swiftmodule_identifier, swiftmodule), + zip_args += [ + _zip_swift_arg(module_name, swiftmodule_identifier, swiftdoc), + _zip_swift_arg(module_name, swiftmodule_identifier, swiftmodule), ] ctx.actions.run( @@ -64,9 +66,9 @@ def _prebuilt_swift_static_framework_impl(ctx): inputs = input_modules_docs + [fat_file], outputs = [output_file], mnemonic = "CreateSwiftFrameworkTar", - progress_message = "Creating framework tar for {}".format(module_name), - executable = ctx.executable._create_tar, - arguments = [output_file.path] + tar_args, + progress_message = "Creating framework zip for {}".format(module_name), + executable = ctx.executable._zipper, + arguments = ["c", output_file.path] + zip_args, ) return [ @@ -75,8 +77,8 @@ def _prebuilt_swift_static_framework_impl(ctx): ), ] -_prebuilt_swift_static_framework = rule( - implementation = _prebuilt_swift_static_framework_impl, +_swift_static_framework = rule( + implementation = _swift_static_framework_impl, attrs = dict( archive = attr.label( mandatory = True, @@ -88,21 +90,20 @@ _prebuilt_swift_static_framework = rule( platform_type = attr.string( default = str(apple_common.platform_type.ios), ), - _create_tar = attr.label( - default = "//tools:create_tar", + _zipper = attr.label( + default = "@bazel_tools//tools/zip:zipper", cfg = "host", executable = True, ), ), outputs = { "fat_file": "%{framework_name}.fat", - "output_file": "%{framework_name}.tar.bz2", + "output_file": "%{framework_name}.zip", }, ) -def prebuilt_swift_static_framework( +def swift_static_framework( name, - version = None, srcs = [], copts = [], deps = []): @@ -111,7 +112,6 @@ def prebuilt_swift_static_framework( Args: name: The name of the module, the framework's name will be this name appending Framework so you can depend on this from other modules - version: The version of the library for use with metadata files srcs: Custom source paths for the swift files copts: Any custom swiftc opts passed through to the swift_library deps: Any deps the swift_library requires @@ -127,7 +127,7 @@ def prebuilt_swift_static_framework( ) framework_name = name + "Framework" - _prebuilt_swift_static_framework( + _swift_static_framework( name = framework_name, framework_name = name, archive = name, diff --git a/library/swift/BUILD b/library/swift/BUILD index 6ab4fd53ac..6dcb56d02d 100644 --- a/library/swift/BUILD +++ b/library/swift/BUILD @@ -1,9 +1,9 @@ licenses(["notice"]) # Apache 2 load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") -load("//bazel:swift_static_framework.bzl", "prebuilt_swift_static_framework") +load("//bazel:swift_static_framework.bzl", "swift_static_framework") -prebuilt_swift_static_framework( +swift_static_framework( name = "swift_framework", srcs = ["Envoy.swift"], deps = ["//library/objective-c:envoy_engine_objc_lib"]