changeset 28963:f29e4791a792

mkoctfile: eliminate global debug variable * mkoctfile.in.cc: Delete global variable, DEBUG. (run_command): New argument, VERBOSE. (main): New local variable, VERBOSE. Change use of DEBUG to VERBOSE. Pass VERBOSE to run_command.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Oct 2020 01:02:28 -0400
parents 90c39bbbe5cd
children 091aeae73b60
files src/mkoctfile.in.cc
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/mkoctfile.in.cc	Mon Oct 19 20:16:21 2020 -0700
+++ b/src/mkoctfile.in.cc	Tue Oct 20 01:02:28 2020 -0400
@@ -376,8 +376,6 @@
 
 static std::string version_msg = "mkoctfile, version " OCTAVE_VERSION;
 
-static bool debug = false;
-
 static std::string help_msg =
   "\n"
   "Options:\n"
@@ -565,7 +563,7 @@
 }
 
 static int
-run_command (const std::string& cmd, bool printonly = false)
+run_command (const std::string& cmd, bool verbose, bool printonly = false)
 {
   if (printonly)
     {
@@ -573,7 +571,7 @@
       return 0;
     }
 
-  if (debug)
+  if (verbose)
     std::cout << cmd << std::endl;
 
   int result = system (cmd.c_str ());
@@ -706,6 +704,7 @@
   std::string output_ext = ".oct";
   std::string objfiles, libfiles, octfile, outputfile;
   std::string incflags, defs, ldflags, pass_on_options;
+  bool verbose = false;
   bool strip = false;
   bool no_oct_file_strip_on_this_platform = is_true ("%NO_OCT_FILE_STRIP%");
   bool compile_only = false;
@@ -757,7 +756,8 @@
       else if (arg == "-d" || arg == "-debug" || arg == "--debug"
                || arg == "-v" || arg == "-verbose" ||  arg == "--verbose")
         {
-          debug = true;
+          verbose = true;
+
           if (vars["CC"] == "cc-msvc")
             vars["CC"] += " -d";
           if (vars["CXX"] == "cc-msvc")
@@ -1146,7 +1146,7 @@
                + vars["ALL_FFLAGS"] + ' ' + incflags + ' ' + defs + ' '
                + pass_on_options + ' ' + f + " -o " + o);
 
-          int status = run_command (cmd, printonly);
+          int status = run_command (cmd, verbose, printonly);
 
           if (status)
             return status;
@@ -1186,7 +1186,7 @@
                + pass_on_options + ' ' + incflags + ' ' + defs + ' '
                + quote_path (f) + " -o " + quote_path (o));
 
-          int status = run_command (cmd, printonly);
+          int status = run_command (cmd, verbose, printonly);
 
           if (status)
             return status;
@@ -1226,7 +1226,7 @@
                + pass_on_options + ' ' + incflags + ' ' + defs + ' '
                + quote_path (f) + " -o " + quote_path (o));
 
-          int status = run_command (cmd, printonly);
+          int status = run_command (cmd, verbose, printonly);
 
           if (status)
             return status;
@@ -1267,7 +1267,7 @@
                + vars["LFLAGS"] + ' ' + octave_libs + ' '
                + vars["OCTAVE_LINK_OPTS"] + ' ' + vars["OCTAVE_LINK_DEPS"]);
 
-          int status = run_command (cmd, printonly);
+          int status = run_command (cmd, verbose, printonly);
 
           clean_up_tmp_files (tmp_objfiles);
 
@@ -1301,7 +1301,7 @@
         cmd += ' ' + vars["FLIBS"];
 #endif
 
-      int status = run_command (cmd, printonly);
+      int status = run_command (cmd, verbose, printonly);
 
       clean_up_tmp_files (tmp_objfiles);
 
@@ -1313,7 +1313,7 @@
     {
       std::string cmd = "strip " + octfile;
 
-      int status = run_command (cmd, printonly);
+      int status = run_command (cmd, verbose, printonly);
 
       if (status)
         return status;