llvm.org GIT mirror llvm / 83e112a
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) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301004 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
6 changed file(s) with 149 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-cvtres /h > %t
1 ; RUN: FileCheck -input-file=%t %s -check-prefix=HELP_TEST
2
3 ; HELP_TEST: OVERVIEW: Resource Converter
0 set(LLVM_LINK_COMPONENTS
1 Option
2 Support
3 )
4
5 set(LLVM_TARGET_DEFINITIONS Opts.td)
6
7 tablegen(LLVM Opts.inc -gen-opt-parser-defs)
8 add_public_tablegen_target(CvtResTableGen)
9
10 add_llvm_tool(llvm-cvtres
11 llvm-cvtres.cpp
12 )
0 ;===- ./tools/llvm-cvtres/LLVMBuild.txt ------------------------*- Conf -*--===;
1 ;
2 ; The LLVM Compiler Infrastructure
3 ;
4 ; This file is distributed under the University of Illinois Open Source
5 ; License. See LICENSE.TXT for details.
6 ;
7 ;===------------------------------------------------------------------------===;
8 ;
9 ; This is an LLVMBuild description file for the components in this subdirectory.
10 ;
11 ; For more information on the LLVMBuild system, please see:
12 ;
13 ; http://llvm.org/docs/LLVMBuild.html
14 ;
15 ;===------------------------------------------------------------------------===;
16
17 [component_0]
18 type = Tool
19 name = llvm-cvtres
20 parent = Tools
21 required_libraries = Option Support
0 include "llvm/Option/OptParser.td"
1
2 def DEFINE : Joined<["/"], "DEFINE:">, HelpText<"">, MetaVarName<"symbol">;
3 def FOLDDUPS : Flag<["/"], "FOLDDUPS:">, HelpText<"">;
4 def MACHINE : Joined<["/"], "MACHINE:">, HelpText<"">, MetaVarName<"{ARM|EBC|IA64|X64|X86}">;
5 def NOLOGO : Flag<["/"], "NOLOGO">, HelpText<"">;
6 def OUT : Joined<["/"], "OUT:">, HelpText<"">, MetaVarName<"filename">;
7 def READONLY : Flag<["/"], "READONLY">, HelpText<"">;
8 def VERBOSE : Flag<["/"], "VERBOSE">, HelpText<"">;
9 def HELP : Flag<["/"], "HELP">;
10 def H : Flag<["/"], "H">, Alias;
0 //===- llvm-cvtres.cpp - Serialize .res files into .obj ---------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Serialize .res files into .obj files. This is intended to be a
10 // platform-independent port of Microsoft's cvtres.exe.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm-cvtres.h"
15
16 #include "llvm/Option/Arg.h"
17 #include "llvm/Option/ArgList.h"
18 #include "llvm/Option/Option.h"
19 #include "llvm/Support/Error.h"
20 #include "llvm/Support/ManagedStatic.h"
21 #include "llvm/Support/PrettyStackTrace.h"
22 #include "llvm/Support/Process.h"
23 #include "llvm/Support/Signals.h"
24 #include "llvm/Support/raw_ostream.h"
25
26 using namespace llvm;
27
28 namespace {
29
30 enum ID {
31 OPT_INVALID = 0, // This is not an option ID.
32 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
33 HELPTEXT, METAVAR) \
34 OPT_##ID,
35 #include "Opts.inc"
36 #undef OPTION
37 };
38
39 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
40 #include "Opts.inc"
41 #undef PREFIX
42
43 static const opt::OptTable::Info InfoTable[] = {
44 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
45 HELPTEXT, METAVAR) \
46 { \
47 PREFIX, NAME, HELPTEXT, \
48 METAVAR, OPT_##ID, opt::Option::KIND##Class, \
49 PARAM, FLAGS, OPT_##GROUP, \
50 OPT_##ALIAS, ALIASARGS},
51 #include "Opts.inc"
52 #undef OPTION
53 };
54
55 class CvtResOptTable : public opt::OptTable {
56 public:
57 CvtResOptTable() : OptTable(InfoTable, true) {}
58 };
59
60 static ExitOnError ExitOnErr;
61 }
62
63 int main(int argc_, const char *argv_[]) {
64 sys::PrintStackTraceOnErrorSignal(argv_[0]);
65 PrettyStackTraceProgram X(argc_, argv_);
66
67 ExitOnErr.setBanner("llvm-cvtres: ");
68
69 SmallVector argv;
70 SpecificBumpPtrAllocator ArgAllocator;
71 ExitOnErr(errorCodeToError(sys::Process::GetArgumentVector(
72 argv, makeArrayRef(argv_, argc_), ArgAllocator)));
73
74 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
75
76 CvtResOptTable T;
77 unsigned MAI, MAC;
78 ArrayRef ArgsArr = makeArrayRef(argv_, argc_);
79 opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
80
81 if (InputArgs.hasArg(OPT_HELP))
82 T.PrintHelp(outs(), "cvtres", "Resource Converter", false);
83
84 return 0;
85 }
0 //===- llvm-cvtres.h ------------------------------------------ *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMCVTRES_LLVMCVTRES_H
10 #define LLVM_TOOLS_LLVMCVTRES_LLVMCVTRES_H
11
12 #endif