summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cvtres/llvm-cvtres.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-04-21 17:30:29 +0000
committerZachary Turner <zturner@google.com>2017-04-21 17:30:29 +0000
commit087edfa2e82cc508042339f1e0f348e7ca7b17f2 (patch)
tree8657b32a763631a5b64ed2aa528675690221c15f /llvm/tools/llvm-cvtres/llvm-cvtres.cpp
parentd1be869744bee92130c95c893b63abb47933f05d (diff)
downloadbcm5719-llvm-087edfa2e82cc508042339f1e0f348e7ca7b17f2.tar.gz
bcm5719-llvm-087edfa2e82cc508042339f1e0f348e7ca7b17f2.zip
Add empty shell of llvm-cvtres.
This marks the beginning of an effort to port remaining MSVC toolchain miscellaneous utilities to all platforms. Currently clang-cl shells out to certain additional tools such as the IDL compiler, resource compiler, and a few other tools, but as these tools are Windows-only it limits the ability of clang to target Windows on other platforms. having a full suite of these tools directly in LLVM should eliminate this constraint. The current implementation provides no actual functionality, it is just an empty skeleton executable for the purposes of making incremental changes. Differential Revision: https://reviews.llvm.org/D32095 Patch by Eric Beckmann (ecbeckmann@google.com) llvm-svn: 301004
Diffstat (limited to 'llvm/tools/llvm-cvtres/llvm-cvtres.cpp')
-rw-r--r--llvm/tools/llvm-cvtres/llvm-cvtres.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/llvm/tools/llvm-cvtres/llvm-cvtres.cpp b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp
new file mode 100644
index 00000000000..f03e0b772e1
--- /dev/null
+++ b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -0,0 +1,86 @@
+//===- llvm-cvtres.cpp - Serialize .res files into .obj ---------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Serialize .res files into .obj files. This is intended to be a
+// platform-independent port of Microsoft's cvtres.exe.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm-cvtres.h"
+
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Process.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+namespace {
+
+enum ID {
+ OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR) \
+ OPT_##ID,
+#include "Opts.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#include "Opts.inc"
+#undef PREFIX
+
+static const opt::OptTable::Info InfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR) \
+ { \
+ PREFIX, NAME, HELPTEXT, \
+ METAVAR, OPT_##ID, opt::Option::KIND##Class, \
+ PARAM, FLAGS, OPT_##GROUP, \
+ OPT_##ALIAS, ALIASARGS},
+#include "Opts.inc"
+#undef OPTION
+};
+
+class CvtResOptTable : public opt::OptTable {
+public:
+ CvtResOptTable() : OptTable(InfoTable, true) {}
+};
+
+static ExitOnError ExitOnErr;
+}
+
+int main(int argc_, const char *argv_[]) {
+ sys::PrintStackTraceOnErrorSignal(argv_[0]);
+ PrettyStackTraceProgram X(argc_, argv_);
+
+ ExitOnErr.setBanner("llvm-cvtres: ");
+
+ SmallVector<const char *, 256> argv;
+ SpecificBumpPtrAllocator<char> ArgAllocator;
+ ExitOnErr(errorCodeToError(sys::Process::GetArgumentVector(
+ argv, makeArrayRef(argv_, argc_), ArgAllocator)));
+
+ llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+
+ CvtResOptTable T;
+ unsigned MAI, MAC;
+ ArrayRef<const char *> ArgsArr = makeArrayRef(argv_, argc_);
+ opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
+
+ if (InputArgs.hasArg(OPT_HELP))
+ T.PrintHelp(outs(), "cvtres", "Resource Converter", false);
+
+ return 0;
+}
OpenPOWER on IntegriCloud