[PATCH] D44808: Fix lib.exe detection when running within MSVC toolchain
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 9 14:18:19 PDT 2018
aganea updated this revision to Diff 141740.
aganea added a comment.
Improved test a bit. Also, printHelpMessage() now shows the same tool name casing as on the command-line, ie:
$ ./RanLib
F:\svn\llvm\test\RanLib: error loading '': no such file or directory.
OVERVIEW: LLVM Ranlib (llvm-ranlib)
This program generates an index to speed access to archives
USAGE: RanLib <archive-file>
$ ./Ar
F:\svn\llvm\test\Ar: An archive name must be specified.
OVERVIEW: LLVM Archiver (llvm-ar)
This program archives bitcode files into single libraries
USAGE: Ar [options] [relpos] [count] <archive-file> [members]...
Repository:
rL LLVM
https://reviews.llvm.org/D44808
Files:
test/tools/llvm-ar/case-detection.test
tools/llvm-ar/llvm-ar.cpp
Index: tools/llvm-ar/llvm-ar.cpp
===================================================================
--- tools/llvm-ar/llvm-ar.cpp
+++ tools/llvm-ar/llvm-ar.cpp
@@ -26,6 +26,7 @@
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -57,7 +58,7 @@
This program generates an index to speed access to archives
-USAGE: llvm-ranlib <archive-file>
+USAGE: {0} <archive-file>
OPTIONS:
-help - Display available options
@@ -69,7 +70,7 @@
This program archives bitcode files into single libraries
-USAGE: llvm-ar [options] [relpos] [count] <archive-file> [members]...
+USAGE: {0} [options] [relpos] [count] <archive-file> [members]...
OPTIONS:
-M -
@@ -109,10 +110,10 @@
)";
void printHelpMessage() {
- if (Stem.find("ranlib") != StringRef::npos)
- outs() << RanlibHelp;
- else if (Stem.find("ar") != StringRef::npos)
- outs() << ArHelp;
+ if (Stem.find_lower("ranlib") != StringRef::npos)
+ outs() << formatv(RanlibHelp, Stem);
+ else if (Stem.find_lower("ar") != StringRef::npos)
+ outs() << formatv(ArHelp, Stem);
}
// Show the error message and exit.
@@ -960,16 +961,16 @@
llvm::InitializeAllAsmParsers();
Stem = sys::path::stem(ToolName);
- if (Stem.find("dlltool") != StringRef::npos)
+ if (Stem.find_lower("dlltool") != StringRef::npos)
return dlltoolDriverMain(makeArrayRef(argv, argc));
- if (Stem.find("ranlib") != StringRef::npos)
+ if (Stem.find_lower("ranlib") != StringRef::npos)
return ranlib_main(argc, argv);
- if (Stem.find("lib") != StringRef::npos)
+ if (Stem.find_lower("lib") != StringRef::npos)
return libDriverMain(makeArrayRef(argv, argc));
- if (Stem.find("ar") != StringRef::npos)
+ if (Stem.find_lower("ar") != StringRef::npos)
return ar_main(argc, argv);
fail("Not ranlib, ar, lib or dlltool!");
}
Index: test/tools/llvm-ar/case-detection.test
===================================================================
--- test/tools/llvm-ar/case-detection.test
+++ test/tools/llvm-ar/case-detection.test
@@ -0,0 +1,11 @@
+-- Test CamelCase tool name to ensure detection works properly
+
+RUN: yaml2obj %S/Inputs/coff.yaml -o %t.obj
+RUN: rm -rf %t1
+RUN: mkdir %t1
+RUN: cp llvm-ar %t1/Lib
+RUN: %t1/Lib /OUT:%t.lib %t.obj | FileCheck %s -allow-empty
+RUN: cp llvm-ar %t1/Ar
+RUN: %t1/Ar crs %t.ar %t.obj | FileCheck %s -allow-empty
+
+CHECK-NOT: OVERVIEW: LLVM Archiver (llvm-ar)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44808.141740.patch
Type: text/x-patch
Size: 2667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180409/85c38925/attachment.bin>
More information about the llvm-commits
mailing list