diff options
author | 2018-06-11 13:15:43 -0700 | |
---|---|---|
committer | 2018-06-11 13:17:22 -0700 | |
commit | c7eef96da80ace358e1d19c7b090765747281cfd (patch) | |
tree | e1deefb8baf4b10d19cf2b25df06c8982457d6ee | |
parent | 8c666d999699f788d4ff286a4a30c9dab0beb5b0 (diff) |
Migrate remaining assorted skylark types to skylarkbuildapi
RELNOTES: None.
PiperOrigin-RevId: 200100871
23 files changed, 465 insertions, 180 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index 352dd39972..b3723d09f4 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD @@ -580,6 +580,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/shell", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi", + "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform", "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/skyframe", @@ -888,6 +889,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/collect/nestedset", "//src/main/java/com/google/devtools/build/lib/concurrent", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", + "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/common/options", "//third_party:auto_value", @@ -1111,6 +1113,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/buildeventstream", "//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_proto", "//src/main/java/com/google/devtools/build/lib/concurrent", + "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/protobuf:test_status_java_proto", "//third_party:guava", diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java index b1d40f5be7..bd68b48e3e 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java @@ -19,20 +19,14 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety; 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.skylarkbuildapi.platform.PlatformConfigurationApi; import java.util.List; /** A configuration fragment describing the current platform configuration. */ @AutoCodec @ThreadSafety.Immutable -@SkylarkModule( - name = "platform", - doc = "The platform configuration.", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT -) -public class PlatformConfiguration extends BuildConfiguration.Fragment { +public class PlatformConfiguration extends BuildConfiguration.Fragment + implements PlatformConfigurationApi { private final Label hostPlatform; private final ImmutableList<String> extraExecutionPlatforms; private final ImmutableList<Label> targetPlatforms; @@ -53,7 +47,7 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment { this.enabledToolchainTypes = enabledToolchainTypes; } - @SkylarkCallable(name = "host_platform", structField = true, doc = "The current host platform") + @Override public Label getHostPlatform() { return hostPlatform; } @@ -66,7 +60,7 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment { return extraExecutionPlatforms; } - @SkylarkCallable(name = "platforms", structField = true, doc = "The current target platforms") + @Override public ImmutableList<Label> getTargetPlatforms() { return targetPlatforms; } @@ -79,11 +73,7 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment { return extraToolchains; } - @SkylarkCallable( - name = "enabled_toolchain_types", - structField = true, - doc = "The set of toolchain types enabled for platform-based toolchain selection." - ) + @Override public List<Label> getEnabledToolchainTypes() { return enabledToolchainTypes; } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java index a53b79950e..d73bc22245 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java @@ -32,8 +32,7 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; +import com.google.devtools.build.lib.skylarkbuildapi.ToolchainContextApi; import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; import com.google.devtools.build.lib.syntax.EvalException; @@ -48,12 +47,7 @@ import javax.annotation.Nullable; /** Contains toolchain-related information needed for a {@link RuleContext}. */ @Immutable @ThreadSafe -@SkylarkModule( - name = "ToolchainContext", - category = SkylarkModuleCategory.BUILTIN, - doc = "Stores toolchains available to a given rule." -) -public class ToolchainContext { +public class ToolchainContext implements ToolchainContextApi { public static ToolchainContext create( String targetDescription, PlatformInfo executionPlatform, diff --git a/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java b/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java index 8b41b8075f..06b7aa2d1d 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java +++ b/src/main/java/com/google/devtools/build/lib/packages/FilesetEntry.java @@ -22,7 +22,7 @@ import com.google.common.collect.Lists; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkbuildapi.FilesetEntryApi; import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; import com.google.devtools.build.lib.vfs.PathFragment; @@ -37,13 +37,9 @@ import javax.annotation.Nullable; /** * FilesetEntry is a value object used to represent a "FilesetEntry" inside a "Fileset" BUILD rule. */ -@SkylarkModule( - name = "FilesetEntry", - doc = "", - documented = false) @Immutable @ThreadSafe -public final class FilesetEntry implements SkylarkValue { +public final class FilesetEntry implements SkylarkValue, FilesetEntryApi { public static final SymlinkBehavior DEFAULT_SYMLINK_BEHAVIOR = SymlinkBehavior.COPY; public static final String DEFAULT_STRIP_PREFIX = "."; diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcExecutionDynamicLibraries.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcExecutionDynamicLibraries.java index fbf52685eb..1f488d31be 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcExecutionDynamicLibraries.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcExecutionDynamicLibraries.java @@ -19,19 +19,12 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; +import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcExecutionDynamicLibrariesApi; /** An object that contains the execution-time dynamic libraries of a C++ rule. */ @Immutable @AutoCodec -@SkylarkModule( - name = "cc_execution_dynamic_libraries ", - documented = false, - category = SkylarkModuleCategory.PROVIDER, - doc = "." -) -public final class CcExecutionDynamicLibraries { +public final class CcExecutionDynamicLibraries implements CcExecutionDynamicLibrariesApi { public static final CcExecutionDynamicLibraries EMPTY = new CcExecutionDynamicLibraries(NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER)); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java index 80dca05475..18c64003aa 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java @@ -35,8 +35,7 @@ import com.google.devtools.build.lib.rules.cpp.CcToolchainVariables.StringChunk; import com.google.devtools.build.lib.rules.cpp.CcToolchainVariables.StringValueParser; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; +import com.google.devtools.build.lib.skylarkbuildapi.cpp.FeatureConfigurationApi; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.StringUtil; import com.google.devtools.build.lib.vfs.PathFragment; @@ -993,13 +992,7 @@ public class CcToolchainFeatures implements Serializable { /** Captures the set of enabled features and action configs for a rule. */ @Immutable @AutoCodec - @SkylarkModule( - name = "feature_configuration", - documented = false, - category = SkylarkModuleCategory.BUILTIN, - doc = "Class used to construct command lines from CROSSTOOL features." - ) - public static class FeatureConfiguration { + public static class FeatureConfiguration implements FeatureConfigurationApi { private final ImmutableSet<String> enabledFeatureNames; private final ImmutableList<Feature> enabledFeatures; private final ImmutableSet<String> enabledActionConfigActionNames; diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainVariables.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainVariables.java index 093837c046..6733f30263 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainVariables.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainVariables.java @@ -32,8 +32,7 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.ExpansionException; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; +import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcToolchainVariablesApi; import java.io.Serializable; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -49,12 +48,7 @@ import javax.annotation.Nullable; * <p>TODO(b/32655571): Investigate cleanup once implicit iteration is not needed. Variables * instance could serve as a top level View used to expand all flag_groups. */ -@SkylarkModule( - name = "variables", - documented = false, - category = SkylarkModuleCategory.BUILTIN, - doc = "Class encapsulating build variables.") -public abstract class CcToolchainVariables { +public abstract class CcToolchainVariables implements CcToolchainVariablesApi { /** * A piece of a single string value. diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/BUILD b/src/main/java/com/google/devtools/build/lib/rules/platform/BUILD index f398be1057..c59874970e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/BUILD @@ -21,6 +21,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/analysis/platform", "//src/main/java/com/google/devtools/build/lib/analysis/platform:utils", + "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform", "//third_party:guava", ], ) 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 e68a461390..b3aff82b62 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 @@ -17,40 +17,18 @@ package com.google.devtools.build.lib.rules.platform; import com.google.devtools.build.lib.analysis.TemplateVariableInfo; 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; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.syntax.SkylarkSignatureProcessor; +import com.google.devtools.build.lib.skylarkbuildapi.platform.PlatformCommonApi; /** Skylark namespace used to interact with the platform APIs. */ -@SkylarkModule( - name = "platform_common", - doc = "Functions for Skylark to interact with the platform APIs." -) -public class PlatformCommon { +public class PlatformCommon implements PlatformCommonApi { - @SkylarkCallable( - name = TemplateVariableInfo.SKYLARK_NAME, - doc = "The provider used to retrieve the provider that contains the template variables " - + "defined by a particular toolchain, for example by calling " - + "ctx.attr._cc_toolchain[platform_common.TemplateVariableInfo].make_variables[<name>]", - structField = true - ) + @Override public Provider getMakeVariableProvider() { return TemplateVariableInfo.PROVIDER; } - @SkylarkCallable( - name = ToolchainInfo.SKYLARK_NAME, - doc = - "The provider constructor for ToolchainInfo. The constructor takes the type of the " - + "toolchain, and a map of the toolchain's data.", - structField = true - ) + @Override public Provider getToolchainInfoConstructor() { return ToolchainInfo.PROVIDER; } - - static { - SkylarkSignatureProcessor.configureSkylarkFunctions(PlatformCommon.class); - } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java index a5706d9bc2..353d9038af 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java @@ -26,8 +26,7 @@ import com.google.devtools.build.lib.analysis.config.InvalidConfigurationExcepti import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; +import com.google.devtools.build.lib.skylarkbuildapi.ProtoConfigurationApi; import com.google.devtools.common.options.Converters; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionDocumentationCategory; @@ -40,12 +39,7 @@ import java.util.List; @Immutable // This module needs to be exported to Skylark so it can be passed as a mandatory host/target // configuration fragment in aspect definitions. -@SkylarkModule( - name = "proto", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT, - doc = "A configuration fragment representing protocol buffers." -) -public class ProtoConfiguration extends Fragment { +public class ProtoConfiguration extends Fragment implements ProtoConfigurationApi { /** Command line options. */ @AutoCodec(strategy = AutoCodec.Strategy.PUBLIC_FIELDS) public static class Options extends FragmentOptions { diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java index 48158ba420..26075cf07f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java @@ -21,8 +21,7 @@ import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; 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.skylarkbuildapi.ProtoSourcesProviderApi; // TODO(carmi): Rename the class to ProtoInfoProvider. /** @@ -31,9 +30,9 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; */ @AutoValue @Immutable -@SkylarkModule(name = "ProtoSourcesProvider", doc = "") @AutoCodec -public abstract class ProtoSourcesProvider implements TransitiveInfoProvider { +public abstract class ProtoSourcesProvider + implements TransitiveInfoProvider, ProtoSourcesProviderApi<Artifact> { /** The name of the field in Skylark used to access this class. */ public static final String SKYLARK_NAME = "proto"; @@ -60,30 +59,18 @@ public abstract class ProtoSourcesProvider implements TransitiveInfoProvider { * Transitive imports including weak dependencies This determines the order of "-I" arguments to * the protocol compiler, and that is probably important */ - @SkylarkCallable( - name = "transitive_imports", - doc = "Transitive imports including weak dependencies.", - structField = true - ) + @Override public abstract NestedSet<Artifact> getTransitiveImports(); /** Returns the proto sources for this rule and all its dependent protocol buffer rules. */ - @SkylarkCallable( - name = "transitive_sources", - doc = "Proto sources for this rule and all its dependent protocol buffer rules.", - structField = true - ) + @Override // TODO(bazel-team): The difference between transitive imports and transitive proto sources // should never be used by Skylark or by an Aspect. One of these two should be removed, // preferably soon, before Skylark users start depending on them. public abstract NestedSet<Artifact> getTransitiveProtoSources(); /** Returns the proto sources from the 'srcs' attribute. */ - @SkylarkCallable( - name = "direct_sources", - doc = "Proto sources from the 'srcs' attribute.", - structField = true - ) + @Override public abstract ImmutableList<Artifact> getDirectProtoSources(); /** @@ -93,14 +80,7 @@ public abstract class ProtoSourcesProvider implements TransitiveInfoProvider { * <p>This must be a set to avoid collecting the same source twice when depending on 2 proxy * proto_library's that depend on the same proto_library. */ - @SkylarkCallable( - name = "check_deps_sources", - doc = - "Proto sources from the 'srcs' attribute. If the library is a proxy library " - + "that has no sources, it contains the check_deps_sources " - + "from this library's direct deps.", - structField = true - ) + @Override public abstract NestedSet<Artifact> getCheckDepsProtoSources(); /** @@ -109,11 +89,7 @@ public abstract class ProtoSourcesProvider implements TransitiveInfoProvider { * (remember that proto-compiler reads all transitive .proto files, even when producing the * direct-srcs descriptor set) */ - @SkylarkCallable( - name = "direct_descriptor_set", - doc = "The FileDescriptorSet of the direct sources. If no srcs, contains an empty file. ", - structField = true - ) + @Override public abstract Artifact directDescriptorSet(); /** @@ -122,25 +98,14 @@ public abstract class ProtoSourcesProvider implements TransitiveInfoProvider { * (remember that proto-compiler reads all transitive .proto files, even when producing the * direct-srcs descriptor set) */ - @SkylarkCallable( - name = "transitive_descriptor_sets", - doc = - "A set of FileDescriptorSet files of all dependent proto_library rules, and this one's. " - + "This is not the same as passing --include_imports to proto-compiler. " - + "Will be empty if no dependencies. ", - structField = true - ) + @Override public abstract NestedSet<Artifact> transitiveDescriptorSets(); /** * Directories of .proto sources collected from the transitive closure. These flags will be passed * to {@code protoc} in the specified order, via the {@code --proto_path} flag. */ - @SkylarkCallable( - name = "transitive_proto_path", - doc = "A set of proto source roots collected from the transitive closure of this rule.", - structField = true - ) + @Override public abstract NestedSet<String> getTransitiveProtoPathFlags(); ProtoSourcesProvider() {} diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/SkylarkTestingModule.java b/src/main/java/com/google/devtools/build/lib/rules/test/SkylarkTestingModule.java index a2fa110a85..225298cf5b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/SkylarkTestingModule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/SkylarkTestingModule.java @@ -15,59 +15,18 @@ package com.google.devtools.build.lib.rules.test; import com.google.devtools.build.lib.analysis.test.ExecutionInfo; import com.google.devtools.build.lib.analysis.test.TestEnvironmentInfo; -import com.google.devtools.build.lib.skylarkinterface.Param; -import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkbuildapi.test.TestingModuleApi; import com.google.devtools.build.lib.syntax.SkylarkDict; /** A class that exposes testing infrastructure to skylark. */ -@SkylarkModule( - name = "testing", - doc = "Helper methods for skylark to access testing infrastructure." -) -public class SkylarkTestingModule { +public class SkylarkTestingModule implements TestingModuleApi { - // TODO(bazel-team): Change this BuiltinFunction to be the actual ExecutionInfo.PROVIDER. - @SkylarkCallable( - name = "ExecutionInfo", - doc = - "Creates a new execution info provider. Use this provider to specify special" - + "environments requirements needed to run tests.", - parameters = { - @Param( - name = "requirements", - type = SkylarkDict.class, - named = false, - positional = true, - doc = - "A map of string keys and values to indicate special execution requirements, such as" - + " hardware platforms, etc. These keys and values are passed to the executor of" - + " the test action as parameters to configure the execution environment." - ) - } - ) + @Override public ExecutionInfo executionInfo(SkylarkDict<String, String> requirements) { return new ExecutionInfo(requirements); } - // TODO(bazel-team): Change this BuiltinFunction to be the actual TestEnvironmentInfo.PROVIDER. - @SkylarkCallable( - name = "TestEnvironment", - doc = - "Creates a new test environment provider. Use this provider to specify extra" - + "environment variables to be made available during test execution.", - parameters = { - @Param( - name = "environment", - type = SkylarkDict.class, - named = false, - positional = true, - doc = - "A map of string keys and values that represent environment variables and their values." - + " These will be made available during the test execution." - ) - } - ) + @Override public TestEnvironmentInfo testEnvironment(SkylarkDict<String, String> environment) { return new TestEnvironmentInfo(environment); } diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/FilesetEntryApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/FilesetEntryApi.java new file mode 100644 index 0000000000..53bc977177 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/FilesetEntryApi.java @@ -0,0 +1,27 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi; + +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; + +/** + * A value object used to represent an entry inside a "Fileset" BUILD rule. + */ +@SkylarkModule( + name = "FilesetEntry", + doc = "", + documented = false) +public interface FilesetEntryApi { +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProtoConfigurationApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProtoConfigurationApi.java new file mode 100644 index 0000000000..6082ba850b --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProtoConfigurationApi.java @@ -0,0 +1,29 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi; + +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; + +/** + * A configuration fragment representing protocol buffers. + */ +@SkylarkModule( + name = "proto", + category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT, + doc = "A configuration fragment representing protocol buffers." +) +public interface ProtoConfigurationApi { +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProtoSourcesProviderApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProtoSourcesProviderApi.java new file mode 100644 index 0000000000..1468663cab --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProtoSourcesProviderApi.java @@ -0,0 +1,85 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.collect.nestedset.NestedSet; +import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; + +/** + * Info object propagating information about protocol buffer sources. + */ +@SkylarkModule(name = "ProtoSourcesProvider", doc = "") +public interface ProtoSourcesProviderApi<FileT extends FileApi> { + + @SkylarkCallable( + name = "transitive_imports", + doc = "Transitive imports including weak dependencies.", + structField = true + ) + public NestedSet<FileT> getTransitiveImports(); + + @SkylarkCallable( + name = "transitive_sources", + doc = "Proto sources for this rule and all its dependent protocol buffer rules.", + structField = true + ) + // TODO(bazel-team): The difference between transitive imports and transitive proto sources + // should never be used by Skylark or by an Aspect. One of these two should be removed, + // preferably soon, before Skylark users start depending on them. + public NestedSet<FileT> getTransitiveProtoSources(); + + @SkylarkCallable( + name = "direct_sources", + doc = "Proto sources from the 'srcs' attribute.", + structField = true + ) + public ImmutableList<FileT> getDirectProtoSources(); + + @SkylarkCallable( + name = "check_deps_sources", + doc = + "Proto sources from the 'srcs' attribute. If the library is a proxy library " + + "that has no sources, it contains the check_deps_sources " + + "from this library's direct deps.", + structField = true + ) + public NestedSet<FileT> getCheckDepsProtoSources(); + + @SkylarkCallable( + name = "direct_descriptor_set", + doc = "The FileDescriptorSet of the direct sources. If no srcs, contains an empty file. ", + structField = true + ) + public FileT directDescriptorSet(); + + @SkylarkCallable( + name = "transitive_descriptor_sets", + doc = + "A set of FileDescriptorSet files of all dependent proto_library rules, and this one's. " + + "This is not the same as passing --include_imports to proto-compiler. " + + "Will be empty if no dependencies. ", + structField = true + ) + public NestedSet<FileT> transitiveDescriptorSets(); + + @SkylarkCallable( + name = "transitive_proto_path", + doc = "A set of proto source roots collected from the transitive closure of this rule.", + structField = true + ) + public NestedSet<String> getTransitiveProtoPathFlags(); +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ToolchainContextApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ToolchainContextApi.java new file mode 100644 index 0000000000..3441c52044 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ToolchainContextApi.java @@ -0,0 +1,29 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi; + +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; + +/** + * Stores toolchains available to a given rule. + */ +@SkylarkModule( + name = "ToolchainContext", + category = SkylarkModuleCategory.BUILTIN, + doc = "Stores toolchains available to a given rule." +) +public interface ToolchainContextApi { +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcExecutionDynamicLibrariesApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcExecutionDynamicLibrariesApi.java new file mode 100644 index 0000000000..cc1228e498 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcExecutionDynamicLibrariesApi.java @@ -0,0 +1,30 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi.cpp; + +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; + +/** + * An object that contains the execution-time dynamic libraries of a C++ rule. + */ +@SkylarkModule( + name = "cc_execution_dynamic_libraries ", + documented = false, + category = SkylarkModuleCategory.PROVIDER, + doc = "." +) +public interface CcExecutionDynamicLibrariesApi { +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcToolchainVariablesApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcToolchainVariablesApi.java new file mode 100644 index 0000000000..cadcb3f3fb --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcToolchainVariablesApi.java @@ -0,0 +1,29 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi.cpp; + +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; + +/** + * Type encapsulating build variables. + */ +@SkylarkModule( + name = "variables", + documented = false, + category = SkylarkModuleCategory.BUILTIN, + doc = "Class encapsulating build variables.") +public interface CcToolchainVariablesApi { +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/FeatureConfigurationApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/FeatureConfigurationApi.java new file mode 100644 index 0000000000..1940c6efb7 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/FeatureConfigurationApi.java @@ -0,0 +1,30 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi.cpp; + +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; + +/** + * Class used to construct command lines from CROSSTOOL features. + */ +@SkylarkModule( + name = "feature_configuration", + documented = false, + category = SkylarkModuleCategory.BUILTIN, + doc = "Class used to construct command lines from CROSSTOOL features." +) +public interface FeatureConfigurationApi { +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformCommonApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformCommonApi.java new file mode 100644 index 0000000000..e8dfe9a74b --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformCommonApi.java @@ -0,0 +1,47 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi.platform; + +import com.google.devtools.build.lib.skylarkbuildapi.ProviderApi; +import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; + +/** + * Module containing functions to interact with the platform APIs. + */ +@SkylarkModule( + name = "platform_common", + doc = "Functions for Skylark to interact with the platform APIs." +) +public interface PlatformCommonApi { + + @SkylarkCallable( + name = "TemplateVariableInfo", + doc = "The provider used to retrieve the provider that contains the template variables " + + "defined by a particular toolchain, for example by calling " + + "ctx.attr._cc_toolchain[platform_common.TemplateVariableInfo].make_variables[<name>]", + structField = true + ) + public ProviderApi getMakeVariableProvider(); + + @SkylarkCallable( + name = "ToolchainInfo", + doc = + "The provider constructor for ToolchainInfo. The constructor takes the type of the " + + "toolchain, and a map of the toolchain's data.", + structField = true + ) + public ProviderApi getToolchainInfoConstructor(); +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformConfigurationApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformConfigurationApi.java new file mode 100644 index 0000000000..be7b831548 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformConfigurationApi.java @@ -0,0 +1,46 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi.platform; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.cmdline.Label; +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 java.util.List; + +/** + * The platform configuration. + */ +@SkylarkModule( + name = "platform", + doc = "The platform configuration.", + category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT +) +public interface PlatformConfigurationApi { + + @SkylarkCallable(name = "host_platform", structField = true, doc = "The current host platform") + public Label getHostPlatform(); + + @SkylarkCallable(name = "platforms", structField = true, doc = "The current target platforms") + public ImmutableList<Label> getTargetPlatforms(); + + @SkylarkCallable( + name = "enabled_toolchain_types", + structField = true, + doc = "The set of toolchain types enabled for platform-based toolchain selection." + ) + public List<Label> getEnabledToolchainTypes(); +} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/BUILD b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/BUILD index a8d8e947de..ef57962d47 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/BUILD +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/BUILD @@ -20,6 +20,7 @@ java_library( srcs = glob(["*.java"]), deps = [ "//src/main/java/com/google/devtools/build/lib:skylarkinterface", + "//src/main/java/com/google/devtools/build/lib:syntax", "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi", "//third_party:guava", "//third_party:jsr305", diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/TestingModuleApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/TestingModuleApi.java new file mode 100644 index 0000000000..63528c9b56 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/TestingModuleApi.java @@ -0,0 +1,72 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skylarkbuildapi.test; + +import com.google.devtools.build.lib.skylarkinterface.Param; +import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.syntax.SkylarkDict; + +/** + * Helper module for accessing test infrastructure. + */ +@SkylarkModule( + name = "testing", + doc = "Helper methods for skylark to access testing infrastructure." +) +public interface TestingModuleApi { + + // TODO(bazel-team): Change this function to be the actual ExecutionInfo.PROVIDER. + @SkylarkCallable( + name = "ExecutionInfo", + doc = + "Creates a new execution info provider. Use this provider to specify special" + + "environments requirements needed to run tests.", + parameters = { + @Param( + name = "requirements", + type = SkylarkDict.class, + named = false, + positional = true, + doc = + "A map of string keys and values to indicate special execution requirements," + + " such as hardware platforms, etc. These keys and values are passed to the" + + " executor of the test action as parameters to configure the execution" + + " environment." + ) + } + ) + public ExecutionInfoApi executionInfo(SkylarkDict<String, String> requirements); + + // TODO(bazel-team): Change this function to be the actual TestEnvironmentInfo.PROVIDER. + @SkylarkCallable( + name = "TestEnvironment", + doc = + "Creates a new test environment provider. Use this provider to specify extra" + + "environment variables to be made available during test execution.", + parameters = { + @Param( + name = "environment", + type = SkylarkDict.class, + named = false, + positional = true, + doc = + "A map of string keys and values that represent environment variables and their" + + " values. These will be made available during the test execution." + ) + } + ) + public TestEnvironmentInfoApi testEnvironment(SkylarkDict<String, String> environment); +} |