diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java index eb247e36504e45..bbc8c97bdfe45a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java @@ -214,9 +214,10 @@ public ObjcProvider newObjcProvider(Dict kwargs, StarlarkThread public AppleDynamicFrameworkInfo newDynamicFrameworkProvider( Object dylibBinary, Object depsCcInfo, - ObjcProvider depsObjcProvider, + Object depsObjcProvider, Object dynamicFrameworkDirs, - Object dynamicFrameworkFiles) + Object dynamicFrameworkFiles, + StarlarkThread thread) throws EvalException { NestedSet frameworkDirs = Depset.noneableCast(dynamicFrameworkDirs, String.class, "framework_dirs"); @@ -225,19 +226,30 @@ public AppleDynamicFrameworkInfo newDynamicFrameworkProvider( Artifact binary = (dylibBinary != Starlark.NONE) ? (Artifact) dylibBinary : null; // TODO(b/252909384): Disallow Starlark.NONE once rules have been migrated to supply CcInfo. CcInfo ccInfo = (depsCcInfo != Starlark.NONE) ? (CcInfo) depsCcInfo : CcInfo.EMPTY; - + ObjcProvider objcProvider; + if (depsObjcProvider != Starlark.NONE) { + objcProvider = (ObjcProvider) depsObjcProvider; + } else { + objcProvider = new ObjcProvider.StarlarkBuilder(thread.getSemantics()).build(); + } return new AppleDynamicFrameworkInfo( - binary, ccInfo, depsObjcProvider, frameworkDirs, frameworkFiles); + binary, ccInfo, objcProvider, frameworkDirs, frameworkFiles); } @Override public AppleExecutableBinaryInfo newExecutableBinaryProvider( - Object executableBinary, Object depsCcInfo, ObjcProvider depsObjcProvider) + Object executableBinary, Object depsCcInfo, Object depsObjcProvider, StarlarkThread thread) throws EvalException { Artifact binary = (executableBinary != Starlark.NONE) ? (Artifact) executableBinary : null; // TODO(b/252909384): Disallow Starlark.NONE once rules have been migrated to supply CcInfo. CcInfo ccInfo = (depsCcInfo != Starlark.NONE) ? (CcInfo) depsCcInfo : CcInfo.EMPTY; - return new AppleExecutableBinaryInfo(binary, ccInfo, depsObjcProvider); + ObjcProvider objcProvider; + if (depsObjcProvider != Starlark.NONE) { + objcProvider = (ObjcProvider) depsObjcProvider; + } else { + objcProvider = new ObjcProvider.StarlarkBuilder(thread.getSemantics()).build(); + } + return new AppleExecutableBinaryInfo(binary, ccInfo, objcProvider); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java index d6afe9836d54ac..8599b85ac8f075 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java @@ -268,6 +268,7 @@ ObjcProviderApi newObjcProvider(Dict kwargs, StarlarkThread t name = "objc", named = true, positional = false, + defaultValue = "None", doc = "An ObjcProvider which contains information about the transitive " + "dependencies linked into the binary."), @@ -295,13 +296,15 @@ ObjcProviderApi newObjcProvider(Dict kwargs, StarlarkThread t doc = "The full set of artifacts that should be included as inputs to link against the " + "dynamic framework") - }) + }, + useStarlarkThread = true) AppleDynamicFrameworkInfoApi newDynamicFrameworkProvider( Object dylibBinary, Object depsCcInfo, - ObjcProviderApiT depsObjcProvider, + Object depsObjcProvider, Object dynamicFrameworkDirs, - Object dynamicFrameworkFiles) + Object dynamicFrameworkFiles, + StarlarkThread thread) throws EvalException; @StarlarkMethod( @@ -330,12 +333,14 @@ AppleDynamicFrameworkInfoApi newDynamicFrameworkProvider( name = "objc", named = true, positional = false, + defaultValue = "None", doc = "An ObjcProvider which contains information about the transitive " + "dependencies linked into the binary.") - }) + }, + useStarlarkThread = true) AppleExecutableBinaryApi newExecutableBinaryProvider( - Object executableBinary, Object depsCcInfo, ObjcProviderApiT depsObjcProvider) + Object executableBinary, Object depsCcInfo, Object depsObjcProvider, StarlarkThread thread) throws EvalException; @StarlarkMethod(