1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
//===-- driver/configfile.h - LDC config file handling ----------*- C++ -*-===//
//
// LDC – the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
//
// Handles reading and parsing of an LDC config file (ldc.conf/ldc2.conf).
//
//===----------------------------------------------------------------------===//
#pragma once
#include "dmd/root/array.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include <string>
struct ConfigFile {
public:
static ConfigFile instance;
bool read(const char *explicitConfFile, const char *triple);
llvm::StringRef path() {
return pathcstr ? llvm::StringRef(pathcstr) : llvm::StringRef();
}
void extendCommandLine(llvm::SmallVectorImpl<const char *> &args);
const Array<const char *> &libDirs() const { return _libDirs; }
llvm::StringRef rpath() const {
return rpathcstr ? llvm::StringRef(rpathcstr) : llvm::StringRef();
}
private:
bool locate(std::string &pathstr);
static bool sectionMatches(const char *section, const char *triple);
// implemented in D
bool readConfig(const char *cfPath, const char *triple, const char *binDir);
const char *pathcstr = nullptr;
Array<const char *> switches;
Array<const char *> postSwitches;
Array<const char *> _libDirs;
const char *rpathcstr = nullptr;
};
|