llvm.org GIT mirror llvm / b8fb226
Create empty shell of llvm-mt. Summary: This is the first patch towards creating the llvm-mt tool for merging Windows manifests. This is a reimplementation of mt.exe. Reviewers: zturner, ruiu, rnk Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D35333 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308224 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Beckmann 2 years ago
6 changed file(s) with 189 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5757 llvm-mc
5858 llvm-mcmarkup
5959 llvm-modextract
60 llvm-mt
6061 llvm-nm
6162 llvm-objdump
6263 llvm-opt-report
0 RUN: llvm-mt /? | FileCheck %s -check-prefix=HELP
1
2 RUN: llvm-mt /inputresource:foo.res /manifest foo.manifest | FileCheck %s -check-prefix=NOT_SUPPORTED
3
4 HELP: OVERVIEW: Manifest Tool
5
6 NOT_SUPPORTED: llvm-mt: ignoring unsupported 'inputresource:' option
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(MtTableGen)
9
10 add_llvm_tool(llvm-mt
11 llvm-mt.cpp
12 )
0 ;===- ./tools/llvm-mt/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-mt
20 parent = Tools
21 required_libraries = Option Support
0 include "llvm/Option/OptParser.td"
1
2 def unsupported : OptionGroup<"unsupported">;
3 def manifest : Separate<["/", "-"], "manifest">, HelpText<"Used to specify each manifest that need to be processed">, MetaVarName<"manifest">;
4 def identity : Joined<["/", "-"], "identity:">, HelpText<"Not supported">, MetaVarName<"identity">, Group;
5 def rgs : Joined<["/", "-"], "rgs:">, HelpText<"Not supported">, MetaVarName<"script">, Group;
6 def tlb : Joined<["/", "-"], "tlb:">, HelpText<"Not supported">, MetaVarName<"file">, Group;
7 def dll : Joined<["/", "-"], "dll:">, HelpText<"Not supported">, MetaVarName<"dll">, Group;
8 def replacements : Joined<["/", "-"], "replacements:">, HelpText<"Not supported">, MetaVarName<"file">, Group;
9 def managed_assembly_name : Joined<["/", "-"], "managedassemblyname:">, HelpText<"Not supported">, MetaVarName<"assembly">, Group;
10 def no_dependency : Flag<["/", "-"], "nodependency">, HelpText<"Not supported">, Group;
11 def category : Flag<["/", "-"], "category">, HelpText<"Not supported">, Group;
12 def no_logo : Flag<["/", "-"], "nologo">, HelpText<"No effect as this tool never writes copyright data. Included for parity">;
13 def out : Joined<["/", "-"], "out:">, HelpText<"Name of the output manifest. If this is skipped and only one manifest is being operated upon by the tool, that manifest is modified in place">, MetaVarName<"manifest">;
14 def input_resource : Joined<["/", "-"], "inputresource:">, HelpText<"Not supported">, MetaVarName<"file">, Group;
15 def output_resource : Joined<["/", "-"], "outputresource:">, HelpText<"Not supported">, MetaVarName<"file">, Group;
16 def output_resource_flag : Flag<["/", "-"], "outputresource">, Alias, HelpText<"Not supported">, Group;
17 def update_resource : Joined<["/", "-"], "updateresource:">, HelpText<"Not supported">, MetaVarName<"file">, Group;
18 def hash_update : Joined<["/", "-"], "hashupdate:">, HelpText<"Not supported">, MetaVarName<"file">, Group;
19 def hash_update_flag : Flag<["/", "-"], "hashupdate">, Alias, HelpText<"Not supported">, Group;
20 def validate_manifest : Flag<["/", "-"], "validate_manifest">, HelpText<"Not supported">, Group;
21 def validate_file_hashes : Joined<["/", "-"], "validate_file_hashes:">, HelpText<"Not supported">, MetaVarName<"">, Group;
22 def canonicalize : Flag<["/", "-"], "canonicalize:">, HelpText<"Not supported">, Group;
23 def check_for_duplicates : Flag<["/", "-"], "check_for_duplicates:">, HelpText<"Not supported">, Group;
24 def make_cdfs : Flag<["/", "-"], "makecdfs:">, HelpText<"Not supported">, Group;
25 def verbose : Flag<["/", "-"], "verbose">, HelpText<"Not supported">, Group;
26 def help : Flag<["/", "-"], "?">;
27 def help_long : Flag<["/", "-"], "help">, Alias;
28 def h : Flag<["/", "-"], "h">, Alias;
0 //===- llvm-mt.cpp - Merge .manifest files ---------------------*- 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 // Merge .manifest files. This is intended to be a platform-independent port
10 // of Microsoft's mt.exe.
11 //
12 //===---------------------------------------------------------------------===//
13
14 #include "llvm/Option/Arg.h"
15 #include "llvm/Option/ArgList.h"
16 #include "llvm/Option/Option.h"
17 #include "llvm/Support/Error.h"
18 #include "llvm/Support/ManagedStatic.h"
19 #include "llvm/Support/Path.h"
20 #include "llvm/Support/PrettyStackTrace.h"
21 #include "llvm/Support/Process.h"
22 #include "llvm/Support/Signals.h"
23 #include "llvm/Support/raw_ostream.h"
24
25 #include
26
27 using namespace llvm;
28
29 namespace {
30
31 enum ID {
32 OPT_INVALID = 0, // This is not an 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 CvtResOptTable : public opt::OptTable {
57 public:
58 CvtResOptTable() : OptTable(InfoTable, true) {}
59 };
60
61 static ExitOnError ExitOnErr;
62 } // namespace
63
64 LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
65 errs() << "llvm-mt error: " << Msg << "\n";
66 exit(1);
67 }
68
69 int main(int argc, const char **argv) {
70 sys::PrintStackTraceOnErrorSignal(argv[0]);
71 PrettyStackTraceProgram X(argc, argv);
72
73 ExitOnErr.setBanner("llvm-mt: ");
74
75 SmallVector argv_buf;
76 SpecificBumpPtrAllocator ArgAllocator;
77 ExitOnErr(errorCodeToError(sys::Process::GetArgumentVector(
78 argv_buf, makeArrayRef(argv, argc), ArgAllocator)));
79
80 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
81
82 CvtResOptTable T;
83 unsigned MAI, MAC;
84 ArrayRef ArgsArr = makeArrayRef(argv + 1, argc);
85 opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
86
87 for (auto &Arg : InputArgs) {
88 if (Arg->getOption().matches(OPT_unsupported)) {
89 outs() << "llvm-mt: ignoring unsupported '" << Arg->getOption().getName()
90 << "' option\n";
91 }
92 }
93
94 if (InputArgs.hasArg(OPT_help)) {
95 T.PrintHelp(outs(), "mt", "Manifest Tool", false);
96 return 0;
97 }
98
99 std::vector InputFiles = InputArgs.getAllArgValues(OPT_manifest);
100
101 if (InputFiles.size() == 0) {
102 reportError("no input file specified");
103 }
104
105 StringRef OutputFile;
106
107 if (InputArgs.hasArg(OPT_out)) {
108 OutputFile = InputArgs.getLastArgValue(OPT_out);
109 } else if (InputFiles.size() == 1) {
110 OutputFile = InputFiles[0];
111 } else {
112 reportError("no output file specified");
113 }
114
115 return 0;
116 }