mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-30 11:00:05 +02:00
Fix the ldcbinarypath config file rewriting.
This commit is contained in:
@@ -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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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@"
|
||||||
|
|||||||
Reference in New Issue
Block a user