[PATCH] D154545: [llvm-rc] Allow detection by Meson

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 14:40:14 PDT 2023


mstorsjo created this revision.
mstorsjo added reviewers: MaskRay, thakis, hans.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a subscriber: wangpc.
Herald added a project: LLVM.

When manually specifying a Windows Resource Compiler to Meson,
Meson tries to detect the kind of interface (MS rc.exe, GNU windres
or Wine wrc) by inspecting the output of "$CMD /?" or "$CMD --version"
and matching some specific strings - see [1]. Currently this fails.

By default Meson uses rc.exe, but if cross compiling with Clang and
LLD, it'd be beneficial to be able to use llvm-rc instead of requiring
running rc.exe in Wine.

Include the string "Microsoft Resource Compiler" in the output of
"llvm-rc /?" to let Meson detect it. This is similar to how we already
mention the corresponding GNU tools in similar printouts from lld,
llvm-nm, llvm-windres, llvm-objcopy and llvm-strip.

One could of course patch Meson to detect the llvm-rc specific
printouts too, but the previous form of the output from "llvm-rc /?"
was almost too bare to base any detection on; it would need to
look for a string like "OVERVIEW: Resource Converter".

While touching the help output, also improve the output by calling
it "LLVM Resource Converter" instead of plain "Resource Converter",
and print the name of the tool as "llvm-rc" instead of plain "rc".

[1] https://github.com/mesonbuild/meson/blob/1.1.1/mesonbuild/modules/windows.py#L97-L109


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154545

Files:
  llvm/test/tools/llvm-rc/helpmsg.test
  llvm/tools/llvm-rc/llvm-rc.cpp


Index: llvm/tools/llvm-rc/llvm-rc.cpp
===================================================================
--- llvm/tools/llvm-rc/llvm-rc.cpp
+++ llvm/tools/llvm-rc/llvm-rc.cpp
@@ -521,7 +521,10 @@
 
   // The tool prints nothing when invoked with no command-line arguments.
   if (InputArgs.hasArg(OPT_help)) {
-    T.printHelp(outs(), "rc [options] file...", "Resource Converter", false);
+    T.printHelp(
+        outs(), "llvm-rc [options] file...",
+        "LLVM Resource Converter (compatible with Microsoft Resource Compiler)",
+        false);
     exit(0);
   }
 
Index: llvm/test/tools/llvm-rc/helpmsg.test
===================================================================
--- llvm/test/tools/llvm-rc/helpmsg.test
+++ llvm/test/tools/llvm-rc/helpmsg.test
@@ -3,8 +3,8 @@
 ; RUN: diff %t1 %t2
 ; RUN: FileCheck -input-file=%t1 %s
 
-; CHECK:  OVERVIEW: Resource Converter
-; CHECK-DAG:  USAGE: rc [options] file...
+; CHECK:  OVERVIEW: LLVM Resource Converter (compatible with Microsoft Resource Compiler)
+; CHECK-DAG:  USAGE: llvm-rc [options] file...
 ; CHECK-DAG:  OPTIONS:
 ; CHECK-NEXT:    /?          Display this help and exit.
 ; CHECK-NEXT:    /C <value>  Set the codepage used for input strings.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154545.537507.patch
Type: text/x-patch
Size: 1219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230705/26b79871/attachment.bin>


More information about the llvm-commits mailing list