summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-11 22:59:47 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-11 22:59:47 +0000
commitc2f9c8984af4fa82b42408c0ce1c791c487502d0 (patch)
treefab330f3dd602708f882b58db035a7420caed10a /tools
parent01b825d45b6f067e42e4c3d160b87f34459aab8c (diff)
downloadllvm-c2f9c8984af4fa82b42408c0ce1c791c487502d0.tar.gz
llvm-c2f9c8984af4fa82b42408c0ce1c791c487502d0.tar.bz2
llvm-c2f9c8984af4fa82b42408c0ce1c791c487502d0.tar.xz
llvm-config-2: Detect when we are running out of a BuildTools development tree, so that we can always provide library/include information for the real build directory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144420 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-config-2/llvm-config.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/llvm-config-2/llvm-config.cpp b/tools/llvm-config-2/llvm-config.cpp
index 30ace56f4c..fddd481230 100644
--- a/tools/llvm-config-2/llvm-config.cpp
+++ b/tools/llvm-config-2/llvm-config.cpp
@@ -174,6 +174,7 @@ int main(int argc, char **argv) {
bool IsInDevelopmentTree, DevelopmentTreeLayoutIsCMakeStyle;
llvm::SmallString<256> CurrentPath(GetExecutablePath(argv[0]).str());
std::string CurrentExecPrefix;
+ std::string ActiveObjRoot;
// Create an absolute path, and pop up one directory (we expect to be inside a
// bin dir).
@@ -187,9 +188,19 @@ int main(int argc, char **argv) {
if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE) {
IsInDevelopmentTree = true;
DevelopmentTreeLayoutIsCMakeStyle = false;
+
+ // If we are in a development tree, then check if we are in a BuildTools
+ // directory. This indicates we are built for the build triple, but we
+ // always want to provide information for the host triple.
+ if (sys::path::filename(LLVM_OBJ_ROOT) == "BuildTools") {
+ ActiveObjRoot = sys::path::parent_path(LLVM_OBJ_ROOT);
+ } else {
+ ActiveObjRoot = LLVM_OBJ_ROOT;
+ }
} else if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/bin") {
IsInDevelopmentTree = true;
DevelopmentTreeLayoutIsCMakeStyle = true;
+ ActiveObjRoot = LLVM_OBJ_ROOT;
} else {
IsInDevelopmentTree = false;
}
@@ -204,18 +215,18 @@ int main(int argc, char **argv) {
// CMake organizes the products differently than a normal prefix style
// layout.
if (DevelopmentTreeLayoutIsCMakeStyle) {
- ActiveIncludeDir = std::string(LLVM_OBJ_ROOT) + "/include";
- ActiveBinDir = std::string(LLVM_OBJ_ROOT) + "/bin/" + LLVM_BUILDMODE;
- ActiveLibDir = std::string(LLVM_OBJ_ROOT) + "/lib/" + LLVM_BUILDMODE;
+ ActiveIncludeDir = ActiveObjRoot + "/include";
+ ActiveBinDir = ActiveObjRoot + "/bin/" + LLVM_BUILDMODE;
+ ActiveLibDir = ActiveObjRoot + "/lib/" + LLVM_BUILDMODE;
} else {
- ActiveIncludeDir = std::string(LLVM_OBJ_ROOT) + "/include";
- ActiveBinDir = std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE + "/bin";
- ActiveLibDir = std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE + "/lib";
+ ActiveIncludeDir = ActiveObjRoot + "/include";
+ ActiveBinDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/bin";
+ ActiveLibDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/lib";
}
// We need to include files from both the source and object trees.
ActiveIncludeOption = ("-I" + ActiveIncludeDir + " " +
- "-I" + LLVM_OBJ_ROOT + "/include");
+ "-I" + ActiveObjRoot + "/include");
} else {
ActivePrefix = CurrentExecPrefix;
ActiveIncludeDir = ActivePrefix + "/include";