Closed davido closed 9 years ago
OK, tracked it down. This is path separator mismatch bug, specific to other platform Genrule.addSymlinkCommands():329:
[...]
// By the time we get this far, all source paths (the keys in the map) have been converted
// to paths relative to the project root. We want the path relative to the build target, so
// strip the base path.
if (entry.getValue().equals(canonicalPath)) {
if (localPath.startsWith(basePath)) {
localPath = localPath.substring(basePathLength);
} else {
localPath = canonicalPath.getFileName().toString();
}
}
[...]
The values are:
basePath = "gerrit-war/"
localPath = "gerrit-war\src\main\webapp\WEB-INF\extra\jetty7\gerrit-jetty.sh"
So the condition if (localPath.startsWith(basePath))
is erroneously false.
This diff fixed this:
diff --git a/src/com/facebook/buck/shell/Genrule.java b/src/com/facebook/buck/shell/Genrule.java
old mode 100644
new mode 100755
index 2e6e967..e3dd044
--- a/src/com/facebook/buck/shell/Genrule.java
+++ b/src/com/facebook/buck/shell/Genrule.java
@@ -38,6 +38,7 @@ import com.facebook.buck.step.fs.MkdirStep;
import com.facebook.buck.step.fs.RmStep;
import com.facebook.buck.util.BuckConstant;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.CharMatcher;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
@@ -317,6 +318,7 @@ public class Genrule extends AbstractBuildRule implements HasOutputName {
@VisibleForTesting
void addSymlinkCommands(ImmutableList.Builder<Step> commands) {
String basePath = getBuildTarget().getBasePathWithSlash();
+ String basePathWithoutTrailingSlash = CharMatcher.is('/').trimTrailingFrom(basePath);
int basePathLength = basePath.length();
// Symlink all sources into the temp directory so that they can be used in the genrule.
@@ -330,7 +332,7 @@ public class Genrule extends AbstractBuildRule implements HasOutputName {
// to paths relative to the project root. We want the path relative to the build target, so
// strip the base path.
if (entry.getValue().equals(canonicalPath)) {
- if (localPath.startsWith(basePath)) {
+ if (localPath.startsWith(basePathWithoutTrailingSlash)) {
localPath = localPath.substring(basePathLength);
} else {
localPath = canonicalPath.getFileName().toString();
Fixed meantime by 923579e2089af2972aabe908af90fdba4ec71bf8.
Consider the following content of
BUCK
build file in gerrit-war sub-directory:And the following source directory structure:
The following verbose invocation describes the problem:
It seems like
mkdir
andlink
steps are broken; I would expect them to be:Note: when the same rule is placed in
BUCK
in the root directory and the content of gerrit-war sub-directory is also moved to the base project directory, then it works as expected:In this case the content of target
zip
file is also correct: