Migrate Tulsi from legacy swift provider to SwiftInfo.
PiperOrigin-RevId: 193514434
diff --git a/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl b/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl
index 96680a9..5400495 100644
--- a/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl
+++ b/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl
@@ -23,6 +23,7 @@
'AppleBundleInfo',
'AppleTestInfo',
'IosExtensionBundleInfo',
+ 'SwiftInfo',
)
# List of all of the attributes that can link from a Tulsi-supported rule to a
@@ -508,7 +509,7 @@
def _collect_module_maps(target):
"""Returns a depset of Clang module maps found on the given target."""
maps = depset()
- if hasattr(target, 'swift'):
+ if SwiftInfo in target:
for module_maps in _getattr_as_list(target, 'objc.module_map'):
maps += module_maps
return maps
@@ -519,7 +520,7 @@
headers = depset()
# swift_* targets put the generated header into their objc provider HEADER
# field.
- if hasattr(target, 'swift') and hasattr(target, 'objc'):
+ if SwiftInfo in target and hasattr(target, 'objc'):
headers += target.objc.header
return headers
@@ -660,9 +661,8 @@
infoplist = None
# Build up any local transitive attributes and apply them.
- swift = _get_opt_attr(target, 'swift')
- if swift:
- transitive_attributes['swift_language_version'] = getattr(swift, 'swift_version', None)
+ if SwiftInfo in target:
+ transitive_attributes['swift_language_version'] = target[SwiftInfo].swift_version
transitive_attributes['has_swift_dependency'] = True
all_attributes = attributes + inheritable_attributes + transitive_attributes
diff --git a/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects_paths.bzl b/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects_paths.bzl
index 8ce3a51..132c6f0 100644
--- a/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects_paths.bzl
+++ b/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects_paths.bzl
@@ -21,6 +21,7 @@
'@build_bazel_rules_apple//apple:providers.bzl',
_AppleBundleInfo='AppleBundleInfo',
_IosExtensionBundleInfo='IosExtensionBundleInfo',
+ _SwiftInfo='SwiftInfo',
)
load(
'@build_bazel_rules_apple//apple/testing:apple_test_rules.bzl',
@@ -31,3 +32,4 @@
AppleBundleInfo = _AppleBundleInfo
AppleTestInfo = _AppleTestInfo
IosExtensionBundleInfo = _IosExtensionBundleInfo
+SwiftInfo = _SwiftInfo