Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tylerwilliams/bazel into …
Browse files Browse the repository at this point in the history
…b3hasher2
  • Loading branch information
tylerwilliams committed Jul 19, 2023
2 parents e9152ae + f4fcb42 commit 81ded64
Show file tree
Hide file tree
Showing 49 changed files with 794 additions and 487 deletions.
8 changes: 1 addition & 7 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bazel_dep(name = "zstd-jni", version = "1.5.2-3")
bazel_dep(name = "blake3", version = "1.3.3")
bazel_dep(name = "zlib", version = "1.2.13")
bazel_dep(name = "rules_cc", version = "0.0.6")
bazel_dep(name = "rules_java", version = "6.1.1")
bazel_dep(name = "rules_java", version = "6.2.2")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "rules_jvm_external", version = "5.2")
bazel_dep(name = "rules_python", version = "0.19.0")
Expand All @@ -29,12 +29,6 @@ single_version_override(
patches = ["//third_party:rules_jvm_external_5.2.patch"],
)

single_version_override(
module_name = "rules_java",
patch_strip = 1,
patches = ["//third_party:rules_java_6.1.0.patch"],
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
# We don't yet specify the maven coordinates in the MODULE.bazel to avoid duplicating information.
Expand Down
8 changes: 3 additions & 5 deletions distdir_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ DIST_DEPS = {
"rules_java_builtin",
"rules_java_builtin_for_testing",
],
"archive": "rules_java-6.1.1.tar.gz",
"sha256": "76402a50ae6859d50bd7aed8c1b8ef09dae5c1035bb3ca7d276f7f3ce659818a",
"urls": ["https://github.com/bazelbuild/rules_java/releases/download/6.1.1/rules_java-6.1.1.tar.gz"],
"patches": ["//third_party:rules_java_6.1.0.patch"],
"patch_args": ["-p1"],
"archive": "rules_java-6.2.2.tar.gz",
"sha256": "847527aa7f74712e0a63af2670ba3ddc04e8ea3d8930a7947c17aebfb29d5294",
"urls": ["https://github.com/bazelbuild/rules_java/releases/download/6.2.2/rules_java-6.2.2.tar.gz"],
"workspace_file_content": "",
"used_in": [
"additional_distfiles",
Expand Down
2 changes: 1 addition & 1 deletion site/en/contribute/maintainers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ repository.
1. If the issue is low priority and can be worked on by a new community
contributor, the DevEx member assigns the `good first issue` label.
At this stage, the issue enters the pool of [untriaged open
issues](https://github.com/bazelbuild/bazel/issues?q=is%3Aissue+is%3Aopen+label%3Auntriaged){: .external}.
issues](https://github.com/bazelbuild/bazel/issues?q=is%3Aissue+is%3Aopen+label%3Auntriaged).

Each Bazel subteam will triage all issues under labels they own, preferably on a
weekly basis. The subteam will review and evaluate the issue and provide a
Expand Down
2 changes: 1 addition & 1 deletion src/MODULE.tools
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module(name = "bazel_tools")

bazel_dep(name = "rules_cc", version = "0.0.6")
bazel_dep(name = "rules_java", version = "6.1.1")
bazel_dep(name = "rules_java", version = "6.2.2")
bazel_dep(name = "rules_license", version = "0.0.3")
bazel_dep(name = "rules_proto", version = "4.0.0")
bazel_dep(name = "rules_python", version = "0.4.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

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

import com.google.common.base.Preconditions;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.devtools.build.lib.actions.BasicActionLookupValue;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.Aspect;
Expand All @@ -24,78 +25,110 @@
import net.starlark.java.syntax.Location;

/** An aspect in the context of the Skyframe graph. */
public final class AspectValue extends BasicActionLookupValue implements RuleConfiguredObjectValue {
public class AspectValue extends BasicActionLookupValue
implements ConfiguredAspect, RuleConfiguredObjectValue {

public static AspectValue create(
AspectKey key,
Aspect aspect,
Location location,
ConfiguredAspect configuredAspect,
@Nullable NestedSet<Package> transitivePackages) {
return transitivePackages == null
? new AspectValue(key, aspect, location, configuredAspect)
: new AspectValueWithTransitivePackages(
key, aspect, location, configuredAspect, transitivePackages);
}

// These variables are only non-final because they may be clear()ed to save memory. They are null
// only after they are cleared except for transitivePackagesForPackageRootResolution.
@Nullable private Aspect aspect;
@Nullable private Location location;
@Nullable private TransitiveInfoProviderMap providers;
// Normally the key used to evaluate this value in AspectFunction#compute. But in the case of a
// top-level StarlarkAspectKey, the AspectValue will be this value but the key will be the
// associated aspect key from StarlarkAspectKey#toAspectkey.
@Nullable private AspectKey key;
@Nullable private ConfiguredAspect configuredAspect;
// May be null either after clearing or because transitive packages are not tracked.
@Nullable private transient NestedSet<Package> transitivePackages;

public AspectValue(
AspectKey key,
Aspect aspect,
Location location,
ConfiguredAspect configuredAspect,
NestedSet<Package> transitivePackages) {
private AspectValue(
AspectKey key, Aspect aspect, Location location, ConfiguredAspect configuredAspect) {
super(configuredAspect.getActions());
this.key = key;
this.aspect = Preconditions.checkNotNull(aspect, location);
this.location = Preconditions.checkNotNull(location, aspect);
this.configuredAspect = Preconditions.checkNotNull(configuredAspect, location);
this.transitivePackages = transitivePackages;
this.key = checkNotNull(key);
this.aspect = checkNotNull(aspect);
this.location = checkNotNull(location);
this.providers = configuredAspect.getProviders();
}

public ConfiguredAspect getConfiguredAspect() {
return Preconditions.checkNotNull(configuredAspect);
public final Location getLocation() {
return checkNotNull(location);
}

public Location getLocation() {
return Preconditions.checkNotNull(location);
public final AspectKey getKey() {
return checkNotNull(key);
}

public AspectKey getKey() {
return Preconditions.checkNotNull(key);
public final Aspect getAspect() {
return checkNotNull(aspect);
}

public Aspect getAspect() {
return Preconditions.checkNotNull(aspect);
@Override
public TransitiveInfoProviderMap getProviders() {
return checkNotNull(providers);
}

@Override
public void clear(boolean clearEverything) {
if (clearEverything) {
aspect = null;
location = null;
providers = null;
key = null;
configuredAspect = null;
}
transitivePackages = null;
}

@Nullable
@Override
public NestedSet<Package> getTransitivePackages() {
return transitivePackages;
return null;
}

@Override
public ProviderCollection getConfiguredObject() {
return getConfiguredAspect();
public final ProviderCollection getConfiguredObject() {
return this;
}

@Override
public String toString() {
public final String toString() {
return getStringHelper()
.add("key", key)
.add("location", location)
.add("aspect", aspect)
.add("configuredAspect", configuredAspect)
.add("providers", providers)
.toString();
}

private static final class AspectValueWithTransitivePackages extends AspectValue {
@Nullable private transient NestedSet<Package> transitivePackages; // Null after clear().

private AspectValueWithTransitivePackages(
AspectKey key,
Aspect aspect,
Location location,
ConfiguredAspect configuredAspect,
NestedSet<Package> transitivePackages) {
super(key, aspect, location, configuredAspect);
this.transitivePackages = checkNotNull(transitivePackages);
}

@Override
public NestedSet<Package> getTransitivePackages() {
return transitivePackages;
}

@Override
public void clear(boolean clearEverything) {
super.clear(clearEverything);
transitivePackages = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

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

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.devtools.build.lib.analysis.ExtraActionUtils.createExtraActionProvider;

import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
Expand All @@ -27,11 +29,9 @@
import com.google.devtools.build.lib.analysis.starlark.StarlarkApiProvider;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.packages.Info;
import com.google.devtools.build.lib.packages.Provider;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
import java.util.TreeMap;
import javax.annotation.Nullable;
import net.starlark.java.eval.EvalException;
Expand All @@ -52,70 +52,48 @@
* @see com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory
* @see com.google.devtools.build.lib.packages.AspectClass
*/
@Immutable
public final class ConfiguredAspect implements ProviderCollection {
private final ImmutableList<ActionAnalysisMetadata> actions;
private final TransitiveInfoProviderMap providers;

private ConfiguredAspect(
ImmutableList<ActionAnalysisMetadata> actions, TransitiveInfoProviderMap providers) {
this.actions = actions;
this.providers = providers;

// Initialize every StarlarkApiProvider
for (int i = 0; i < providers.getProviderCount(); i++) {
Object obj = providers.getProviderInstanceAt(i);
if (obj instanceof StarlarkApiProvider) {
((StarlarkApiProvider) obj).init(providers);
}
}
}
public interface ConfiguredAspect extends ProviderCollection {

public ImmutableList<ActionAnalysisMetadata> getActions() {
return actions;
}
ImmutableList<ActionAnalysisMetadata> getActions();

/** Returns the providers created by the aspect. */
public TransitiveInfoProviderMap getProviders() {
return providers;
}
TransitiveInfoProviderMap getProviders();

@Override
@Nullable
public <P extends TransitiveInfoProvider> P getProvider(Class<P> providerClass) {
default <P extends TransitiveInfoProvider> P getProvider(Class<P> providerClass) {
AnalysisUtils.checkProvider(providerClass);
return providers.getProvider(providerClass);
return getProviders().getProvider(providerClass);
}

@Override
public Info get(Provider.Key key) {
return providers.get(key);
default Info get(Provider.Key key) {
return getProviders().get(key);
}

@Override
public Object get(String legacyKey) {
default Object get(String legacyKey) {
if (OutputGroupInfo.STARLARK_NAME.equals(legacyKey)) {
return get(OutputGroupInfo.STARLARK_CONSTRUCTOR.getKey());
}
return providers.get(legacyKey);
return getProviders().get(legacyKey);
}

public static ConfiguredAspect forAlias(ConfiguredAspect real) {
return new ConfiguredAspect(real.actions, real.providers);
static ConfiguredAspect forAlias(ConfiguredAspect real) {
return BasicConfiguredAspect.create(real.getActions(), real.getProviders());
}

public static ConfiguredAspect forNonapplicableTarget() {
return new ConfiguredAspect(
ImmutableList.of(),
new TransitiveInfoProviderMapBuilder().add().build());
static ConfiguredAspect forNonapplicableTarget() {
return BasicConfiguredAspect.create(
ImmutableList.of(), new TransitiveInfoProviderMapBuilder().build());
}

public static Builder builder(RuleContext ruleContext) {
static Builder builder(RuleContext ruleContext) {
return new Builder(ruleContext);
}

/** Builder for {@link ConfiguredAspect}. */
public static class Builder {
final class Builder {
private final TransitiveInfoProviderMapBuilder providers =
new TransitiveInfoProviderMapBuilder();
private final TreeMap<String, NestedSetBuilder<Artifact>> outputGroupBuilders = new TreeMap<>();
Expand All @@ -128,7 +106,7 @@ public Builder(RuleContext ruleContext) {
@CanIgnoreReturnValue
public <T extends TransitiveInfoProvider> Builder addProvider(
Class<? extends T> providerClass, T provider) {
Preconditions.checkNotNull(provider);
checkNotNull(provider);
checkProviderClass(providerClass);
providers.put(providerClass, provider);
return this;
Expand All @@ -137,34 +115,13 @@ public <T extends TransitiveInfoProvider> Builder addProvider(
/** Adds a provider to the aspect. */
@CanIgnoreReturnValue
public Builder addProvider(TransitiveInfoProvider provider) {
Preconditions.checkNotNull(provider);
checkNotNull(provider);
addProvider(TransitiveInfoProviderEffectiveClassHelper.get(provider), provider);
return this;
}

private static void checkProviderClass(Class<? extends TransitiveInfoProvider> providerClass) {
Preconditions.checkNotNull(providerClass);
}

/** Adds providers to the aspect. */
@CanIgnoreReturnValue
public Builder addProviders(TransitiveInfoProviderMap providers) {
this.providers.addAll(providers);
return this;
}

/** Adds providers to the aspect. */
public Builder addProviders(TransitiveInfoProvider... providers) {
return addProviders(Arrays.asList(providers));
}

/** Adds providers to the aspect. */
@CanIgnoreReturnValue
public Builder addProviders(Iterable<TransitiveInfoProvider> providers) {
for (TransitiveInfoProvider provider : providers) {
addProvider(provider);
}
return this;
checkNotNull(providerClass);
}

/** Adds a set of files to an output group. */
Expand Down Expand Up @@ -232,7 +189,17 @@ public ConfiguredAspect build() throws ActionConflictException, InterruptedExcep

maybeAddRequiredConfigFragmentsProvider();

return new ConfiguredAspect(actions, providers.build());
TransitiveInfoProviderMap providerMap = providers.build();

// Initialize every StarlarkApiProvider
for (int i = 0; i < providerMap.getProviderCount(); i++) {
Object obj = providerMap.getProviderInstanceAt(i);
if (obj instanceof StarlarkApiProvider) {
((StarlarkApiProvider) obj).init(providerMap);
}
}

return BasicConfiguredAspect.create(actions, providerMap);
}

/**
Expand All @@ -250,4 +217,16 @@ private void maybeAddRequiredConfigFragmentsProvider() {
}
}
}

/** Basic implementation of {@link ConfiguredAspect}. */
@AutoValue
abstract class BasicConfiguredAspect implements ConfiguredAspect {

private static BasicConfiguredAspect create(
ImmutableList<ActionAnalysisMetadata> actions, TransitiveInfoProviderMap providers) {
return new AutoValue_ConfiguredAspect_BasicConfiguredAspect(actions, providers);
}

BasicConfiguredAspect() {}
}
}

0 comments on commit 81ded64

Please sign in to comment.