Fix the ldcbinarypath config file rewriting.

This commit is contained in:
Christian Kamm
2009-05-10 18:14:36 +02:00
parent d7c984fbef
commit dfaba71dce
2 changed files with 6 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <string.h> #include <cstring>
#include "llvm/System/Path.h" #include "llvm/System/Path.h"
@@ -85,6 +85,9 @@ bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename)
// handle switches // handle switches
if (root.exists("switches")) if (root.exists("switches"))
{ {
std::string binpathkey = "%%ldcbinarypath%%";
std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname();
libconfig::Setting& arr = cfg->lookup("default.switches"); libconfig::Setting& arr = cfg->lookup("default.switches");
int len = arr.getLength(); int len = arr.getLength();
for (int i=0; i<len; i++) for (int i=0; i<len; i++)
@@ -92,13 +95,10 @@ bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename)
std::string v = arr[i]; std::string v = arr[i];
// replace binpathkey with binpath // replace binpathkey with binpath
std::string binpathkey = "%%ldcbinarypath%%";
sys::Path binpathgetter = sys::Path::GetMainExecutable(argv0, mainAddr);
binpathgetter.eraseComponent();
std::string binpath = binpathgetter.toString();
size_t p; size_t p;
while (std::string::npos != (p = v.find(binpathkey))) while (std::string::npos != (p = v.find(binpathkey)))
v.replace(p, binpathkey.size(), binpath); v.replace(p, binpathkey.size(), binpath);
switches.push_back(strdup(v.c_str())); switches.push_back(strdup(v.c_str()));
} }
} }

View File

@@ -9,7 +9,7 @@ default:
switches = [ switches = [
"-I@RUNTIME_DIR@", "-I@RUNTIME_DIR@",
"-I@RUNTIME_DIR@/lib/common", "-I@RUNTIME_DIR@/lib/common",
"-L-L%%ldcbinarydir%%/../lib", "-L-L%%ldcbinarypath%%/../lib",
"-d-version=Tango", "-d-version=Tango",
"-defaultlib=@RUNTIME_AIO@", "-defaultlib=@RUNTIME_AIO@",
"-debuglib=@RUNTIME_AIO@" "-debuglib=@RUNTIME_AIO@"