[lld] r193195 - [PECOFF] Add /manifestfile command line option.

Rui Ueyama ruiu at google.com
Tue Oct 22 13:53:08 PDT 2013


Author: ruiu
Date: Tue Oct 22 15:53:07 2013
New Revision: 193195

URL: http://llvm.org/viewvc/llvm-project?rev=193195&view=rev
Log:
[PECOFF] Add /manifestfile command line option.

/manifestfile:<path> specifies an alternative manifest file output path.
Default is "<output-path>.manifest" where <output-path> is the executable's
path.

Modified:
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/Driver/WinLinkOptions.td
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=193195&r1=193194&r2=193195&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Tue Oct 22 15:53:07 2013
@@ -152,6 +152,11 @@ public:
   void setCreateManifest(bool val) { _createManifest = val; }
   bool getCreateManifest() const { return _createManifest; }
 
+  void setManifestOutputPath(std::string val) { _manifestOutputPath = val; }
+  const std::string &getManifestOutputPath() const {
+    return _manifestOutputPath;
+  }
+
   void setEmbedManifest(bool val) { _embedManifest = val; }
   bool getEmbedManifest() const { return _embedManifest; }
 
@@ -223,6 +228,7 @@ private:
   bool _terminalServerAware;
   bool _dynamicBaseEnabled;
   bool _createManifest;
+  std::string _manifestOutputPath;
   bool _embedManifest;
   int _manifestId;
   std::string _manifestLevel;

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=193195&r1=193194&r2=193195&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Oct 22 15:53:07 2013
@@ -496,6 +496,10 @@ WinLinkDriver::parse(int argc, const cha
       break;
     }
 
+    case OPT_manifestfile:
+      ctx.setManifestOutputPath(ctx.allocateString(inputArg->getValue()));
+      break;
+
     case OPT_failifmismatch:
       if (handleFailIfMismatchOption(inputArg->getValue(), failIfMismatchMap,
                                      diagnostics))
@@ -639,6 +643,14 @@ WinLinkDriver::parse(int argc, const cha
     ctx.setOutputPath(replaceExtension(ctx, path, ".exe"));
   }
 
+  // Default name of the manifest file is "foo.exe.manifest" where "foo.exe" is
+  // the output path.
+  if (ctx.getManifestOutputPath().empty()) {
+    std::string path = ctx.outputPath();
+    path.append(".manifest");
+    ctx.setManifestOutputPath(ctx.allocateString(path));
+  }
+
   // If the core linker already started, we need to explicitly call parse() for
   // each input element, because the pass to parse input files in Driver::link
   // has already done.

Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=193195&r1=193194&r2=193195&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Tue Oct 22 15:53:07 2013
@@ -34,6 +34,7 @@ def subsystem : P<"subsystem", "Specify
 def manifest : F<"manifest">;
 def manifest_colon : P<"manifest", "Create manifest file">;
 def manifestuac : P<"manifestuac", "User access control">;
+def manifestfile : P<"manifestfile", "Manifest file path">;
 
 // We cannot use multiclass P because class name "incl" is different
 // from its command line option name. We do this because "include" is

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=193195&r1=193194&r2=193195&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Tue Oct 22 15:53:07 2013
@@ -61,6 +61,7 @@ TEST_F(WinLinkParserTest, Basic) {
   EXPECT_TRUE(_context.isTerminalServerAware());
   EXPECT_TRUE(_context.getDynamicBaseEnabled());
   EXPECT_TRUE(_context.getCreateManifest());
+  EXPECT_EQ("a.exe.manifest", _context.getManifestOutputPath());
   EXPECT_FALSE(_context.getEmbedManifest());
   EXPECT_EQ(1, _context.getManifestId());
   EXPECT_EQ("'asInvoker'", _context.getManifestLevel());
@@ -372,7 +373,7 @@ TEST_F(WinLinkParserTest, FailIfMismatch
 }
 
 //
-// Tests for /manifest and /manifestuac.
+// Tests for /manifest, /manifestuac, and /manifestfile.
 //
 TEST_F(WinLinkParserTest, Manifest_Default) {
   EXPECT_TRUE(parse("link.exe", "/manifest", "a.out", nullptr));
@@ -427,6 +428,12 @@ TEST_F(WinLinkParserTest, Manifestuac_Le
   EXPECT_EQ("'true'", _context.getManifestUiAccess());
 }
 
+TEST_F(WinLinkParserTest, Manifestfile) {
+  EXPECT_TRUE(parse("link.exe", "/manifestfile:bar.manifest",
+                    "a.out", nullptr));
+  EXPECT_EQ("bar.manifest", _context.getManifestOutputPath());
+}
+
 //
 // Test for command line flags that are ignored.
 //





More information about the llvm-commits mailing list