Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic C++ path mapping support #22445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readability: add /* localResources= */ . Only on arguments, where you can't figure out the parameter name. Same below.

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