From 1401d2c78ac4b454d7a5caf64a0ffe7642cdb6e4 Mon Sep 17 00:00:00 2001 From: Andreas Bergmeier Date: Thu, 25 Apr 2013 17:53:00 +0200 Subject: Change `Building.make` and `Building.configure` to raise a `CalledProcessError` when the underlying command's `returncode` is not 0. Handle all calls inside of `shared.py` to ignore the error, so behavior does not change. Handle error in `emmake` and `emconfigure`, so these exit with the `returncode` of the underlying command. --- tools/shared.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/shared.py b/tools/shared.py index 33b0273e..d2bcaf48 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -657,11 +657,14 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e if 'cmake' in args[0]: args = Building.handle_CMake_toolchain(args, env) try: - Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() + process = Popen(args, stdout=stdout, stderr=stderr, env=env) + process.communicate() except Exception, e: print >> sys.stderr, 'Error: Exception thrown when invoking Popen in configure with args: "%s"!' % ' '.join(args) raise del env['EMMAKEN_JUST_CONFIGURE'] + if process.returncode is not 0: + raise subprocess.CalledProcessError( cmd=args, returncode=process.returncode ) @staticmethod def make(args, stdout=None, stderr=None, env=None): @@ -672,10 +675,14 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e sys.exit(1) #args += ['VERBOSE=1'] try: - Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() + process = Popen(args, stdout=stdout, stderr=stderr, env=env) + process.communicate() except Exception, e: print >> sys.stderr, 'Error: Exception thrown when invoking Popen in make with args: "%s"!' % ' '.join(args) raise + if process.returncode is not 0: + raise subprocess.CalledProcessError( cmd=args, returncode=process.returncode ) + @staticmethod def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None, native=False): @@ -710,8 +717,11 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e for k, v in env_init.iteritems(): env[k] = v if configure: # Useful in debugging sometimes to comment this out (and the lines below up to and including the |link| call) - Building.configure(configure + configure_args, stdout=open(os.path.join(project_dir, 'configure_'), 'w'), - stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env) + try: + Building.configure(configure + configure_args, stdout=open(os.path.join(project_dir, 'configure_'), 'w'), + stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env) + except CalledProcessError, e: + pass # Ignore exit code != 0 def open_make_out(i, mode='r'): return open(os.path.join(project_dir, 'make_' + str(i)), mode) @@ -721,8 +731,11 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e for i in range(2): # FIXME: Sad workaround for some build systems that need to be run twice to succeed (e.g. poppler) with open_make_out(i, 'w') as make_out: with open_make_err(i, 'w') as make_err: - Building.make(make + make_args, stdout=make_out, - stderr=make_err, env=env) + try: + Building.make(make + make_args, stdout=make_out, + stderr=make_err, env=env) + except CalledProcessError, e: + pass # Ignore exit code != 0 try: if cache is not None: cache[cache_name] = [] -- cgit v1.2.3-18-g5258 From 897eda9ceeb7d3369fef19b3da55d009e6fa2d28 Mon Sep 17 00:00:00 2001 From: Andreas Bergmeier Date: Thu, 25 Apr 2013 17:54:22 +0200 Subject: Change to fit in with Alon's coding style. --- tools/shared.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/shared.py b/tools/shared.py index d2bcaf48..f1cca907 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -664,7 +664,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e raise del env['EMMAKEN_JUST_CONFIGURE'] if process.returncode is not 0: - raise subprocess.CalledProcessError( cmd=args, returncode=process.returncode ) + raise subprocess.CalledProcessError(cmd=args, returncode=process.returncode) @staticmethod def make(args, stdout=None, stderr=None, env=None): @@ -681,7 +681,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e print >> sys.stderr, 'Error: Exception thrown when invoking Popen in make with args: "%s"!' % ' '.join(args) raise if process.returncode is not 0: - raise subprocess.CalledProcessError( cmd=args, returncode=process.returncode ) + raise subprocess.CalledProcessError(cmd=args, returncode=process.returncode) @staticmethod -- cgit v1.2.3-18-g5258 From 209871d41d9070e6a3bc5748fadd6bd5942911ec Mon Sep 17 00:00:00 2001 From: Andreas Bergmeier Date: Sat, 27 Apr 2013 12:25:37 +0200 Subject: Explicitly refer to CalledProcessError with its package name. --- tools/shared.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/shared.py b/tools/shared.py index f1cca907..bc1d4352 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -720,7 +720,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e try: Building.configure(configure + configure_args, stdout=open(os.path.join(project_dir, 'configure_'), 'w'), stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env) - except CalledProcessError, e: + except subprocess.CalledProcessError, e: pass # Ignore exit code != 0 def open_make_out(i, mode='r'): return open(os.path.join(project_dir, 'make_' + str(i)), mode) @@ -734,7 +734,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e try: Building.make(make + make_args, stdout=make_out, stderr=make_err, env=env) - except CalledProcessError, e: + except subprocess.CalledProcessError, e: pass # Ignore exit code != 0 try: if cache is not None: -- cgit v1.2.3-18-g5258