Skip to content

Commit

Permalink
[6.4.0] Remove PackageGroupConfiguredTarget.isAvailableFor function (#…
Browse files Browse the repository at this point in the history
…19444)

Support for checking if a target exists inside an allowlist was added
inside PackageSpecificationProvider as a `contains` function (c4d5fdb).
`PackageGroupConfiguredTarget.isAvailableFor` can be removed.

Cherrypicking beb6ea8.
  • Loading branch information
kotlaja authored Sep 8, 2023
1 parent 3aea7d7 commit 2b93256
Showing 1 changed file with 0 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@

package com.google.devtools.build.lib.analysis.configuredtargets;

import static net.starlark.java.eval.Module.ofInnermostEnclosingStarlarkFunction;

import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.Allowlist;
import com.google.devtools.build.lib.analysis.FileProvider;
import com.google.devtools.build.lib.analysis.PackageSpecificationProvider;
import com.google.devtools.build.lib.analysis.TargetContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.cmdline.BazelModuleContext;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
Expand All @@ -32,12 +28,6 @@
import com.google.devtools.build.lib.packages.PackageSpecification.PackageGroupContents;
import com.google.devtools.build.lib.packages.Provider;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
import net.starlark.java.eval.Starlark;
import net.starlark.java.eval.StarlarkThread;

/**
* Dummy ConfiguredTarget for package groups. Contains no functionality, since package groups are
Expand Down Expand Up @@ -86,24 +76,4 @@ protected Info rawGetStarlarkProvider(Provider.Key providerKey) {
protected Object rawGetStarlarkProvider(String providerKey) {
return null;
}

@StarlarkMethod(
name = "isAvailableFor",
documented = false,
parameters = {
@Param(
name = "label",
allowedTypes = {@ParamType(type = Label.class)})
},
useStarlarkThread = true)
public boolean starlarkMatches(Label label, StarlarkThread starlarkThread) throws EvalException {
RepositoryName repository =
BazelModuleContext.of(ofInnermostEnclosingStarlarkFunction(starlarkThread))
.label()
.getRepository();
if (!"@_builtins".equals(repository.getNameWithAt())) {
throw Starlark.errorf("private API only for use by builtins");
}
return Allowlist.isAvailableFor(packageSpecificationProvider.getPackageSpecifications(), label);
}
}

0 comments on commit 2b93256

Please sign in to comment.