From 7e49ad81de439400655c022322486d738aeaeb09 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 10 Dec 2017 17:15:13 +1300 Subject: [PATCH] build_analyzer.py bails after first build error --- build_analyzer.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/build_analyzer.py b/build_analyzer.py index 4ddd7ee..594d9af 100644 --- a/build_analyzer.py +++ b/build_analyzer.py @@ -1,7 +1,8 @@ +# Python 3 script to build the analyzer + import os, glob, platform #find out if we're running on mac or linux and set the dynamic library extension -dylib_ext = "" if platform.system().lower() == "darwin": dylib_ext = ".dylib" else: @@ -45,6 +46,12 @@ link_dependencies = [ "-lAnalyzer" ] #refers to libAnalyzer.dylib or libAnalyzer debug_compile_flags = "-O0 -w -c -fpic -g" release_compile_flags = "-O3 -w -c -fpic" +def run_command(cmd): + "Display cmd, then run it in a subshell, raise if there's an error" + print(cmd) + if os.system(cmd): + raise Exception("Shell execution returned nonzero status") + #loop through all the cpp files, build up the gcc command line, and attempt to compile each cpp file for cpp_file in cpp_files: @@ -66,10 +73,8 @@ for cpp_file in cpp_files: debug_command += "\"" + "source/" + cpp_file + "\"" #the cpp file to compile #run the commands from the command line - print(release_command) - os.system( release_command ) - print(debug_command) - os.system( debug_command ) + run_command(release_command) + run_command(debug_command) #lastly, link #g++ @@ -111,9 +116,5 @@ for cpp_file in cpp_files: debug_command += "debug/" + cpp_file.replace( ".cpp", ".o" ) + " " #run the commands from the command line -print(release_command) -os.system( release_command ) -print(debug_command) -os.system( debug_command ) - - +run_command(release_command) +run_command(debug_command)