Mercurial > octave
changeset 22472:76f2b0436423
Add -n option to print, not execute, mkoctfile commands.
* mkoctfile.in.cc: Add '-n, --just-print' option to help_msg.
* mkoctfile.in.cc(run_command): Alter function prototype to
have second argument "bool printonly = false". If arg is true,
print command to standard out and return immediately rather
than executing cmd input in a shell.
* mkoctfile.in.cc(main): New var 'bool printonly'. Detect
input arg '-n' or '--just-print' and set printonly to true.
Change all instances of run_command to include second argument
with printonly var.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 12 Sep 2016 16:05:04 -0700 |
parents | 667d353d1ab8 |
children | bb10d836751b |
files | src/mkoctfile.in.cc |
diffstat | 1 files changed, 20 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mkoctfile.in.cc Mon Sep 12 13:39:32 2016 -0700 +++ b/src/mkoctfile.in.cc Mon Sep 12 16:05:04 2016 -0700 @@ -312,6 +312,8 @@ "\n" " -s, --strip Strip output file.\n" "\n" +" -n, --just-print Print commands, but do not execute them.\n" +"\n" " -v, --verbose Echo commands as they are executed.\n" "\n" " FILE Compile or link FILE. Recognized file types are:\n" @@ -372,8 +374,14 @@ } static int -run_command (const std::string& cmd) +run_command (const std::string& cmd, bool printonly = false) { + if (printonly) + { + std::cout << cmd << std::endl; + return 0; + } + if (debug) std::cout << cmd << std::endl; @@ -414,6 +422,7 @@ bool link_stand_alone = false; std::string output_ext = ".oct"; bool depend = false; + bool printonly = false; if (argc == 1) { @@ -527,6 +536,10 @@ else std::cerr << "mkoctfile: output filename missing" << std::endl; } + else if (arg == "-n" || arg == "--just-print") + { + printonly = true; + } else if (arg == "-p" || arg == "-print" || arg == "--print") { if (i < argc-1) @@ -708,7 +721,7 @@ + vars["ALL_FFLAGS"] + " " + incflags + " " + defs + " " + pass_on_options + " " + f + " -o " + o; - result = run_command (cmd); + result = run_command (cmd, printonly); } else { @@ -740,7 +753,7 @@ + pass_on_options + " " + incflags + " " + defs + " " + quote_path (f) + " -o " + quote_path (o); - result = run_command (cmd); + result = run_command (cmd, printonly); } else { @@ -773,7 +786,7 @@ + pass_on_options + " " + incflags + " " + defs + " " + quote_path (f) + " -o " + quote_path (o); - result = run_command (cmd); + result = run_command (cmd, printonly); } else { @@ -800,7 +813,7 @@ + " -loctinterp -loctave " + " " + vars["OCTAVE_LINK_OPTS"] + " " + vars["OCTAVE_LINK_DEPS"]; - result = run_command (cmd); + result = run_command (cmd, printonly); } else { @@ -822,13 +835,13 @@ + vars["LFLAGS"] + " -loctinterp -loctave " + vars["OCT_LINK_OPTS"] + " " + vars["OCT_LINK_DEPS"]; - result = run_command (cmd); + result = run_command (cmd, printonly); } if (strip) { std::string cmd = "strip " + octfile; - result = run_command (cmd); + result = run_command (cmd, printonly); } }