[pkg-d-commits] [ldc] 93/211: Introduce (hidden) command-line option `-cleanup-obj`

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.1.0
in repository ldc.

commit 141310c77cb433ca358bcc65e7117166b975061f
Author: Martin <noone at nowhere.com>
Date:   Sat Oct 15 00:30:39 2016 +0200

    Introduce (hidden) command-line option `-cleanup-obj`
    
    Removing all generated object files on success.
---
 ddmd/globals.d        |  1 +
 ddmd/globals.h        |  1 +
 ddmd/mars.d           | 14 ++++++++++++++
 driver/cl_options.cpp |  6 ++++++
 4 files changed, 22 insertions(+)

diff --git a/ddmd/globals.d b/ddmd/globals.d
index 6592c21..cd7da5b 100644
--- a/ddmd/globals.d
+++ b/ddmd/globals.d
@@ -207,6 +207,7 @@ struct Param
         bool verbose_cg;
         bool hasObjectiveC;
         bool fullyQualifiedObjectFiles;
+        bool cleanupObjectFiles;
 
         // Profile-guided optimization:
         bool genInstrProf;             // Whether to generate PGO instrumented code
diff --git a/ddmd/globals.h b/ddmd/globals.h
index 7352a3c..6796970 100644
--- a/ddmd/globals.h
+++ b/ddmd/globals.h
@@ -206,6 +206,7 @@ struct Param
     bool verbose_cg;
     bool hasObjectiveC;
     bool fullyQualifiedObjectFiles;
+    bool cleanupObjectFiles;
 
     // Profile-guided optimization:
     bool genInstrProf;             // Whether to generate PGO instrumented code
diff --git a/ddmd/mars.d b/ddmd/mars.d
index 359ebd4..95c9227 100644
--- a/ddmd/mars.d
+++ b/ddmd/mars.d
@@ -1754,6 +1754,17 @@ extern (C++) int mars_mainBody(ref Strings files, ref Strings libmodules)
             status = linkObjToBinary();
         else if (global.params.lib)
             status = createStaticLibrary();
+
+        if (status == EXIT_SUCCESS &&
+            (global.params.cleanupObjectFiles || global.params.run))
+        {
+            for (size_t i = 0; i < modules.dim; i++)
+            {
+                modules[i].deleteObjFile();
+                if (global.params.oneobj)
+                    break;
+            }
+        }
       }
       else
       {
@@ -1767,12 +1778,15 @@ extern (C++) int mars_mainBody(ref Strings files, ref Strings libmodules)
                 status = runProgram();
                 /* Delete .obj files and .exe file
                  */
+              version (IN_LLVM) {} else
+              {
                 for (size_t i = 0; i < modules.dim; i++)
                 {
                     modules[i].deleteObjFile();
                     if (global.params.oneobj)
                         break;
                 }
+              }
                 deleteExeFile();
             }
         }
diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp
index 50cb759..b730383 100644
--- a/driver/cl_options.cpp
+++ b/driver/cl_options.cpp
@@ -151,6 +151,12 @@ cl::opt<bool> output_s("output-s", cl::desc("Write native assembly"));
 cl::opt<cl::boolOrDefault> output_o("output-o",
                                     cl::desc("Write native object"));
 
+static cl::opt<bool, true>
+    cleanupObjectFiles("cleanup-obj",
+                       cl::desc("Remove generated object files on success"),
+                       cl::ZeroOrMore, cl::ReallyHidden,
+                       cl::location(global.params.cleanupObjectFiles));
+
 // Disabling Red Zone
 cl::opt<bool, true>
     disableRedZone("disable-red-zone",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list