llvm.org GIT mirror llvm / c6f54fe
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308940 91177308-0d34-0410-b5e6-96231b3b80d8 Marek Sokolowski 2 years ago
6 changed file(s) with 196 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-rc /h > %t1
1 ; RUN: llvm-rc /? > %t2
2 ; RUN: diff %t1 %t2
3 ; RUN: FileCheck -input-file=%t1 %s
4
5 ; CHECK: OVERVIEW: Resource Converter
6 ; CHECK-DAG: USAGE: rc [options]
7 ; CHECK-DAG: OPTIONS:
8 ; CHECK-NEXT: /? Display this help and exit.
9 ; CHECK-NEXT: /D Define a symbol for the C preprocessor.
10 ; CHECK-NEXT: /FO Change the output file location.
11 ; CHECK-NEXT: /H Display this help and exit.
12 ; CHECK-NEXT: /I Add an include path.
13 ; CHECK-NEXT: /LN Set the default language name.
14 ; CHECK-NEXT: /L Set the default language identifier.
15 ; CHECK-NEXT: /N Null-terminate all strings in the string table.
16 ; CHECK-NEXT: /U Undefine a symbol for the C preprocessor.
17 ; CHECK-NEXT: /V Be verbose.
18 ; CHECK-NEXT: /X Ignore 'include' variable.
19 ; CHECK-NEXT: /Y Suppress warnings on duplicate resource IDs.
4242 llvm-objdump
4343 llvm-pdbutil
4444 llvm-profdata
45 llvm-rc
4546 llvm-rtdyld
4647 llvm-size
4748 llvm-split
0 set(LLVM_LINK_COMPONENTS
1 Option
2 )
3
4 set(LLVM_TARGET_DEFINITIONS Opts.td)
5
6 tablegen(LLVM Opts.inc -gen-opt-parser-defs)
7 add_public_tablegen_target(RcTableGen)
8
9 add_llvm_tool(llvm-rc
10 llvm-rc.cpp
11 )
0 ;===- ./tools/llvm-rc/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-rc
20 parent = Tools
21 required_libraries = Option
0 include "llvm/Option/OptParser.td"
1
2 // All the switches can be preceded by either '/' or '-'.
3 // These options seem to be important for the tool
4 // and should be implemented.
5
6 def FILEOUT : Separate<[ "/", "-" ], "FO">,
7 HelpText<"Change the output file location.">;
8
9 def DEFINE : Separate<[ "/", "-" ], "D">,
10 HelpText<"Define a symbol for the C preprocessor.">;
11 def UNDEF : Separate<[ "/", "-" ], "U">,
12 HelpText<"Undefine a symbol for the C preprocessor.">;
13
14 def LANG_ID : Separate<[ "/", "-" ], "L">,
15 HelpText<"Set the default language identifier.">;
16 def LANG_NAME : Separate<[ "/", "-" ], "LN">,
17 HelpText<"Set the default language name.">;
18
19 def INCLUDE : Separate<[ "/", "-" ], "I">, HelpText<"Add an include path.">;
20 def NOINCLUDE : Flag<[ "/", "-" ], "X">, HelpText<"Ignore 'include' variable.">;
21
22 def ADD_NULL : Flag<[ "/", "-" ], "N">,
23 HelpText<"Null-terminate all strings in the string table.">;
24
25 def DUPID_NOWARN : Flag<[ "/", "-" ], "Y">,
26 HelpText<"Suppress warnings on duplicate resource IDs.">;
27
28 def VERBOSE : Flag<[ "/", "-" ], "V">, HelpText<"Be verbose.">;
29 def HELP : Flag<[ "/", "-" ], "?">, HelpText<"Display this help and exit.">;
30 def H : Flag<[ "/", "-" ], "H">,
31 Alias,
32 HelpText<"Display this help and exit.">;
33
34 // Unused switches (at least for now). These will stay unimplemented
35 // in an early stage of development and can be ignored. However, we need to
36 // parse them in order to preserve the compatibility with the original tool.
37
38 def NOLOGO : Flag<[ "/", "-" ], "NOLOGO">;
39 def R : Flag<[ "/", "-" ], "R">;
40 def SL : Flag<[ "/", "-" ], "SL">;
41
42 // (Codepages support.)
43 def C : Flag<[ "/", "-" ], "C">;
44 def W : Flag<[ "/", "-" ], "W">;
45
46 // (Support of MUI and similar.)
47 def FM : Separate<[ "/", "-" ], "FM">;
48 def Q : Separate<[ "/", "-" ], "Q">;
49 def G : Flag<[ "/", "-" ], "G">;
50 def GN : Flag<[ "/", "-" ], "GN">;
51 def G1 : Flag<[ "/", "-" ], "G1">;
52 def G2 : Flag<[ "/", "-" ], "G2">;
0 //===- llvm-rc.cpp - Compile .rc scripts into .res -------------*- 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 // Compile .rc scripts into .res files. This is intended to be a
10 // platform-independent port of Microsoft's rc.exe tool.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Option/Arg.h"
15 #include "llvm/Option/ArgList.h"
16 #include "llvm/Support/Error.h"
17 #include "llvm/Support/ManagedStatic.h"
18 #include "llvm/Support/PrettyStackTrace.h"
19 #include "llvm/Support/Process.h"
20 #include "llvm/Support/Signals.h"
21 #include "llvm/Support/raw_ostream.h"
22
23 #include
24
25 using namespace llvm;
26
27 namespace {
28
29 // Input options tables.
30
31 enum ID {
32 OPT_INVALID = 0, // This is not a correct option ID.
33 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
34 HELPTEXT, METAVAR, VALUES) \
35 OPT_##ID,
36 #include "Opts.inc"
37 #undef OPTION
38 };
39
40 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
41 #include "Opts.inc"
42 #undef PREFIX
43
44 static const opt::OptTable::Info InfoTable[] = {
45 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
46 HELPTEXT, METAVAR, VALUES) \
47 { \
48 PREFIX, NAME, HELPTEXT, \
49 METAVAR, OPT_##ID, opt::Option::KIND##Class, \
50 PARAM, FLAGS, OPT_##GROUP, \
51 OPT_##ALIAS, ALIASARGS, VALUES},
52 #include "Opts.inc"
53 #undef OPTION
54 };
55
56 class RcOptTable : public opt::OptTable {
57 public:
58 RcOptTable() : OptTable(InfoTable, /* IgnoreCase = */ true) {}
59 };
60
61 static ExitOnError ExitOnErr;
62 } // anonymous namespace
63
64 int main(int argc_, const char *argv_[]) {
65 sys::PrintStackTraceOnErrorSignal(argv_[0]);
66 PrettyStackTraceProgram X(argc_, argv_);
67
68 ExitOnErr.setBanner("llvm-rc: ");
69
70 SmallVector argv;
71 SpecificBumpPtrAllocator ArgAllocator;
72 ExitOnErr(errorCodeToError(sys::Process::GetArgumentVector(
73 argv, makeArrayRef(argv_, argc_), ArgAllocator)));
74
75 llvm_shutdown_obj Y;
76
77 RcOptTable T;
78 unsigned MAI, MAC;
79 ArrayRef ArgsArr = makeArrayRef(argv_ + 1, argc_);
80 opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
81
82 // The tool prints nothing when invoked with no command-line arguments.
83 if (InputArgs.hasArg(OPT_HELP))
84 T.PrintHelp(outs(), "rc", "Resource Converter", false);
85
86 return 0;
87 }