Skip to content

Commit

Permalink
[8.0.0] Allow any attributes on non-registry overrides (#24443)
Browse files Browse the repository at this point in the history
Contains cherry-picks of:
* dfdbe77
* d99595f
* 3d60f1c

RELNOTES: `archive_override` now accepts all attributes usable with
`http_archive`; similar for `git_override` and `git_repository`.

---------

Co-authored-by: Googler <[email protected]>
  • Loading branch information
Wyverald and cushon authored Nov 21, 2024
1 parent e749da2 commit 27487cf
Show file tree
Hide file tree
Showing 327 changed files with 3,786 additions and 3,979 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package com.google.devtools.build.docgen;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;

import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Ascii;
import com.google.common.base.Splitter;
Expand Down Expand Up @@ -480,14 +480,14 @@ static int collectModuleInfoDocs(
}

/** The file and symbol from which documentation was obtained. */
@AutoValue
abstract static class DocumentationOrigin {
abstract String file();

abstract String symbol();
record DocumentationOrigin(String file, String symbol) {
DocumentationOrigin {
requireNonNull(file, "file");
requireNonNull(symbol, "symbol");
}

static DocumentationOrigin create(String file, String symbol) {
return new AutoValue_BuildDocCollector_DocumentationOrigin(file, symbol);
return new DocumentationOrigin(file, symbol);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,31 @@
// limitations under the License.
package com.google.devtools.build.lib.actions;

import com.google.auto.value.AutoValue;
import static java.util.Objects.requireNonNull;

import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;

/** Notifications for the progress of an in-flight action. */
@AutoValue
public abstract class ActionProgressEvent implements Postable {
/**
* Notifications for the progress of an in-flight action.
*
* @param action Gets the metadata associated with the action being scheduled.
* @param progressId The id that uniquely determines the progress among all progress events within
* an action.
* @param progress Human readable description of the progress.
* @param finished Whether the download progress reported about is finished already.
*/
public record ActionProgressEvent(
ActionExecutionMetadata action, String progressId, String progress, boolean finished)
implements Postable {
public ActionProgressEvent {
requireNonNull(action, "action");
requireNonNull(progressId, "progressId");
requireNonNull(progress, "progress");
}

public static ActionProgressEvent create(
ActionExecutionMetadata action, String progressId, String progress, boolean finished) {
return new AutoValue_ActionProgressEvent(action, progressId, progress, finished);
return new ActionProgressEvent(action, progressId, progress, finished);
}

/** Gets the metadata associated with the action being scheduled. */
public abstract ActionExecutionMetadata action();

/** The id that uniquely determines the progress among all progress events within an action. */
public abstract String progressId();

/** Human readable description of the progress. */
public abstract String progress();

/** Whether the download progress reported about is finished already. */
public abstract boolean finished();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,33 @@

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

import static java.util.Objects.requireNonNull;

import com.google.auto.value.AutoValue;
import com.google.auto.value.AutoBuilder;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Nullable;

/** Holds the result(s) of an action's execution. */
@SuppressWarnings("GoodTime") // Use ints instead of Durations to improve build time (cl/505728570)
@AutoValue
public abstract class ActionResult {
/**
* Holds the result(s) of an action's execution.
*
* @param spawnResults Returns the SpawnResults for the action.
*/
@SuppressWarnings("GoodTime")
public record ActionResult(ImmutableList<SpawnResult> spawnResults) {
public ActionResult {
requireNonNull(spawnResults, "spawnResults");
}

/** An empty ActionResult used by Actions that don't have any metadata to return. */
public static final ActionResult EMPTY = ActionResult.create(ImmutableList.of());

/** Returns the SpawnResults for the action. */
public abstract ImmutableList<SpawnResult> spawnResults();

/** Returns a builder that can be used to construct a {@link ActionResult} object. */
public static Builder builder() {
return new AutoValue_ActionResult.Builder();
return new AutoBuilder_ActionResult_Builder();
}

/**
* Returns the cumulative total of long values taken from a series of {@link SpawnResult}s.
*
Expand Down Expand Up @@ -286,7 +291,7 @@ public static ActionResult create(List<SpawnResult> spawnResults) {
}

/** Builder for a {@link ActionResult} instance, which is immutable once built. */
@AutoValue.Builder
@AutoBuilder
public abstract static class Builder {

/** Sets the SpawnResults for the action. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,31 @@
// limitations under the License.
package com.google.devtools.build.lib.actions;

import static java.util.Objects.requireNonNull;

import build.bazel.remote.execution.v2.Digest;
import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;
import com.google.devtools.build.lib.remote.Store;

/**
* The event fired when a resource is done uploading to a remote or disk cache upon completion of a
* local action.
*
* @param action Returns the associated action.
* @param store Returns the {@link Store} that the resource belongs to.
* @param digest Returns the {@link Digest} that uniquely identifies the resource.
*/
@AutoValue
public abstract class ActionUploadFinishedEvent implements Postable {
public record ActionUploadFinishedEvent(ActionExecutionMetadata action, Store store, Digest digest)
implements Postable {
public ActionUploadFinishedEvent {
requireNonNull(action, "action");
requireNonNull(store, "store");
requireNonNull(digest, "digest");
}

public static ActionUploadFinishedEvent create(
ActionExecutionMetadata action, Store store, Digest digest) {
return new AutoValue_ActionUploadFinishedEvent(action, store, digest);
return new ActionUploadFinishedEvent(action, store, digest);
}

/** Returns the associated action. */
public abstract ActionExecutionMetadata action();

/** Returns the {@link Store} that the resource belongs to. */
public abstract Store store();

/** Returns the {@link Digest} that uniquely identifies the resource. */
public abstract Digest digest();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,31 @@
// limitations under the License.
package com.google.devtools.build.lib.actions;

import static java.util.Objects.requireNonNull;

import build.bazel.remote.execution.v2.Digest;
import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;
import com.google.devtools.build.lib.remote.Store;

/**
* The event fired when a resource is about to be uploaded to a remote or disk cache upon completion
* of a local action.
*
* @param action Returns the associated action.
* @param store Returns the store that the resource belongs to.
* @param digest Returns the digest that uniquely identifies the resource.
*/
@AutoValue
public abstract class ActionUploadStartedEvent implements Postable {
public record ActionUploadStartedEvent(ActionExecutionMetadata action, Store store, Digest digest)
implements Postable {
public ActionUploadStartedEvent {
requireNonNull(action, "action");
requireNonNull(store, "store");
requireNonNull(digest, "digest");
}

public static ActionUploadStartedEvent create(
ActionExecutionMetadata action, Store store, Digest digest) {
return new AutoValue_ActionUploadStartedEvent(action, store, digest);
return new ActionUploadStartedEvent(action, store, digest);
}

/** Returns the associated action. */
public abstract ActionExecutionMetadata action();

/** Returns the store that the resource belongs to. */
public abstract Store store();

/** Returns the digest that uniquely identifies the resource. */
public abstract Digest digest();
}
6 changes: 2 additions & 4 deletions src/main/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ java_library(
name = "execution_requirements",
srcs = ["ExecutionRequirements.java"],
deps = [
"//third_party:auto_value",
"//third_party:guava",
"//third_party:jsr305",
],
Expand Down Expand Up @@ -416,8 +415,10 @@ java_library(
deps = [
":artifacts",
":has_digest",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//third_party:auto_value",
"//third_party:error_prone_annotations",
"//third_party:guava",
"//third_party:jsr305",
],
Expand Down Expand Up @@ -601,7 +602,4 @@ java_library(
java_library(
name = "total_and_configured_target_only_metric",
srcs = ["TotalAndConfiguredTargetOnlyMetric.java"],
deps = [
"//third_party:auto_value",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,26 @@
package com.google.devtools.build.lib.actions;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;

import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;

/** Notifies that an in-flight action is checking the cache. */
@AutoValue
public abstract class CachingActionEvent implements Postable {
/**
* Notifies that an in-flight action is checking the cache.
*
* @param action Gets the metadata associated with the action.
* @param strategy Gets the name of the strategy on which the action is caching.
*/
public record CachingActionEvent(ActionExecutionMetadata action, String strategy)
implements Postable {
public CachingActionEvent {
requireNonNull(action, "action");
requireNonNull(strategy, "strategy");
}

public static CachingActionEvent create(ActionExecutionMetadata action, String strategy) {
return new AutoValue_CachingActionEvent(
return new CachingActionEvent(
action, checkNotNull(strategy, "Strategy names are not optional"));
}

/** Gets the metadata associated with the action. */
public abstract ActionExecutionMetadata action();

/** Gets the name of the strategy on which the action is caching. */
public abstract String strategy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
// limitations under the License.
package com.google.devtools.build.lib.actions;

import com.google.auto.value.AutoValue;
import static java.util.Objects.requireNonNull;

import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Set;
Expand All @@ -22,33 +23,26 @@
* A message sent conveying a set of changed files. This is sent over the event bus if a build is
* discovered to have changed files. If many files have changed, the set of changed files will be
* empty, but {@link #changedFileCount} will still return the correct number.
*
* @param changedFiles Returns a set with one PathFragment for each file that was changed since the
* last build, or an empty set if the set is unknown or would be too big.
* @param changedFileCount Returns the number of changed files. This will always be the correct
* number of files, even when {@link #changedFiles} might return an empty set, because the
* actual set would be too big.
* @param invalidatedFileValueCount Returns the number of {@link FileValue} nodes invalidated in the
* build.
* <p>This is different from {@link #changedFiles} , in particular a single file change can
* result with multiple {@linkplain FileValue FVs} .
*/
@AutoValue
public abstract class ChangedFilesMessage {

/**
* Returns a set with one PathFragment for each file that was changed since the last build, or an
* empty set if the set is unknown or would be too big.
*/
public abstract ImmutableSet<PathFragment> changedFiles();

/**
* Returns the number of changed files. This will always be the correct number of files, even when
* {@link #changedFiles} might return an empty set, because the actual set would be too big.
*/
public abstract int changedFileCount();

/**
* Returns the number of {@link FileValue} nodes invalidated in the build.
*
* <p>This is different from {@link #changedFiles}, in particular a single file change can result
* with multiple {@linkplain FileValue FVs}.
*/
public abstract int invalidatedFileValueCount();
public record ChangedFilesMessage(
ImmutableSet<PathFragment> changedFiles, int changedFileCount, int invalidatedFileValueCount) {
public ChangedFilesMessage {
requireNonNull(changedFiles, "changedFiles");
}

public static ChangedFilesMessage create(
Set<PathFragment> changedFiles, int changedFileCount, int invalidatedFileValueCount) {
return new AutoValue_ChangedFilesMessage(
return new ChangedFilesMessage(
ImmutableSet.copyOf(changedFiles), changedFileCount, invalidatedFileValueCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

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

import com.google.auto.value.AutoValue;
import static java.util.Objects.requireNonNull;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
Expand All @@ -39,8 +40,13 @@
public class ExecutionRequirements {

/** An execution requirement that can be split into a key and a value part using a regex. */
@AutoValue
public abstract static class ParseableRequirement {
public record ParseableRequirement(
String userFriendlyName, Pattern detectionPattern, Function<String, String> validator) {
public ParseableRequirement {
requireNonNull(userFriendlyName, "userFriendlyName");
requireNonNull(detectionPattern, "detectionPattern");
requireNonNull(validator, "validator");
}

/**
* Thrown when a {@link ParseableRequirement} feels responsible for a tag, but the {@link
Expand Down Expand Up @@ -87,16 +93,9 @@ public String getTagValue() {
*/
static ParseableRequirement create(
String userFriendlyName, Pattern detectionPattern, Function<String, String> validator) {
return new AutoValue_ExecutionRequirements_ParseableRequirement(
userFriendlyName, detectionPattern, validator);
return new ParseableRequirement(userFriendlyName, detectionPattern, validator);
}

public abstract String userFriendlyName();

public abstract Pattern detectionPattern();

public abstract Function<String, String> validator();

/**
* Returns the parsed value from a tag, if this {@link ParseableRequirement} detects that it is
* responsible for it, otherwise returns {@code null}.
Expand Down
Loading

0 comments on commit 27487cf

Please sign in to comment.