summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/llvm-rc.cpp
diff options
context:
space:
mode:
authorMarek Sokolowski <mnbvmar@gmail.com>2017-07-25 00:25:18 +0000
committerMarek Sokolowski <mnbvmar@gmail.com>2017-07-25 00:25:18 +0000
commit2ce2fa481d7ceebcda70454a1d9ad7348f809c17 (patch)
treefdfa8366a28d1bda623aee8168ba76eaa161e1d0 /llvm/tools/llvm-rc/llvm-rc.cpp
parentdc49af9d32e72cd60a8d8eb1adcca8ea328631ae (diff)
downloadbcm5719-llvm-2ce2fa481d7ceebcda70454a1d9ad7348f809c17.tar.gz
bcm5719-llvm-2ce2fa481d7ceebcda70454a1d9ad7348f809c17.zip
Add an empty shell of llvm-rc.
This starts the development on one of MS Visual Studio binutils, Resource Converter. The tool compiles resource scripts (.rc) into binary resource files (.res). The current implementation does nothing but parse the command line arguments. It is going to be extended in the future. Differential Revision: https://reviews.llvm.org/D35810 llvm-svn: 308940
Diffstat (limited to 'llvm/tools/llvm-rc/llvm-rc.cpp')
-rw-r--r--llvm/tools/llvm-rc/llvm-rc.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
new file mode 100644
index 00000000000..aa97bf9c0d5
--- /dev/null
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -0,0 +1,88 @@
+//===- llvm-rc.cpp - Compile .rc scripts into .res -------------*- C++ -*--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Compile .rc scripts into .res files. This is intended to be a
+// platform-independent port of Microsoft's rc.exe tool.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.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"
+
+#include <system_error>
+
+using namespace llvm;
+
+namespace {
+
+// Input options tables.
+
+enum ID {
+ OPT_INVALID = 0, // This is not a correct option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES) \
+ 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, VALUES) \
+ { \
+ PREFIX, NAME, HELPTEXT, \
+ METAVAR, OPT_##ID, opt::Option::KIND##Class, \
+ PARAM, FLAGS, OPT_##GROUP, \
+ OPT_##ALIAS, ALIASARGS, VALUES},
+#include "Opts.inc"
+#undef OPTION
+};
+
+class RcOptTable : public opt::OptTable {
+public:
+ RcOptTable() : OptTable(InfoTable, /* IgnoreCase = */ true) {}
+};
+
+static ExitOnError ExitOnErr;
+} // anonymous namespace
+
+int main(int argc_, const char *argv_[]) {
+ sys::PrintStackTraceOnErrorSignal(argv_[0]);
+ PrettyStackTraceProgram X(argc_, argv_);
+
+ ExitOnErr.setBanner("llvm-rc: ");
+
+ SmallVector<const char *, 256> argv;
+ SpecificBumpPtrAllocator<char> ArgAllocator;
+ ExitOnErr(errorCodeToError(sys::Process::GetArgumentVector(
+ argv, makeArrayRef(argv_, argc_), ArgAllocator)));
+
+ llvm_shutdown_obj Y;
+
+ RcOptTable T;
+ unsigned MAI, MAC;
+ ArrayRef<const char *> ArgsArr = makeArrayRef(argv_ + 1, argc_);
+ opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
+
+ // The tool prints nothing when invoked with no command-line arguments.
+ if (InputArgs.hasArg(OPT_HELP))
+ T.PrintHelp(outs(), "rc", "Resource Converter", false);
+
+ return 0;
+}
OpenPOWER on IntegriCloud