Skip to content

Commit

Permalink
Allow binary/framework providers to not specify an ObjcProvider
Browse files Browse the repository at this point in the history
These ObjcProviders are used for linking info, so will eventually be removed at
the completion of linking info migration (#16939).  We want to allow starlark
rules to stop specifying them.

PiperOrigin-RevId: 505111482
Change-Id: Ibc4fd874fb755860510d49a1f87d571574799c9e
  • Loading branch information
googlewalt authored and copybara-github committed Jan 27, 2023
1 parent 9815b76 commit 28f9056
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ public ObjcProvider newObjcProvider(Dict<String, Object> kwargs, StarlarkThread
public AppleDynamicFrameworkInfo newDynamicFrameworkProvider(
Object dylibBinary,
Object depsCcInfo,
ObjcProvider depsObjcProvider,
Object depsObjcProvider,
Object dynamicFrameworkDirs,
Object dynamicFrameworkFiles)
Object dynamicFrameworkFiles,
StarlarkThread thread)
throws EvalException {
NestedSet<String> frameworkDirs =
Depset.noneableCast(dynamicFrameworkDirs, String.class, "framework_dirs");
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ ObjcProviderApi<?> newObjcProvider(Dict<String, Object> 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."),
Expand Down Expand Up @@ -295,13 +296,15 @@ ObjcProviderApi<?> newObjcProvider(Dict<String, Object> 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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 28f9056

Please sign in to comment.