[llvm-rc] Add a GNU windres-like frontend to llvm-rc
authorMartin Storsjö <martin@martin.st>
Thu, 15 Apr 2021 11:38:27 +0000 (14:38 +0300)
committerMartin Storsjö <martin@martin.st>
Mon, 26 Apr 2021 19:04:29 +0000 (22:04 +0300)
commitf8de9aaef2f472ad7572748582444083d31d5a95
treedd15482cd7ba18ab0df8b35c134751bbf024ed86
parentf0c22c3d584c5f335b2457b6f9c2723ebdcfa06e
[llvm-rc] Add a GNU windres-like frontend to llvm-rc

This primarily parses a different set of options and invokes the same
resource compiler as llvm-rc normally. Additionally, it can convert
directly to an object file (which in MSVC style setups is done with the
separate cvtres tool, or by the linker).

(GNU windres also supports other conversions; from coff object file back
to .res, and from .res or object file back to .rc form; that's not yet
implemented.)

The other bigger complication lies in being able to imply or pass the
intended target triple, to let clang find the corresponding mingw sysroot
for finding include files, and for specifying the default output object
machine format.

It can be implied from the tool triple prefix, like
`<triple>-[llvm-]windres` or picked up from the windres option e.g.
`-F pe-x86-64`. In GNU windres, that option takes BFD style format names
such as pe-i386 or pe-x86-64. As libbfd in binutils doesn't support
Windows on ARM, there's no such canonical name for the ARM targets.
Therefore, as an LLVM specific extension, this option is extended to
allow passing full triples, too.

Differential Revision: https://reviews.llvm.org/D100756
15 files changed:
clang/test/CMakeLists.txt
clang/test/Preprocessor/Inputs/llvm-windres.h [new file with mode: 0644]
clang/test/Preprocessor/llvm-windres.rc [new file with mode: 0644]
llvm/test/CMakeLists.txt
llvm/test/lit.cfg.py
llvm/test/tools/llvm-rc/codepage.test
llvm/test/tools/llvm-rc/language.test
llvm/test/tools/llvm-rc/windres-format.test [new file with mode: 0644]
llvm/test/tools/llvm-rc/windres-prefix.test [new file with mode: 0644]
llvm/test/tools/llvm-rc/windres-preproc.test [new file with mode: 0644]
llvm/test/tools/llvm-rc/windres-target.test [new file with mode: 0644]
llvm/test/tools/llvm-rc/windres-version.test [new file with mode: 0644]
llvm/tools/llvm-rc/CMakeLists.txt
llvm/tools/llvm-rc/WindresOpts.td [new file with mode: 0644]
llvm/tools/llvm-rc/llvm-rc.cpp