diff options
Diffstat (limited to 'src/main/java')
5 files changed, 4 insertions, 134 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintSettingInfo.java b/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintSettingInfo.java index 907a1b977c..d2b5e1e83b 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintSettingInfo.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintSettingInfo.java @@ -14,7 +14,6 @@ package com.google.devtools.build.lib.analysis.platform; -import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.events.Location; @@ -25,9 +24,6 @@ import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec. import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; -import com.google.devtools.build.lib.syntax.EvalException; -import com.google.devtools.build.lib.syntax.FunctionSignature; -import com.google.devtools.build.lib.syntax.SkylarkType; import com.google.devtools.build.lib.util.Fingerprint; /** Provider for a platform constraint setting that is available to be fulfilled. */ @@ -42,30 +38,9 @@ public class ConstraintSettingInfo extends NativeInfo { /** Name used in Skylark for accessing this provider. */ public static final String SKYLARK_NAME = "ConstraintSettingInfo"; - private static final FunctionSignature.WithValues<Object, SkylarkType> SIGNATURE = - FunctionSignature.WithValues.create( - FunctionSignature.of( - /*numMandatoryPositionals=*/ 1, - /*numOptionalPositionals=*/ 0, - /*numMandatoryNamedOnly*/ 0, - /*starArg=*/ false, - /*kwArg=*/ false, - /*names=*/ "label"), - /*defaultValues=*/ null, - /*types=*/ ImmutableList.<SkylarkType>of(SkylarkType.of(Label.class))); - /** Skylark constructor and identifier for this provider. */ public static final NativeProvider<ConstraintSettingInfo> PROVIDER = - new NativeProvider<ConstraintSettingInfo>( - ConstraintSettingInfo.class, SKYLARK_NAME, SIGNATURE) { - @Override - protected ConstraintSettingInfo createInstanceFromSkylark(Object[] args, Location loc) - throws EvalException { - // Based on SIGNATURE above, the args are label. - Label label = (Label) args[0]; - return ConstraintSettingInfo.create(label, loc); - } - }; + new NativeProvider<ConstraintSettingInfo>(ConstraintSettingInfo.class, SKYLARK_NAME) {}; private final Label label; diff --git a/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintValueInfo.java b/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintValueInfo.java index 7603f0820f..345edb9dee 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintValueInfo.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintValueInfo.java @@ -14,7 +14,6 @@ package com.google.devtools.build.lib.analysis.platform; -import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.events.Location; @@ -25,9 +24,6 @@ import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec. import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; -import com.google.devtools.build.lib.syntax.EvalException; -import com.google.devtools.build.lib.syntax.FunctionSignature; -import com.google.devtools.build.lib.syntax.SkylarkType; import com.google.devtools.build.lib.util.Fingerprint; /** Provider for a platform constraint value that fulfills a {@link ConstraintSettingInfo}. */ @@ -42,32 +38,9 @@ public class ConstraintValueInfo extends NativeInfo { /** Name used in Skylark for accessing this provider. */ public static final String SKYLARK_NAME = "ConstraintValueInfo"; - private static final FunctionSignature.WithValues<Object, SkylarkType> SIGNATURE = - FunctionSignature.WithValues.create( - FunctionSignature.of( - /*numMandatoryPositionals=*/ 2, - /*numOptionalPositionals=*/ 0, - /*numMandatoryNamedOnly*/ 0, - /*starArg=*/ false, - /*kwArg=*/ false, - /*names=*/ "label", - "constraint_setting"), - /*defaultValues=*/ null, - /*types=*/ ImmutableList.<SkylarkType>of( - SkylarkType.of(Label.class), SkylarkType.of(ConstraintSettingInfo.class))); - /** Skylark constructor and identifier for this provider. */ public static final NativeProvider<ConstraintValueInfo> SKYLARK_CONSTRUCTOR = - new NativeProvider<ConstraintValueInfo>(ConstraintValueInfo.class, SKYLARK_NAME, SIGNATURE) { - @Override - protected ConstraintValueInfo createInstanceFromSkylark(Object[] args, Location loc) - throws EvalException { - // Based on SIGNATURE above, the args are label, constraint_setting. - Label label = (Label) args[0]; - ConstraintSettingInfo constraint = (ConstraintSettingInfo) args[1]; - return ConstraintValueInfo.create(constraint, label, loc); - } - }; + new NativeProvider<ConstraintValueInfo>(ConstraintValueInfo.class, SKYLARK_NAME) {}; private final ConstraintSettingInfo constraint; private final Label label; diff --git a/src/main/java/com/google/devtools/build/lib/analysis/platform/DeclaredToolchainInfo.java b/src/main/java/com/google/devtools/build/lib/analysis/platform/DeclaredToolchainInfo.java index b72b8894c9..354969ca41 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/platform/DeclaredToolchainInfo.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/platform/DeclaredToolchainInfo.java @@ -21,7 +21,7 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; /** - * Provider for a toolchain declaration, which assosiates a toolchain type, the execution and target + * Provider for a toolchain declaration, which associates a toolchain type, the execution and target * constraints, and the actual toolchain label. The toolchain is then available for use but will be * lazily resolved only when it is actually needed for toolchain-aware rules. Toolchain definitions * are exposed to Skylark and Bazel via {@link ToolchainInfo} providers. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java b/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java index 6b57ddf786..b5e232883d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java @@ -34,10 +34,6 @@ import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec. import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; -import com.google.devtools.build.lib.syntax.EvalException; -import com.google.devtools.build.lib.syntax.FunctionSignature; -import com.google.devtools.build.lib.syntax.SkylarkList; -import com.google.devtools.build.lib.syntax.SkylarkType; import com.google.devtools.build.lib.util.Fingerprint; import java.util.ArrayList; import java.util.Collection; @@ -57,46 +53,9 @@ public class PlatformInfo extends NativeInfo { /** Name used in Skylark for accessing this provider. */ public static final String SKYLARK_NAME = "PlatformInfo"; - private static final FunctionSignature.WithValues<Object, SkylarkType> SIGNATURE = - FunctionSignature.WithValues.create( - FunctionSignature.of( - /*numMandatoryPositionals=*/ 2, - /*numOptionalPositionals=*/ 0, - /*numMandatoryNamedOnly*/ 0, - /*starArg=*/ false, - /*kwArg=*/ false, - /*names=*/ "label", - "constraint_values"), - /*defaultValues=*/ null, - /*types=*/ ImmutableList.<SkylarkType>of( - SkylarkType.of(Label.class), - SkylarkType.Combination.of( - SkylarkType.LIST, SkylarkType.of(ConstraintValueInfo.class)))); - /** Skylark constructor and identifier for this provider. */ public static final NativeProvider<PlatformInfo> SKYLARK_CONSTRUCTOR = - new NativeProvider<PlatformInfo>(PlatformInfo.class, SKYLARK_NAME, SIGNATURE) { - @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())); - } - } - }; + new NativeProvider<PlatformInfo>(PlatformInfo.class, SKYLARK_NAME) {}; private final Label label; private final ImmutableMap<ConstraintSettingInfo, ConstraintValueInfo> constraints; diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformCommon.java b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformCommon.java index 62b3396d77..e68a461390 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformCommon.java @@ -15,9 +15,6 @@ package com.google.devtools.build.lib.rules.platform; import com.google.devtools.build.lib.analysis.TemplateVariableInfo; -import com.google.devtools.build.lib.analysis.platform.ConstraintSettingInfo; -import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; -import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.analysis.platform.ToolchainInfo; import com.google.devtools.build.lib.packages.Provider; import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; @@ -43,40 +40,6 @@ public class PlatformCommon { } @SkylarkCallable( - name = PlatformInfo.SKYLARK_NAME, - doc = - "The provider constructor for PlatformInfo. The constructor takes the list of " - + "ConstraintValueInfo providers that defines the platform.", - structField = true - ) - public Provider getPlatformInfoConstructor() { - return PlatformInfo.SKYLARK_CONSTRUCTOR; - } - - @SkylarkCallable( - name = ConstraintSettingInfo.SKYLARK_NAME, - doc = - "The provider constructor for ConstraintSettingInfo. The constructor takes the label that " - + "uniquely identifies the constraint (and which should always be ctx.label).", - structField = true - ) - public Provider getConstraintSettingInfoConstructor() { - return ConstraintSettingInfo.PROVIDER; - } - - @SkylarkCallable( - name = ConstraintValueInfo.SKYLARK_NAME, - doc = - "The provider constructor for ConstraintValueInfo. The constructor takes the label that " - + "uniquely identifies the constraint value (and which should always be ctx.label), " - + "and the ConstraintSettingInfo which the value belongs to.", - structField = true - ) - public Provider getConstraintValueInfoConstructor() { - return ConstraintValueInfo.SKYLARK_CONSTRUCTOR; - } - - @SkylarkCallable( name = ToolchainInfo.SKYLARK_NAME, doc = "The provider constructor for ToolchainInfo. The constructor takes the type of the " |