mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-12 02:43:14 +01:00
Fix the ldcbinarypath config file rewriting.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "llvm/System/Path.h"
|
||||
|
||||
@@ -85,6 +85,9 @@ bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename)
|
||||
// handle 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");
|
||||
int len = arr.getLength();
|
||||
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];
|
||||
|
||||
// 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;
|
||||
while (std::string::npos != (p = v.find(binpathkey)))
|
||||
v.replace(p, binpathkey.size(), binpath);
|
||||
|
||||
switches.push_back(strdup(v.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ default:
|
||||
switches = [
|
||||
"-I@RUNTIME_DIR@",
|
||||
"-I@RUNTIME_DIR@/lib/common",
|
||||
"-L-L%%ldcbinarydir%%/../lib",
|
||||
"-L-L%%ldcbinarypath%%/../lib",
|
||||
"-d-version=Tango",
|
||||
"-defaultlib=@RUNTIME_AIO@",
|
||||
"-debuglib=@RUNTIME_AIO@"
|
||||
|
||||
Reference in New Issue
Block a user