Skip to content

Commit

Permalink
[7.4.0] Apply a workaround for absolute paths in .d files which can l…
Browse files Browse the repository at this point in the history
…ead to cache issues with the Android NDK on Windows. (#23348)

PiperOrigin-RevId: 658725449
Change-Id: I09edfa9af8a4956d661174bef76a7f8776891a8b

Commit
638f293

Co-authored-by: Googler <ahumesky@google.com>
Co-authored-by: Yun Peng <pcloudy@google.com>
  • Loading branch information
3 people authored Aug 20, 2024
1 parent f71bbc6 commit 9409213
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -104,7 +106,7 @@ private String translatePath(String path) {
if (OS.getCurrent() != OS.WINDOWS) {
return path;
}
return WindowsPath.translateWindowsPath(path);
return WindowsPath.removeWorkspace(WindowsPath.translateWindowsPath(path));
}

/** Reads a dotd file into this DependencySet instance. */
Expand Down Expand Up @@ -251,6 +253,17 @@ public int hashCode() {
private static final class WindowsPath {
private static final AtomicReference<String> UNIX_ROOT = new AtomicReference<>(null);

private static final Pattern EXECROOT_BASE_HEADER_PATTERN =
Pattern.compile(".*execroot[\\\\/](?<headerPath>.*)");

private static String removeWorkspace(String path) {
Matcher m = EXECROOT_BASE_HEADER_PATTERN.matcher(path);
if (m.matches()) {
path = "../" + m.group("headerPath");
}
return path;
}

private static String translateWindowsPath(String path) {
int n = path.length();
if (n == 0 || path.charAt(0) != '/') {
Expand Down

0 comments on commit 9409213

Please sign in to comment.