Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public byte[] getValueFingerprint() {
}

/**
* Returns the unresolved symlink target path.
* Returns the unresolved symlink target path, which is always normalized.
*
* @throws UnsupportedOperationException if the metadata is not of symlink file type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ public synchronized NestedSet<Artifact> getInputs() {

@VisibleForTesting
public void writeTo(OutputStream out, @Nullable EventHandler eventHandler) throws IOException {
writeFile(out, runfiles.getRunfilesInputs(repoMappingManifest));
writeFile(
out, runfiles.getRunfilesInputs(repoMappingManifest), /* inputMetadataProvider= */ null);
}

/**
Expand Down Expand Up @@ -265,7 +266,7 @@ public void prefixConflict(String message) {
.build();
throw new UserExecException(failureDetail);
}
return out -> writeFile(out, runfilesInputs);
return out -> writeFile(out, runfilesInputs, ctx.getInputMetadataProvider());
}

@Override
Expand All @@ -278,9 +279,14 @@ public boolean isRemotable() {
*
* @param out is the message stream to write errors to.
* @param output The actual mapping of the output manifest.
* @param inputMetadataProvider The input metadata provider if available.
* @throws IOException
*/
private void writeFile(OutputStream out, Map<PathFragment, Artifact> output) throws IOException {
private void writeFile(
OutputStream out,
Map<PathFragment, Artifact> output,
@Nullable InputMetadataProvider inputMetadataProvider)
throws IOException {
Writer manifestFile = new BufferedWriter(new OutputStreamWriter(out, ISO_8859_1));
List<Map.Entry<PathFragment, Artifact>> sortedManifest = new ArrayList<>(output.entrySet());
sortedManifest.sort(ENTRY_COMPARATOR);
Expand All @@ -290,7 +296,13 @@ private void writeFile(OutputStream out, Map<PathFragment, Artifact> output) thr
if (artifact == null) {
symlinkTarget = null;
} else if (artifact.isSymlink()) {
symlinkTarget = artifact.getPath().readSymbolicLink();
if (inputMetadataProvider != null) {
symlinkTarget =
PathFragment.createAlreadyNormalized(
inputMetadataProvider.getInputMetadata(artifact).getUnresolvedSymlinkTarget());
} else {
symlinkTarget = artifact.getPath().readSymbolicLink();
}
} else {
symlinkTarget = artifact.getPath().asFragment();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,14 @@ private MerkleTree buildWithPrecomputedSubTrees(
inputBytes += subTreeRoot.inputBytes();
}
case Artifact.SpecialArtifact symlink when symlink.isSymlink() -> {
Path symlinkPath = artifactPathResolver.toPath(symlink);
var metadata =
checkNotNull(
metadataProvider.getInputMetadata(symlink), "missing metadata: %s", symlink);
var builder =
currentDirectory
.addSymlinksBuilder()
.setName(name)
.setTarget(internalToUnicode(symlinkPath.readSymbolicLink().getPathString()));
.setTarget(internalToUnicode(metadata.getUnresolvedSymlinkTarget()));
if (nodeProperties != null) {
builder.setNodeProperties(nodeProperties);
}
Expand Down