Skip to content

Commit

Permalink
Migrate platform-related skylark objects to skylarkbuildapi
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 198086078
  • Loading branch information
c-parsons authored and Copybara-Service committed May 25, 2018
1 parent 475d91a commit c6cf1b9
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 69 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ filegroup(
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi:srcs",
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp:srcs",
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java:srcs",
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform:srcs",
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository:srcs",
"//src/main/java/com/google/devtools/build/lib/skylarkdebug/module:srcs",
"//src/main/java/com/google/devtools/build/lib/skylarkdebug/proto:srcs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/concurrent",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform",
"//third_party:auto_value",
"//third_party:guava",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@
import com.google.devtools.build.lib.packages.NativeProvider;
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.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.ConstraintSettingInfoApi;
import com.google.devtools.build.lib.util.Fingerprint;

/** Provider for a platform constraint setting that is available to be fulfilled. */
@SkylarkModule(
name = "ConstraintSettingInfo",
doc = "A specific constraint setting that may be used to define a platform.",
category = SkylarkModuleCategory.PROVIDER
)
@Immutable
@AutoCodec
public class ConstraintSettingInfo extends NativeInfo {
public class ConstraintSettingInfo extends NativeInfo implements ConstraintSettingInfoApi {
/** Name used in Skylark for accessing this provider. */
public static final String SKYLARK_NAME = "ConstraintSettingInfo";

Expand All @@ -51,11 +44,7 @@ public class ConstraintSettingInfo extends NativeInfo {
this.label = label;
}

@SkylarkCallable(
name = "label",
doc = "The label of the target that created this constraint.",
structField = true
)
@Override
public Label label() {
return label;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@
import com.google.devtools.build.lib.packages.NativeProvider;
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.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.ConstraintValueInfoApi;
import com.google.devtools.build.lib.util.Fingerprint;

/** Provider for a platform constraint value that fulfills a {@link ConstraintSettingInfo}. */
@SkylarkModule(
name = "ConstraintValueInfo",
doc = "A value for a constraint setting that can be used to define a platform.",
category = SkylarkModuleCategory.PROVIDER
)
@Immutable
@AutoCodec
public class ConstraintValueInfo extends NativeInfo {
public class ConstraintValueInfo extends NativeInfo implements ConstraintValueInfoApi {
/** Name used in Skylark for accessing this provider. */
public static final String SKYLARK_NAME = "ConstraintValueInfo";

Expand All @@ -55,22 +48,12 @@ public class ConstraintValueInfo extends NativeInfo {
this.label = label;
}

@SkylarkCallable(
name = "constraint",
doc =
"The <a href=\"ConstraintSettingInfo.html\">ConstraintSettingInfo</a> this value can be "
+ "applied to.",
structField = true
)
@Override
public ConstraintSettingInfo constraint() {
return constraint;
}

@SkylarkCallable(
name = "label",
doc = "The label of the target that created this constraint value.",
structField = true
)
@Override
public Label label() {
return label;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
import com.google.devtools.build.lib.packages.NativeProvider;
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.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.PlatformInfoApi;
import com.google.devtools.build.lib.util.Fingerprint;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -42,14 +40,9 @@
import javax.annotation.Nullable;

/** Provider for a platform, which is a group of constraints and values. */
@SkylarkModule(
name = "PlatformInfo",
doc = "Provides access to data about a specific platform.",
category = SkylarkModuleCategory.PROVIDER
)
@Immutable
@AutoCodec
public class PlatformInfo extends NativeInfo {
public class PlatformInfo extends NativeInfo implements PlatformInfoApi<ConstraintValueInfo> {
/** Name used in Skylark for accessing this provider. */
public static final String SKYLARK_NAME = "PlatformInfo";

Expand Down Expand Up @@ -90,22 +83,12 @@ static PlatformInfo create(
return new PlatformInfo(label, constraintsBuilder.build(), remoteExecutionProperties, location);
}

@SkylarkCallable(
name = "label",
doc = "The label of the target that created this platform.",
structField = true
)
@Override
public Label label() {
return label;
}

@SkylarkCallable(
name = "constraints",
doc =
"The <a href=\"ConstraintValueInfo.html\">ConstraintValueInfo</a> instances that define "
+ "this platform.",
structField = true
)
@Override
public Iterable<ConstraintValueInfo> constraints() {
return constraints.values().asList();
}
Expand All @@ -119,11 +102,7 @@ public ConstraintValueInfo getConstraint(ConstraintSettingInfo constraint) {
return constraints.get(constraint);
}

@SkylarkCallable(
name = "remoteExecutionProperties",
doc = "Properties that are available for the use of remote execution.",
structField = true
)
@Override
public String remoteExecutionProperties() {
return remoteExecutionProperties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import com.google.devtools.build.lib.packages.NativeInfo;
import com.google.devtools.build.lib.packages.NativeProvider;
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.platform.ToolchainInfoApi;
import com.google.devtools.build.lib.syntax.Environment;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.FunctionSignature;
Expand All @@ -34,14 +33,9 @@
* A provider that supplied information about a specific language toolchain, including what platform
* constraints are required for execution and for the target platform.
*/
@SkylarkModule(
name = "ToolchainInfo",
doc = "Provides access to data about a specific toolchain.",
category = SkylarkModuleCategory.PROVIDER
)
@AutoCodec
@Immutable
public class ToolchainInfo extends NativeInfo {
public class ToolchainInfo extends NativeInfo implements ToolchainInfoApi {

/** Name used in Skylark for accessing this provider. */
public static final String SKYLARK_NAME = "ToolchainInfo";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Description:
# This package contains interfaces representing the skylark "build API"
# (but not the implementation of that API). Ultimately, this package
# may be broken out of the Bazel package hierarchy to be standalone.
# Thus, this package should not depend on Bazel-specific packages (only
# those which contain pure-Skylark concepts, such as the interpreter or
# annotation interfaces).

package(default_visibility = ["//src:__subpackages__"])

licenses(["notice"]) # Apache 2.0

filegroup(
name = "srcs",
srcs = glob(["**"]),
)

java_library(
name = "platform",
srcs = glob(["*.java"]),
deps = [
"//src/main/java/com/google/devtools/build/lib:skylarkinterface",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi",
"//third_party:guava",
"//third_party:jsr305",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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.cmdline.Label;
import com.google.devtools.build.lib.skylarkbuildapi.StructApi;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;

/**
* Info object representing a specific constraint setting that may be used to define a platform.
*/
@SkylarkModule(
name = "ConstraintSettingInfo",
doc = "A specific constraint setting that may be used to define a platform.",
category = SkylarkModuleCategory.PROVIDER
)
public interface ConstraintSettingInfoApi extends StructApi {

@SkylarkCallable(
name = "label",
doc = "The label of the target that created this constraint.",
structField = true
)
public Label label();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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.cmdline.Label;
import com.google.devtools.build.lib.skylarkbuildapi.StructApi;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;

/**
* Info object representing a value for a constraint setting that can be used to define a platform.
*/
@SkylarkModule(
name = "ConstraintValueInfo",
doc = "A value for a constraint setting that can be used to define a platform.",
category = SkylarkModuleCategory.PROVIDER
)
public interface ConstraintValueInfoApi extends StructApi {

@SkylarkCallable(
name = "constraint",
doc =
"The <a href=\"ConstraintSettingInfo.html\">ConstraintSettingInfo</a> this value can be "
+ "applied to.",
structField = true
)
public ConstraintSettingInfoApi constraint();

@SkylarkCallable(
name = "label",
doc = "The label of the target that created this constraint value.",
structField = true
)
public Label label();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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.cmdline.Label;
import com.google.devtools.build.lib.skylarkbuildapi.StructApi;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;

/**
* Info object representing data about a specific platform.
*/
@SkylarkModule(
name = "PlatformInfo",
doc = "Provides access to data about a specific platform.",
category = SkylarkModuleCategory.PROVIDER
)
public interface PlatformInfoApi<ConstraintValueInfoT extends ConstraintValueInfoApi>
extends StructApi {

@SkylarkCallable(
name = "label",
doc = "The label of the target that created this platform.",
structField = true
)
public Label label();

@SkylarkCallable(
name = "constraints",
doc =
"The <a href=\"ConstraintValueInfo.html\">ConstraintValueInfo</a> instances that define "
+ "this platform.",
structField = true
)
public Iterable<ConstraintValueInfoT> constraints();

@SkylarkCallable(
name = "remoteExecutionProperties",
doc = "Properties that are available for the use of remote execution.",
structField = true
)
public String remoteExecutionProperties();
}
Original file line number Diff line number Diff line change
@@ -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.platform;

import com.google.devtools.build.lib.skylarkbuildapi.StructApi;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;

/**
* Info object representing data about a specific toolchain.
*/
@SkylarkModule(
name = "ToolchainInfo",
doc = "Provides access to data about a specific toolchain.",
category = SkylarkModuleCategory.PROVIDER
)
public interface ToolchainInfoApi extends StructApi {
}

0 comments on commit c6cf1b9

Please sign in to comment.