[llvm] r331403 - [llvm-rc] Default to writing the output next to the input, if no output is specified

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Wed May 2 14:15:24 PDT 2018


Author: mstorsjo
Date: Wed May  2 14:15:24 2018
New Revision: 331403

URL: http://llvm.org/viewvc/llvm-project?rev=331403&view=rev
Log:
[llvm-rc] Default to writing the output next to the input, if no output is specified

This matches what rc.exe does if no output is specified.

Differential Revision: https://reviews.llvm.org/D46239

Modified:
    llvm/trunk/test/tools/llvm-rc/tag-menu.test
    llvm/trunk/test/tools/llvm-rc/tokenizer.test
    llvm/trunk/tools/llvm-rc/llvm-rc.cpp

Modified: llvm/trunk/test/tools/llvm-rc/tag-menu.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-rc/tag-menu.test?rev=331403&r1=331402&r2=331403&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-rc/tag-menu.test (original)
+++ llvm/trunk/test/tools/llvm-rc/tag-menu.test Wed May  2 14:15:24 2018
@@ -1,6 +1,11 @@
 ; RUN: llvm-rc /FO %t %p/Inputs/tag-menu.rc
 ; RUN: llvm-readobj %t | FileCheck %s --check-prefix=MENU
 
+; Test running llvm-rc without an explicit output file.
+; RUN: cp %p/Inputs/tag-menu.rc %t.implicit.rc
+; RUN: llvm-rc %t.implicit.rc
+; RUN: llvm-readobj %t.implicit.res | FileCheck --check-prefix=MENU %s
+
 ; MENU: Resource type (int): 4
 ; MENU-NEXT: Resource name (string): CHECKRECURSION
 ; MENU-NEXT: Data version: 0

Modified: llvm/trunk/test/tools/llvm-rc/tokenizer.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-rc/tokenizer.test?rev=331403&r1=331402&r2=331403&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-rc/tokenizer.test (original)
+++ llvm/trunk/test/tools/llvm-rc/tokenizer.test Wed May  2 14:15:24 2018
@@ -1,4 +1,4 @@
-; RUN: not llvm-rc /V %p/Inputs/tokens.rc | FileCheck %s
+; RUN: not llvm-rc /V /FO %t.res %p/Inputs/tokens.rc | FileCheck %s
 ; llvm-rc fails now on this sample because it is an invalid resource file
 ; script. We silence the error message and just analyze the output.
 

Modified: llvm/trunk/tools/llvm-rc/llvm-rc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/llvm-rc.cpp?rev=331403&r1=331402&r2=331403&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/llvm-rc.cpp (original)
+++ llvm/trunk/tools/llvm-rc/llvm-rc.cpp Wed May  2 14:15:24 2018
@@ -24,6 +24,7 @@
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
@@ -157,9 +158,15 @@ int main(int Argc, const char **Argv) {
 
   if (!IsDryRun) {
     auto OutArgsInfo = InputArgs.getAllArgValues(OPT_FILEOUT);
+    if (OutArgsInfo.empty()) {
+      SmallString<128> OutputFile = InputFile;
+      llvm::sys::path::replace_extension(OutputFile, "res");
+      OutArgsInfo.push_back(OutputFile.str());
+    }
+
     if (OutArgsInfo.size() != 1)
       fatalError(
-          "Exactly one output file should be provided (using /FO flag).");
+          "No more than one output file should be provided (using /FO flag).");
 
     std::error_code EC;
     auto FOut =




More information about the llvm-commits mailing list