Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into merge-2.068
- Loading branch information
Showing
23 changed files
with
246 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//===-- exe_path.cpp ------------------------------------------------------===// | ||
// | ||
// LDC – the LLVM D compiler | ||
// | ||
// This file is distributed under the BSD-style LDC license. See the LICENSE | ||
// file for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "exe_path.h" | ||
|
||
#include <llvm/Support/Path.h> | ||
#if LDC_LLVM_VER >= 304 | ||
#include <llvm/Support/FileSystem.h> | ||
#endif | ||
|
||
using std::string; | ||
namespace path = llvm::sys::path; | ||
|
||
namespace { string exePath; } | ||
|
||
void exe_path::initialize(const char* arg0, void* mainAddress) | ||
{ | ||
assert(exePath.empty()); | ||
#if LDC_LLVM_VER >= 304 | ||
exePath = llvm::sys::fs::getMainExecutable(arg0, mainAddress); | ||
#else | ||
exePath = llvm::sys::Path::GetMainExecutable(arg0, mainAddress).str(); | ||
#endif | ||
} | ||
|
||
const string& exe_path::getExePath() | ||
{ | ||
assert(!exePath.empty()); | ||
return exePath; | ||
} | ||
|
||
string exe_path::getBinDir() | ||
{ | ||
assert(!exePath.empty()); | ||
return path::parent_path(exePath); | ||
} | ||
|
||
string exe_path::getBaseDir() | ||
{ | ||
string binDir = getBinDir(); | ||
assert(!binDir.empty()); | ||
return path::parent_path(binDir); | ||
} | ||
|
||
string exe_path::prependBinDir(const char* suffix) | ||
{ | ||
llvm::SmallString<128> r(getBinDir()); | ||
path::append(r, suffix); | ||
return r.str(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===-- driver/exe_path.h - Executable path management ----------*- C++ -*-===// | ||
// | ||
// LDC – the LLVM D compiler | ||
// | ||
// This file is distributed under the BSD-style LDC license. See the LICENSE | ||
// file for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Stores the program's executable path and provides some helpers to generate | ||
// derived paths. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LDC_DRIVER_EXE_PATH_H | ||
#define LDC_DRIVER_EXE_PATH_H | ||
|
||
#include <string> | ||
|
||
namespace exe_path | ||
{ | ||
void initialize(const char* arg0, void* mainAddress); | ||
|
||
const std::string& getExePath(); // <baseDir>/bin/ldc2 | ||
std::string getBinDir(); // <baseDir>/bin | ||
std::string getBaseDir(); // <baseDir> | ||
std::string prependBinDir(const char* suffix); // <baseDir>/bin/<suffix> | ||
} | ||
|
||
#endif // LDC_DRIVER_EXE_PATH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.