diff options
author | Martin Storsjo <martin@martin.st> | 2018-05-02 19:43:44 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2018-05-02 19:43:44 +0000 |
commit | d1d046aa32395d8e9c459e877a03e716d47aca2c (patch) | |
tree | c2e7f98b2c476189bb52c52992ac4475a908c52d /llvm/tools/llvm-rc/llvm-rc.cpp | |
parent | 4d64306a92a93a8e4f20c0c83e164c223b26b848 (diff) | |
download | bcm5719-llvm-d1d046aa32395d8e9c459e877a03e716d47aca2c.tar.gz bcm5719-llvm-d1d046aa32395d8e9c459e877a03e716d47aca2c.zip |
[llvm-rc] Add rudimentary support for codepages
Only support UTF-8 (since LLVM contains UTF-8 parsing support
already, and the code even does that already) and Windows-1252
(where most code points has the same value in unicode). Keep the
existing default as only allowing ASCII input.
Using the option type JoinedOrSeparate, since the real rc.exe
handles options in this form, even if llvm-rc uses Separate for
other similar existing options.
Rename the struct SearchParams to WriterParams since it's now used
for more than just include paths.
Add a missing getResourceTypeName method to the BundleResource class,
to fix error printing from within STRINGTABLE resources (used in
tests).
Differential Revision: https://reviews.llvm.org/D46238
llvm-svn: 331391
Diffstat (limited to 'llvm/tools/llvm-rc/llvm-rc.cpp')
-rw-r--r-- | llvm/tools/llvm-rc/llvm-rc.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp index 6491473de32..1f0f16f1685 100644 --- a/llvm/tools/llvm-rc/llvm-rc.cpp +++ b/llvm/tools/llvm-rc/llvm-rc.cpp @@ -129,13 +129,29 @@ int main(int Argc, const char **Argv) { } } - SearchParams Params; + WriterParams Params; SmallString<128> InputFile(InArgsInfo[0]); llvm::sys::fs::make_absolute(InputFile); Params.InputFilePath = InputFile; Params.Include = InputArgs.getAllArgValues(OPT_INCLUDE); Params.NoInclude = InputArgs.getAllArgValues(OPT_NOINCLUDE); + if (InputArgs.hasArg(OPT_CODEPAGE)) { + if (InputArgs.getLastArgValue(OPT_CODEPAGE) + .getAsInteger(10, Params.CodePage)) + fatalError("Invalid code page: " + + InputArgs.getLastArgValue(OPT_CODEPAGE)); + switch (Params.CodePage) { + case CpAcp: + case CpWin1252: + case CpUtf8: + break; + default: + fatalError( + "Unsupported code page, only 0, 1252 and 65001 are supported!"); + } + } + std::unique_ptr<ResourceFileWriter> Visitor; bool IsDryRun = InputArgs.hasArg(OPT_DRY_RUN); |