[PATCH] D100754: [llvm-rc] [2/4] Fix handling of the /X option to match its documentation and rc.exe

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 19 23:25:26 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73cda4d18350: [llvm-rc] Fix handling of the /X option to match its documentation and rc.exe (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D100754?vs=338488&id=338723#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100754/new/

https://reviews.llvm.org/D100754

Files:
  llvm/test/tools/llvm-rc/include-paths.test
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.h
  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
@@ -142,7 +142,7 @@
   llvm::sys::fs::make_absolute(InputFile);
   Params.InputFilePath = InputFile;
   Params.Include = InputArgs.getAllArgValues(OPT_includepath);
-  Params.NoInclude = InputArgs.getAllArgValues(OPT_noinclude);
+  Params.NoInclude = InputArgs.hasArg(OPT_noinclude);
 
   if (InputArgs.hasArg(OPT_codepage)) {
     if (InputArgs.getLastArgValue(OPT_codepage)
Index: llvm/tools/llvm-rc/ResourceFileWriter.h
===================================================================
--- llvm/tools/llvm-rc/ResourceFileWriter.h
+++ llvm/tools/llvm-rc/ResourceFileWriter.h
@@ -35,7 +35,7 @@
 
 struct WriterParams {
   std::vector<std::string> Include;   // Additional folders to search for files.
-  std::vector<std::string> NoInclude; // Folders to exclude from file search.
+  bool NoInclude;                     // Ignore the INCLUDE variable.
   StringRef InputFilePath;            // The full path of the input file.
   int CodePage = CpAcp;               // The codepage for interpreting characters.
 };
Index: llvm/tools/llvm-rc/ResourceFileWriter.cpp
===================================================================
--- llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1553,10 +1553,11 @@
           Path, /*IsText=*/false, /*RequiresNullTerminator=*/false));
   }
 
-  if (auto Result =
-          llvm::sys::Process::FindInEnvPath("INCLUDE", File, Params.NoInclude))
-    return errorOrToExpected(MemoryBuffer::getFile(
-        *Result, /*IsText=*/false, /*RequiresNullTerminator=*/false));
+  if (!Params.NoInclude) {
+    if (auto Result = llvm::sys::Process::FindInEnvPath("INCLUDE", File))
+      return errorOrToExpected(MemoryBuffer::getFile(
+          *Result, /*IsText=*/false, /*RequiresNullTerminator=*/false));
+  }
 
   return make_error<StringError>("error : file not found : " + Twine(File),
                                  inconvertibleErrorCode());
Index: llvm/test/tools/llvm-rc/include-paths.test
===================================================================
--- llvm/test/tools/llvm-rc/include-paths.test
+++ llvm/test/tools/llvm-rc/include-paths.test
@@ -13,6 +13,16 @@
 ; RUN: llvm-rc /FO %t.nested-include.res /I %p/Inputs/nested -- %p/Inputs/deep-include.rc
 ; RUN: llvm-readobj %t.nested-include.res | FileCheck --check-prefix=FOUND %s
 
+; The include dir can be specified via the INCLUDE env var too.
+; RUN: rm -f %t.nested-include.res
+; RUN: env INCLUDE=%p/Inputs/nested llvm-rc /FO %t.nested-include.res -- %p/Inputs/deep-include.rc
+; RUN: llvm-readobj %t.nested-include.res | FileCheck --check-prefix=FOUND %s
+
+; Specifying the /X option should make it ignore the INCLUDE variable.
+; RUN: rm -f %t.nested-include.res
+; RUN: not env INCLUDE=%p/Inputs/nested llvm-rc /X /FO %t.nested-include.res -- %p/Inputs/deep-include.rc 2>&1 \
+; RUN:   | FileCheck --check-prefix=MISSING %s
+
 ; Otherwise, it should not find the bitmap.
 ; RUN: rm -f %t.nested-include.res
 ; RUN: not llvm-rc /FO %t.nested-include.res -- %p/Inputs/deep-include.rc 2>&1 \


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100754.338723.patch
Type: text/x-patch
Size: 3228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210420/d10a17f9/attachment.bin>


More information about the llvm-commits mailing list