Skip to content

Commit

Permalink
Delete a bunch of obsolete workspace status functionality.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 658105185
Change-Id: Ib620a29cc7ba91634cf56a90b6a32f504056a5f1
  • Loading branch information
justinhorvitz authored and copybara-github committed Jul 31, 2024
1 parent 5a8280a commit a7264d9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.google.devtools.common.options.OptionEffectTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParsingException;
import com.google.devtools.common.options.OptionsProvider;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
Expand All @@ -60,8 +59,7 @@
* rebuilds if no other file is changed. This is useful for frequently-changing information that
* does not significantly affect the build, e.g. the current time.
*
* <p>For more information, see {@link
* com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory}.
* <p>For more information, see {@link Factory}.
*/
public abstract class WorkspaceStatusAction extends AbstractAction {

Expand Down Expand Up @@ -91,20 +89,11 @@ public static class Options extends OptionsBase {
public PathFragment workspaceStatusCommand;
}

/** The type of a workspace status action key. */
public enum KeyType {
INTEGER,
STRING,
}

/**
* Action context required by the workspace status action as well as language-specific actions
* that write workspace status artifacts.
*/
public interface Context extends ActionContext {
ImmutableMap<String, Key> getStableKeys();

ImmutableMap<String, Key> getVolatileKeys();

// TODO(ulfjack): Maybe move these to a separate ActionContext interface?
WorkspaceStatusAction.Options getOptions();
Expand All @@ -114,36 +103,6 @@ public interface Context extends ActionContext {
com.google.devtools.build.lib.shell.Command getCommand();
}

/** A key in the workspace status info file. */
public static class Key {
private final KeyType type;

private final String defaultValue;
private final String redactedValue;

private Key(KeyType type, String defaultValue, String redactedValue) {
this.type = type;
this.defaultValue = defaultValue;
this.redactedValue = redactedValue;
}

public KeyType getType() {
return type;
}

public String getDefaultValue() {
return defaultValue;
}

public String getRedactedValue() {
return redactedValue;
}

public static Key of(KeyType type, String defaultValue, String redactedValue) {
return new Key(type, defaultValue, redactedValue);
}
}

/**
* Parses the output of the workspace status action.
*
Expand Down Expand Up @@ -174,23 +133,6 @@ public interface Environment {
Artifact createVolatileArtifact(String name);
}

/**
* Environment for the {@link Factory} to create the dummy workspace status information. This is a
* subset of the information provided by CommandEnvironment. However, we cannot reference the
* CommandEnvironment from here due to layering.
*/
public interface DummyEnvironment {
Path getWorkspace();

/** Returns optional precomputed workspace info to include in the build info event. */
@Nullable
WorkspaceInfoFromDiff getWorkspaceInfoFromDiff();

String getBuildRequestId();

OptionsProvider getOptions();
}

/** Factory for {@link WorkspaceStatusAction}. */
public interface Factory {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import com.google.devtools.build.lib.analysis.BuildInfo;
import com.google.devtools.build.lib.analysis.BuildInfoEvent;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Key;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.KeyType;
import com.google.devtools.build.lib.buildtool.BuildRequest;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
Expand Down Expand Up @@ -315,29 +313,6 @@ private BazelWorkspaceStatusActionContext(CommandEnvironment env) {
this.env = env;
}

@Override
public ImmutableMap<String, Key> getStableKeys() {
WorkspaceStatusAction.Options options =
env.getOptions().getOptions(WorkspaceStatusAction.Options.class);
ImmutableMap.Builder<String, Key> builder = ImmutableMap.builder();
builder.put(
BuildInfo.BUILD_EMBED_LABEL, Key.of(KeyType.STRING, options.embedLabel, "redacted"));
builder.put(BuildInfo.BUILD_HOST, Key.of(KeyType.STRING, "hostname", "redacted"));
builder.put(BuildInfo.BUILD_USER, Key.of(KeyType.STRING, "username", "redacted"));
return builder.buildOrThrow();
}

@Override
public ImmutableMap<String, Key> getVolatileKeys() {
return ImmutableMap.of(
BuildInfo.BUILD_TIMESTAMP,
Key.of(KeyType.INTEGER, "0", "0"),
BuildInfo.BUILD_SCM_REVISION,
Key.of(KeyType.STRING, "0", "0"),
BuildInfo.BUILD_SCM_STATUS,
Key.of(KeyType.STRING, "", "redacted"));
}

@Override
public WorkspaceStatusAction.Options getOptions() {
return env.getOptions().getOptions(WorkspaceStatusAction.Options.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.analysis.TopLevelArtifactContext;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Key;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Options;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue.RunfileSymlinksMode;
Expand Down Expand Up @@ -287,17 +286,8 @@ public Artifact getStableStatus() {
}
}

/** A WorkspaceStatusAction.Context that has no stable keys and no volatile keys. */
/** A {@link WorkspaceStatusAction.Context} that does not support any operations. */
public static class DummyWorkspaceStatusActionContext implements WorkspaceStatusAction.Context {
@Override
public ImmutableMap<String, Key> getStableKeys() {
return ImmutableMap.of();
}

@Override
public ImmutableMap<String, Key> getVolatileKeys() {
return ImmutableMap.of();
}

@Override
public Options getOptions() {
Expand Down Expand Up @@ -412,7 +402,7 @@ public StarlarkSemantics getStarlarkSemantics() {
}

@Override
public ImmutableMap<String, Object> getStarlarkDefinedBuiltins() throws InterruptedException {
public ImmutableMap<String, Object> getStarlarkDefinedBuiltins() {
return null;
}

Expand Down

0 comments on commit a7264d9

Please sign in to comment.