mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Implement the correct search for configuration files. llvmc will now try
the following in this order: 1. -config-dir=/path/to/configs 2. LLVM_CONFIG_DIR=/path/to/configs 3. ~/.llvm/etc 4. $prefix/etc 5. /etc/llvm git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15950 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aa43a4b025
commit
b38e40564b
@ -15,6 +15,7 @@
|
|||||||
#include "Configuration.h"
|
#include "Configuration.h"
|
||||||
#include "ConfigLexer.h"
|
#include "ConfigLexer.h"
|
||||||
#include "CompilerDriver.h"
|
#include "CompilerDriver.h"
|
||||||
|
#include "Config/config.h"
|
||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
#include "Support/StringExtras.h"
|
#include "Support/StringExtras.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -22,6 +23,11 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
namespace sys {
|
||||||
|
// From CompilerDriver.cpp (for now)
|
||||||
|
extern bool FileReadable(const std::string& fname);
|
||||||
|
}
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
ConfigLexerInfo ConfigLexerState;
|
ConfigLexerInfo ConfigLexerState;
|
||||||
InputProvider* ConfigLexerInput = 0;
|
InputProvider* ConfigLexerInput = 0;
|
||||||
@ -389,27 +395,47 @@ namespace {
|
|||||||
CompilerDriver::ConfigData*
|
CompilerDriver::ConfigData*
|
||||||
LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
|
LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
|
||||||
CompilerDriver::ConfigData* result = 0;
|
CompilerDriver::ConfigData* result = 0;
|
||||||
|
std::string dir_name;
|
||||||
if (configDir.empty()) {
|
if (configDir.empty()) {
|
||||||
FileInputProvider fip( std::string("/etc/llvm/") + ftype );
|
// Try the environment variable
|
||||||
if (!fip.okay()) {
|
const char* conf = getenv("LLVM_CONFIG_DIR");
|
||||||
fip.error("Configuration for '" + ftype + "' is not available.");
|
if (conf) {
|
||||||
fip.checkErrors();
|
dir_name = conf;
|
||||||
|
dir_name += "/";
|
||||||
|
if (!::sys::FileReadable(dir_name + ftype))
|
||||||
|
throw "Configuration file for '" + ftype + "' is not available.";
|
||||||
|
} else {
|
||||||
|
// Try the user's home directory
|
||||||
|
const char* home = getenv("HOME");
|
||||||
|
if (home) {
|
||||||
|
dir_name = home;
|
||||||
|
dir_name += "/.llvm/etc/";
|
||||||
|
if (!::sys::FileReadable(dir_name + ftype)) {
|
||||||
|
// Okay, try the LLVM installation directory
|
||||||
|
dir_name = LLVM_ETCDIR;
|
||||||
|
dir_name += "/";
|
||||||
|
if (!::sys::FileReadable(dir_name + ftype)) {
|
||||||
|
// Okay, try the "standard" place
|
||||||
|
dir_name = "/etc/llvm/";
|
||||||
|
if (!::sys::FileReadable(dir_name + ftype)) {
|
||||||
|
throw "Configuration file for '" + ftype + "' is not available.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
result = new CompilerDriver::ConfigData();
|
|
||||||
ParseConfigData(fip,*result);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FileInputProvider fip( configDir + "/" + ftype );
|
dir_name = configDir + "/";
|
||||||
if (!fip.okay()) {
|
if (!::sys::FileReadable(dir_name + ftype)) {
|
||||||
fip.error("Configuration for '" + ftype + "' is not available.");
|
throw "Configuration file for '" + ftype + "' is not available.";
|
||||||
fip.checkErrors();
|
}
|
||||||
|
}
|
||||||
|
FileInputProvider fip( dir_name + ftype );
|
||||||
|
if (!fip.okay()) {
|
||||||
|
throw "Configuration file for '" + ftype + "' is not available.";
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
result = new CompilerDriver::ConfigData();
|
result = new CompilerDriver::ConfigData();
|
||||||
ParseConfigData(fip,*result);
|
ParseConfigData(fip,*result);
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user