Skip to content

Commit

Permalink
Add PathMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed May 26, 2024
1 parent 153552c commit 3e0ee8b
Show file tree
Hide file tree
Showing 24 changed files with 773 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public final class SimpleSpawn implements Spawn {
private final ImmutableList<ActionInput> outputs;
// If null, all outputs are mandatory.
@Nullable private final Set<? extends ActionInput> mandatoryOutputs;
private final PathMapper pathMapper;
private final LocalResourcesSupplier localResourcesSupplier;
private ResourceSet localResourcesCached;

Expand All @@ -55,7 +56,8 @@ private SimpleSpawn(
Collection<? extends ActionInput> outputs,
@Nullable final Set<? extends ActionInput> mandatoryOutputs,
@Nullable ResourceSet localResources,
@Nullable LocalResourcesSupplier localResourcesSupplier) {
@Nullable LocalResourcesSupplier localResourcesSupplier,
PathMapper pathMapper) {
this.owner = Preconditions.checkNotNull(owner);
this.arguments = Preconditions.checkNotNull(arguments);
this.environment = Preconditions.checkNotNull(environment);
Expand All @@ -77,6 +79,7 @@ private SimpleSpawn(
this.localResourcesSupplier = localResourcesSupplier;
this.localResourcesCached = null;
}
this.pathMapper = pathMapper;
}

public SimpleSpawn(
Expand All @@ -101,7 +104,8 @@ public SimpleSpawn(
outputs,
mandatoryOutputs,
localResources,
/*localResourcesSupplier=*/ null);
/* localResourcesSupplier= */ null,
PathMapper.NOOP);
}

@SuppressWarnings("TooManyParameters")
Expand All @@ -126,8 +130,63 @@ public SimpleSpawn(
tools,
outputs,
mandatoryOutputs,
/*localResources=*/ null,
localResourcesSupplier);
/* localResources= */ null,
localResourcesSupplier,
PathMapper.NOOP);
}

public SimpleSpawn(
ActionExecutionMetadata owner,
ImmutableList<String> arguments,
ImmutableMap<String, String> environment,
ImmutableMap<String, String> executionInfo,
ImmutableMap<Artifact, ImmutableList<FilesetOutputSymlink>> filesetMappings,
NestedSet<? extends ActionInput> inputs,
NestedSet<? extends ActionInput> tools,
Collection<? extends ActionInput> outputs,
@Nullable Set<? extends ActionInput> mandatoryOutputs,
LocalResourcesSupplier localResourcesSupplier,
PathMapper pathMapper) {
this(
owner,
arguments,
environment,
executionInfo,
filesetMappings,
inputs,
tools,
outputs,
mandatoryOutputs,
null,
localResourcesSupplier,
pathMapper);
}

public SimpleSpawn(
ActionExecutionMetadata owner,
ImmutableList<String> arguments,
ImmutableMap<String, String> environment,
ImmutableMap<String, String> executionInfo,
ImmutableMap<Artifact, ImmutableList<FilesetOutputSymlink>> filesetMappings,
NestedSet<? extends ActionInput> inputs,
NestedSet<? extends ActionInput> tools,
Collection<? extends ActionInput> outputs,
@Nullable Set<? extends ActionInput> mandatoryOutputs,
ResourceSet localResources,
PathMapper pathMapper) {
this(
owner,
arguments,
environment,
executionInfo,
filesetMappings,
inputs,
tools,
outputs,
mandatoryOutputs,
localResources,
null,
pathMapper);
}

public SimpleSpawn(
Expand Down Expand Up @@ -226,6 +285,11 @@ public ResourceSet getLocalResources() throws ExecException {
return localResourcesCached;
}

@Override
public PathMapper getPathMapper() {
return pathMapper;
}

@Override
public String getMnemonic() {
return owner.getMnemonic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.PathMapper;
import com.google.devtools.build.lib.analysis.AnalysisUtils;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue;
Expand Down Expand Up @@ -287,7 +288,7 @@ public Dict<String, String> getEnvironmentVariable(
return Dict.immutableCopyOf(
featureConfiguration
.getFeatureConfiguration()
.getEnvironmentVariables(actionName, variables));
.getEnvironmentVariables(actionName, variables, PathMapper.NOOP));
}

@Override
Expand Down
Loading

0 comments on commit 3e0ee8b

Please sign in to comment.