本文整理匯總了Java中com.google.devtools.build.lib.syntax.SkylarkList.castSkylarkListOrNoneToList方法的典型用法代碼示例。如果您正苦於以下問題:Java SkylarkList.castSkylarkListOrNoneToList方法的具體用法?Java SkylarkList.castSkylarkListOrNoneToList怎麽用?Java SkylarkList.castSkylarkListOrNoneToList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.devtools.build.lib.syntax.SkylarkList
的用法示例。
在下文中一共展示了SkylarkList.castSkylarkListOrNoneToList方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createInstanceFromSkylark
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
@Override
protected PlatformInfo createInstanceFromSkylark(Object[] args, Location loc)
throws EvalException {
// Based on SIGNATURE above, the args are label, constraint_values.
Label label = (Label) args[0];
List<ConstraintValueInfo> constraintValues =
SkylarkList.castSkylarkListOrNoneToList(
args[1], ConstraintValueInfo.class, "constraint_values");
try {
return builder()
.setLabel(label)
.addConstraints(constraintValues)
.setLocation(loc)
.build();
} catch (DuplicateConstraintException dce) {
throw new EvalException(
loc, String.format("Cannot create PlatformInfo: %s", dce.getMessage()));
}
}
示例2: setAllowedFileTypes
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
private static void setAllowedFileTypes(
String attr, Object fileTypesObj, FuncallExpression ast, Attribute.Builder<?> builder)
throws EvalException {
if (fileTypesObj == Boolean.TRUE) {
builder.allowedFileTypes(FileTypeSet.ANY_FILE);
} else if (fileTypesObj == Boolean.FALSE) {
builder.allowedFileTypes(FileTypeSet.NO_FILE);
} else if (fileTypesObj instanceof SkylarkFileType) {
// TODO(laurentlb): deprecated, to be removed
builder.allowedFileTypes(((SkylarkFileType) fileTypesObj).getFileTypeSet());
} else if (fileTypesObj instanceof SkylarkList) {
List<String> arg =
SkylarkList.castSkylarkListOrNoneToList(
fileTypesObj, String.class, "allow_files argument");
builder.allowedFileTypes(FileType.of(arg));
} else {
throw new EvalException(
ast.getLocation(), attr + " should be a boolean or a string list");
}
}
示例3: registerSpawnAction
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
/**
* Setup for spawn actions common between {@link #run} and {@link #runShell}.
*
* <p>{@code builder} should have either executable or a command set.
*/
private void registerSpawnAction(
SkylarkList outputs,
Object inputs,
Object mnemonicUnchecked,
Object progressMessage,
Boolean useDefaultShellEnv,
Object envUnchecked,
Object executionRequirementsUnchecked,
Object inputManifestsUnchecked,
SpawnAction.Builder builder)
throws EvalException {
// TODO(bazel-team): builder still makes unnecessary copies of inputs, outputs and args.
Iterable<Artifact> inputArtifacts;
if (inputs instanceof SkylarkList) {
inputArtifacts = ((SkylarkList) inputs).getContents(Artifact.class, "inputs");
builder.addInputs(inputArtifacts);
} else {
inputArtifacts = ((SkylarkNestedSet) inputs).toCollection(Artifact.class);
builder.addInputs(((SkylarkNestedSet) inputs).getSet(Artifact.class));
}
builder.addOutputs(outputs.getContents(Artifact.class, "outputs"));
// The actual command can refer to an executable from the inputs, which could require
// some runfiles. Consequently, we add the runfiles of all inputs of this action manually.
for (Artifact current : inputArtifacts) {
FilesToRunProvider provider = context.getExecutableRunfiles(current);
if (provider != null) {
builder.addTool(provider);
}
}
String mnemonic = getMnemonic(mnemonicUnchecked);
builder.setMnemonic(mnemonic);
if (envUnchecked != Runtime.NONE) {
builder.setEnvironment(
ImmutableMap.copyOf(
SkylarkDict.castSkylarkDictOrNoneToDict(
envUnchecked, String.class, String.class, "env")));
}
if (progressMessage != Runtime.NONE) {
builder.setProgressMessageNonLazy((String) progressMessage);
}
if (EvalUtils.toBoolean(useDefaultShellEnv)) {
builder.useDefaultShellEnvironment();
}
if (executionRequirementsUnchecked != Runtime.NONE) {
builder.setExecutionInfo(
ImmutableMap.copyOf(
SkylarkDict.castSkylarkDictOrNoneToDict(
executionRequirementsUnchecked,
String.class,
String.class,
"execution_requirements")));
}
if (inputManifestsUnchecked != Runtime.NONE) {
for (RunfilesSupplier supplier : SkylarkList.castSkylarkListOrNoneToList(
inputManifestsUnchecked, RunfilesSupplier.class, "runfiles suppliers")) {
builder.addRunfilesSupplier(supplier);
}
}
// Always register the action
ruleContext.registerAction(builder.build(ruleContext));
}