Expose objc_provider keys sdk_frameworks and weak_sdk_frameworks to skylark
--
MOS_MIGRATED_REVID=135724830
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
index 5f48a9d..7cde0f5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
@@ -388,6 +388,8 @@
DEFINE,
ASSET_CATALOG,
SDK_DYLIB,
+ SDK_FRAMEWORK,
+ WEAK_SDK_FRAMEWORK,
XCDATAMODEL,
MODULE_MAP,
MERGE_ZIP,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java
index caf0021..7e3b443 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java
@@ -47,6 +47,7 @@
.put(Artifact.class, new DirectConverter())
.put(String.class, new DirectConverter())
.put(PathFragment.class, new PathFragmentToStringConverter())
+ .put(SdkFramework.class, new SdkFrameworkToStringConverter())
.put(BundleableFile.class, new BundleableFileToStructConverter())
.build();
@@ -123,6 +124,33 @@
return result.build();
}
}
+
+ /**
+ * A converter that that translates between a java {@link SdkFramework} and a skylark string.
+ */
+ private static class SdkFrameworkToStringConverter implements Converter {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object valueForSkylark(Key<?> javaKey, NestedSet<?> javaValue) {
+ NestedSetBuilder<String> result = NestedSetBuilder.stableOrder();
+ for (SdkFramework framework : (Iterable<SdkFramework>) javaValue) {
+ result.add(framework.getName());
+ }
+ return SkylarkNestedSet.of(String.class, result.build());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterable<?> valueForJava(Key<?> javaKey, Object skylarkValue) {
+ validateTypes(skylarkValue, String.class, javaKey.getSkylarkKeyName());
+ NestedSetBuilder<SdkFramework> result = NestedSetBuilder.stableOrder();
+ for (String path : (Iterable<String>) skylarkValue) {
+ result.add(new SdkFramework(path));
+ }
+ return result.build();
+ }
+ }
/**
* A converter that that translates between a java BundleableFile and a skylark struct.