[pkg-d-commits] [ldc] 121/149: Append default file extension if -of doesn't contain any
Matthias Klumpp
mak at moszumanska.debian.org
Sun Apr 23 22:37:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.2.0
in repository ldc.
commit 5f8cae7b3462e6b176e8fdb461b6141264ae8344
Author: Martin <noone at nowhere.com>
Date: Fri Feb 17 16:59:38 2017 +0100
Append default file extension if -of doesn't contain any
Resolves issue #2001.
---
driver/linker.cpp | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/driver/linker.cpp b/driver/linker.cpp
index 496fd87..367ef50 100644
--- a/driver/linker.cpp
+++ b/driver/linker.cpp
@@ -73,23 +73,28 @@ static void CreateDirectoryOnDisk(llvm::StringRef fileName) {
//////////////////////////////////////////////////////////////////////////////
static std::string getOutputName(bool const sharedLib) {
- if (global.params.exefile)
- return global.params.exefile;
-
- // Infer output name from first object file.
- std::string result = global.params.objfiles->dim
- ? FileName::removeExt((*global.params.objfiles)[0])
- : "a.out";
+ const auto &triple = *global.params.targetTriple;
const char *extension = nullptr;
if (sharedLib) {
extension = global.dll_ext;
- if (!global.params.targetTriple->isWindowsMSVCEnvironment())
- result = "lib" + result;
- } else if (global.params.targetTriple->isOSWindows()) {
+ } else if (triple.isOSWindows()) {
extension = "exe";
}
+ if (global.params.exefile) {
+ return extension ? FileName::defaultExt(global.params.exefile, extension)
+ : global.params.exefile;
+ }
+
+ // Infer output name from first object file.
+ std::string result = global.params.objfiles->dim
+ ? FileName::removeExt((*global.params.objfiles)[0])
+ : "a.out";
+
+ if (sharedLib && !triple.isWindowsMSVCEnvironment())
+ result = "lib" + result;
+
if (global.params.run) {
// If `-run` is passed, the executable is temporary and is removed
// after execution. Make sure the name does not collide with other files
@@ -100,11 +105,9 @@ static std::string getOutputName(bool const sharedLib) {
tempFilename);
if (!EC)
result = tempFilename.str();
- } else {
- if (extension) {
- result += ".";
- result += extension;
- }
+ } else if (extension) {
+ result += '.';
+ result += extension;
}
return result;
@@ -840,13 +843,13 @@ int createStaticLibrary() {
// output filename
std::string libName;
if (global.params.libname) { // explicit
- libName = global.params.libname;
+ libName = FileName::defaultExt(global.params.libname, global.lib_ext);
} else { // infer from first object file
libName = global.params.objfiles->dim
? FileName::removeExt((*global.params.objfiles)[0])
: "a.out";
- libName.push_back('.');
- libName.append(global.lib_ext);
+ libName += '.';
+ libName += global.lib_ext;
}
if (createStaticLibInObjdir && global.params.objdir &&
!FileName::absolute(libName.c_str())) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list