aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-10-20 13:20:29 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-10-20 16:38:22 +0000
commitda68599a55ada7b04badfcb456c3f1cb8395c2c0 (patch)
tree1f6f02bcfc1a199219944f765d0e258a1930071b /src
parentc68e3b34e0724a2c756ec9786dc22ec98dc261c5 (diff)
Add %crosstool_top% metasyntax for builtin cxx include directories.
Instead of two metasyntactic variables and one random bit of magic which changes relative paths to be children of crosstool, we now have three consistent pieces of metasyntax; except that since we can't actually remove the old syntax, we have either way for the time being. RELNOTES[NEW]: accept %crosstool_top% in cxx_builtin_include_directory -- MOS_MIGRATED_REVID=105854779
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
index 80f1644ece..23a8a21b98 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
@@ -850,11 +850,17 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
private static final PathFragment SYSROOT_FRAGMENT = new PathFragment("%sysroot%");
private static final PathFragment WORKSPACE_FRAGMENT = new PathFragment("%workspace%");
+ private static final PathFragment CROSSTOOL_FRAGMENT = new PathFragment("%crosstool_top%");
/**
- * Resolve the given include directory. If it is not absolute, it is
- * interpreted relative to the crosstool top. If it starts with %sysroot%/,
- * that part is replaced with the actual sysroot.
+ * Resolve the given include directory. If it starts with %sysroot%/,
+ * that part is replaced with the actual sysroot. If it starts with %workspace%/,
+ * that part is replaced with the empty string (essentially making it
+ * relative to the build directory), and if it starts with %crosstool_top%/
+ * or is any relative path, it is interpreted relative to the crosstool top.
+ * Absolute paths remain unchanged. The use of assumed-crosstool-relative
+ * specifications is considered deprecated, and all such uses should eventually
+ * be replaced by "%crosstool_top%/".
*/
static PathFragment resolveIncludeDir(String s, PathFragment sysroot,
PathFragment crosstoolTopPathFragment) {
@@ -871,7 +877,8 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
} else if (path.startsWith(WORKSPACE_FRAGMENT)) {
return path.subFragment(1, path.segmentCount());
} else {
- return crosstoolTopPathFragment.getRelative(path);
+ return crosstoolTopPathFragment.getRelative(path.startsWith(CROSSTOOL_FRAGMENT)
+ ? path.subFragment(1, path.segmentCount()) : path);
}
}