Skip to content

Commit

Permalink
Expose PackageSpecificationInfo provider as a top level symbol
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 558757374
Change-Id: I09ba247ebb611efcebb4ee9f774d1687edd91dd1
  • Loading branch information
kotlaja authored and copybara-github committed Aug 21, 2023
1 parent 1e9334c commit d1d35b2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
import com.google.devtools.build.lib.packages.PackageGroup;
import com.google.devtools.build.lib.packages.PackageSpecification.PackageGroupContents;
import com.google.devtools.build.lib.packages.Provider;
import com.google.devtools.build.lib.starlarkbuildapi.PackageSpecificationProviderApi;
import java.util.Optional;

/**
* A {@link TransitiveInfoProvider} that describes a set of transitive package specifications used
* in package groups.
*/
public class PackageSpecificationProvider extends NativeInfo implements TransitiveInfoProvider {
public class PackageSpecificationProvider extends NativeInfo
implements TransitiveInfoProvider, PackageSpecificationProviderApi {

private static final String STARLARK_NAME = "PackageSpecificationInfo";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.devtools.build.lib.actions.ActionEnvironment;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.RuleSet;
import com.google.devtools.build.lib.analysis.PackageSpecificationProvider;
import com.google.devtools.build.lib.analysis.PlatformConfiguration;
import com.google.devtools.build.lib.analysis.ShellConfiguration;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue;
Expand Down Expand Up @@ -522,6 +523,14 @@ public ImmutableList<RuleSet> requires() {
}
};

static final RuleSet PACKAGING_RULES =
new RuleSet() {
@Override
public void init(ConfiguredRuleClassProvider.Builder builder) {
builder.addBzlToplevel("PackageSpecificationInfo", PackageSpecificationProvider.PROVIDER);
}
};

private static final ImmutableSet<RuleSet> RULE_SETS =
ImmutableSet.of(
BAZEL_SETUP,
Expand All @@ -542,6 +551,7 @@ public ImmutableList<RuleSet> requires() {
J2ObjcRules.INSTANCE,
TestingSupportRules.INSTANCE,
VARIOUS_WORKSPACE_RULES,
PACKAGING_RULES,
// This rule set is a little special: it needs to depend on every configuration fragment
// that has Make variables, so we put it last.
ToolchainRules.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.RuleSet;
import com.google.devtools.build.lib.analysis.PackageSpecificationProvider;
import com.google.devtools.build.lib.analysis.StaticallyLinkedMarkerProvider;
import com.google.devtools.build.lib.bazel.rules.cpp.BazelCcBinaryRule;
import com.google.devtools.build.lib.bazel.rules.cpp.BazelCcImportRule;
Expand Down Expand Up @@ -109,8 +108,6 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {
builder.addStarlarkBuiltinsInternal(
"PropellerOptimizeInfo", PropellerOptimizeProvider.PROVIDER);
builder.addStarlarkBuiltinsInternal("MemProfProfileInfo", MemProfProfileProvider.PROVIDER);
builder.addStarlarkBuiltinsInternal(
"PackageSpecificationInfo", PackageSpecificationProvider.PROVIDER);
builder.addStarlarkBuiltinsInternal("cc_common", bazelCcModule);
builder.addStarlarkBootstrap(
new CcBootstrap(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023 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.starlarkbuildapi;

import com.google.devtools.build.docgen.annot.DocCategory;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.StarlarkBuiltin;

/** Provider which describes a set of transitive package specifications used in package groups. */
@StarlarkBuiltin(
name = "PackageSpecificationInfo",
doc = "Information about transitive package specifications used in package groups.",
category = DocCategory.PROVIDER)
public interface PackageSpecificationProviderApi extends StructApi {}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ load(":common/cc/semantics.bzl", "semantics")
FdoProfileInfo = _builtins.internal.FdoProfileInfo
FdoPrefetchHintsInfo = _builtins.internal.FdoPrefetchHintsInfo
PropellerOptimizeInfo = _builtins.internal.PropellerOptimizeInfo
PackageSpecificationInfo = _builtins.internal.PackageSpecificationInfo
PackageSpecificationInfo = _builtins.toplevel.PackageSpecificationInfo
CcToolchainConfigInfo = _builtins.toplevel.CcToolchainConfigInfo
MemProfProfileInfo = _builtins.internal.MemProfProfileInfo

Expand Down

0 comments on commit d1d35b2

Please sign in to comment.