diff options
author | 2015-11-12 23:19:59 +0000 | |
---|---|---|
committer | 2015-11-13 10:23:04 +0000 | |
commit | f6866778db261e5d8b95ee1c46622ceb19a609a4 (patch) | |
tree | 2e586c69bb4644a6facb7d4dcfecd20545c60043 /src/main/java/com/google | |
parent | 8533b7a5ffb26c115024c6c32325915589e68f9d (diff) |
Preserve repositories' rooted paths
This was taking the "right" rooted path, converting it to a path, and then
making the rooted path [/path/to/external/repo/BUILD]/[] (where it should
have been [/path/to/external/repo]/[BUILD]).
--
MOS_MIGRATED_REVID=107726114
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java index 93d3cf6c7e..fb166e611e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java @@ -135,6 +135,9 @@ public abstract class RepositoryFunction implements SkyFunction { protected RepositoryValue symlinkBuildFile( Rule rule, Path workspaceDirectory, FileValue directoryValue, Environment env) throws RepositoryFunctionException { + Preconditions.checkState( + directoryValue.realRootedPath().getRelativePath().equals(PathFragment.EMPTY_FRAGMENT)); + AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule); PathFragment buildFile = new PathFragment(mapper.get("build_file", Type.STRING)); Path buildFileTarget = workspaceDirectory.getRelative(buildFile); @@ -167,7 +170,8 @@ public abstract class RepositoryFunction implements SkyFunction { Transience.TRANSIENT); } - Path buildFilePath = directoryValue.realRootedPath().asPath().getRelative("BUILD"); + RootedPath buildFilePath = RootedPath.toRootedPath( + directoryValue.realRootedPath().getRoot(), new PathFragment("BUILD")); if (createSymbolicLink(buildFilePath, buildFileTarget, env) == null) { return null; } @@ -207,8 +211,8 @@ public abstract class RepositoryFunction implements SkyFunction { throws RepositoryFunctionException { try { for (Path target : targetDirectory.getDirectoryEntries()) { - Path symlinkPath = - repositoryDirectory.getRelative(target.getBaseName()); + RootedPath symlinkPath = RootedPath.toRootedPath( + repositoryDirectory, new PathFragment(target.getBaseName())); if (createSymbolicLink(symlinkPath, target, env) == null) { return false; } @@ -220,24 +224,23 @@ public abstract class RepositoryFunction implements SkyFunction { return true; } - private static FileValue createSymbolicLink(Path from, Path to, Environment env) + private static FileValue createSymbolicLink(RootedPath from, Path to, Environment env) throws RepositoryFunctionException { + Path fromPath = from.asPath(); try { // Remove not-symlinks that are already there. - if (from.exists()) { - from.delete(); + if (fromPath.exists()) { + fromPath.delete(); } - FileSystemUtils.ensureSymbolicLink(from, to); + FileSystemUtils.ensureSymbolicLink(fromPath, to); } catch (IOException e) { throw new RepositoryFunctionException( new IOException(String.format("Error creating symbolic link from %s to %s: %s", from, to, e.getMessage())), Transience.TRANSIENT); } - SkyKey outputDirectoryKey = FileValue.key(RootedPath.toRootedPath( - from, PathFragment.EMPTY_FRAGMENT)); try { - return (FileValue) env.getValueOrThrow(outputDirectoryKey, IOException.class, + return (FileValue) env.getValueOrThrow(FileValue.key(from), IOException.class, FileSymlinkException.class, InconsistentFilesystemException.class); } catch (IOException | FileSymlinkException | InconsistentFilesystemException e) { throw new RepositoryFunctionException( |