Skip to content

Commit 9c0cdfa

Browse files
committed
Update for rules_swift 3.0
1 parent 9d33c7a commit 9c0cdfa

File tree

4 files changed

+13
-25
lines changed

4 files changed

+13
-25
lines changed

MODULE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bazel_dep(
2222
)
2323
bazel_dep(
2424
name = "rules_apple",
25-
version = "3.15.0",
25+
version = "4.0.1",
2626
repo_name = "build_bazel_rules_apple",
2727
)
2828
bazel_dep(
@@ -31,8 +31,8 @@ bazel_dep(
3131
)
3232
bazel_dep(
3333
name = "rules_swift",
34-
version = "1.18.0",
35-
max_compatibility_level = 2,
34+
version = "3.0.2",
35+
max_compatibility_level = 3,
3636
repo_name = "build_bazel_rules_swift",
3737
)
3838
bazel_dep(

rules/framework.bzl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ load("@build_bazel_rules_apple//apple/internal:apple_toolchains.bzl", "AppleMacT
2525
load("@build_bazel_rules_apple//apple/internal:swift_support.bzl", "swift_support")
2626
load("@build_bazel_rules_apple//apple/internal/utils:clang_rt_dylibs.bzl", "clang_rt_dylibs")
2727
load("@build_bazel_rules_apple//apple/internal:providers.bzl", "AppleBundleInfo", "ApplePlatformInfo", "IosFrameworkBundleInfo", "new_applebundleinfo", "new_iosframeworkbundleinfo")
28-
load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "swift_clang_module_aspect", "swift_common")
28+
load("@build_bazel_rules_swift//swift:providers.bzl", "SwiftInfo", "create_clang_module_inputs", "create_swift_module_context", "create_swift_module_inputs")
29+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_clang_module_aspect", "swift_common")
2930
load(
3031
"@build_bazel_rules_apple//apple/internal/aspects:resource_aspect.bzl",
3132
"apple_resource_aspect",
@@ -558,7 +559,7 @@ def _create_swiftmodule(attrs):
558559
if attrs.symbol_graph:
559560
kwargs["symbol_graph"] = attrs.symbol_graph
560561

561-
return swift_common.create_swift_module(
562+
return create_swift_module_inputs(
562563
swiftdoc = attrs.swiftdoc,
563564
swiftmodule = attrs.swiftmodule,
564565
swiftinterface = attrs.swiftinterface,
@@ -585,7 +586,7 @@ def _copy_swiftmodule(ctx, framework_files, clang_module):
585586
return [
586587
# only add the swift module, the objc modulemap is already listed as a header,
587588
# and it will be discovered via the framework search path
588-
swift_common.create_module(
589+
create_swift_module_context(
589590
name = swiftmodule_name,
590591
clang = clang_module,
591592
swift = swift_module,
@@ -600,13 +601,13 @@ def _get_merged_swift_info(ctx, framework_files, transitive_deps, clang_module):
600601
swift_info_fields["modules"] = _copy_swiftmodule(ctx, framework_files, clang_module)
601602
else:
602603
swift_info_fields["modules"] = [
603-
swift_common.create_module(
604+
create_swift_module_context(
604605
name = ctx.attr.framework_name,
605606
clang = clang_module,
606607
),
607608
]
608609

609-
return swift_common.create_swift_info(**swift_info_fields)
610+
return SwiftInfo(**swift_info_fields)
610611

611612
def _merge_root_infoplists(ctx):
612613
if ctx.attr.infoplists == None or len(ctx.attr.infoplists) == 0:
@@ -1104,15 +1105,15 @@ def _apple_framework_packaging_impl(ctx):
11041105

11051106
# rules_swift 2.x no longers takes compilation_context from CcInfo, need to pass it in via SwiftInfo's clang_module
11061107
if virtualize_frameworks:
1107-
clang_module = swift_common.create_clang_module(
1108+
clang_module = create_clang_module_inputs(
11081109
module_map = None,
11091110
compilation_context = compilation_context,
11101111
)
11111112
else:
11121113
# Setup the `clang` attr of the Swift module for non-vfs case this is required to have it locate the modulemap
11131114
# and headers correctly.
11141115
module_map = outputs.modulemaps[0] if outputs.modulemaps else None
1115-
clang_module = swift_common.create_clang_module(
1116+
clang_module = create_clang_module_inputs(
11161117
module_map = module_map,
11171118
compilation_context = cc_common.create_compilation_context(
11181119
headers = depset(_compact(

rules/framework/vfs_overlay.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ to each of the entries.
1010
"""
1111

1212
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
13-
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_common")
13+
load("@build_bazel_rules_swift//swift:providers.bzl", "SwiftInfo")
1414
load("//rules:features.bzl", "feature_names")
1515
load("//rules:providers.bzl", "FrameworkInfo")
1616

@@ -298,7 +298,7 @@ def _framework_vfs_overlay_impl(ctx):
298298
files = depset([vfs.vfsoverlay_file]),
299299
vfs_info = vfs.vfs_info,
300300
),
301-
swift_common.create_swift_info(),
301+
SwiftInfo(),
302302
]
303303

304304
def _merge_vfs_infos(base, vfs_infos):

rules/transition_support.bzl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def _is_arch_supported_for_target_tuple(*, environment_arch, minimum_os_version,
252252
def _command_line_options(
253253
*,
254254
apple_platforms = [],
255-
emit_swiftinterface = False,
256255
environment_arch = None,
257256
force_bundle_outputs = False,
258257
minimum_os_version,
@@ -267,8 +266,6 @@ def _command_line_options(
267266
first element will be applied to `platforms` as that will be what is resolved by the
268267
underlying rule. Defaults to an empty list, which will signal to Bazel that platform
269268
mapping can take place as a fallback measure.
270-
emit_swiftinterface: Wheither to emit swift interfaces for the given target. Defaults to
271-
`False`.
272269
environment_arch: A valid Apple environment when applicable with its architecture as a
273270
string (for example `sim_arm64` from `ios_sim_arm64`, or `arm64` from `ios_arm64`), or
274271
None to infer a value from command line options passed through settings.
@@ -339,7 +336,6 @@ def _command_line_options(
339336
platform = "watchos",
340337
platform_type = platform_type,
341338
),
342-
"@build_bazel_rules_swift//swift:emit_swiftinterface": emit_swiftinterface,
343339
}
344340

345341
def _apple_rule_base_transition_impl(settings, attr):
@@ -351,7 +347,6 @@ def _apple_rule_base_transition_impl(settings, attr):
351347
# PATCH: end
352348

353349
return _command_line_options(
354-
emit_swiftinterface = hasattr(attr, "_emitswiftinterface"),
355350
environment_arch = _environment_archs(platform_type, settings)[0],
356351
minimum_os_version = minimum_os_version,
357352
platform_type = platform_type,
@@ -401,7 +396,6 @@ _apple_rule_base_transition_outputs = [
401396
"//command_line_option:platforms",
402397
"//command_line_option:tvos_minimum_os",
403398
"//command_line_option:watchos_minimum_os",
404-
"@build_bazel_rules_swift//swift:emit_swiftinterface",
405399
]
406400

407401
_apple_rule_base_transition = transition(
@@ -420,11 +414,6 @@ def _apple_platform_split_transition_impl(settings, attr):
420414
minimum_os_version = _rules_ios_minimum_os_version(platform_type, attr)
421415
# PATCH: end
422416

423-
# iOS and tvOS static frameworks require underlying swift_library targets generate a Swift
424-
# interface file. These rules define a private attribute called `_emitswiftinterface` that
425-
# let's this transition flip rules_swift config down the build graph.
426-
emit_swiftinterface = hasattr(attr, "_emitswiftinterface")
427-
428417
if settings["//command_line_option:incompatible_enable_apple_toolchain_resolution"]:
429418
platforms = (
430419
settings["//command_line_option:apple_platforms"] or
@@ -445,7 +434,6 @@ def _apple_platform_split_transition_impl(settings, attr):
445434
if str(platform) not in output_dictionary:
446435
output_dictionary[str(platform)] = _command_line_options(
447436
apple_platforms = apple_platforms,
448-
emit_swiftinterface = emit_swiftinterface,
449437
minimum_os_version = minimum_os_version,
450438
platform_type = platform_type,
451439
settings = settings,
@@ -492,7 +480,6 @@ def _apple_platform_split_transition_impl(settings, attr):
492480
continue
493481

494482
output_dictionary[found_cpu] = _command_line_options(
495-
emit_swiftinterface = emit_swiftinterface,
496483
environment_arch = environment_arch,
497484
minimum_os_version = minimum_os_version,
498485
platform_type = platform_type,

0 commit comments

Comments
 (0)