--- a/bake/Bake.py Sat Aug 31 01:06:53 2013 +0900
+++ b/bake/Bake.py Fri Sep 06 08:42:25 2013 +0200
@@ -50,7 +50,7 @@
def signal_handler(signal, frame):
""" Handles Ctrl+C keyboard interruptions """
- print (' > Bake was aborted! (Ctrl+C)')
+ print (os.linesep + ' > Bake was aborted! (Ctrl+C)')
os._exit(0)
class MyOptionParser(OptionParser):
@@ -70,8 +70,7 @@
def _error(self, string):
""" Handles hard exceptions, the kind of exceptions Bake should not
- recover from.
- """
+ recover from."""
import sys
print(' > Error: %s ' % string)
@@ -598,6 +597,9 @@
parser.add_option("-a", "--all", action="store_true",
dest="all", default=False,
help="Process all modules")
+ parser.add_option("--stop_on_error", action="store_true",
+ dest="stopOnError", default=False,
+ help="Stop on the first error found and do not advance while the error is not corrected.")
parser.add_option("-s", "--start", action="store", type="string",
dest="start", default="",
help="Process all modules enabled starting from the module specified.")
@@ -745,6 +747,7 @@
print
env._sudoEnabled=options.call_with_sudo
+ ModuleEnvironment._stopOnError=options.stopOnError
valueToReturn=module.check_source_version(env)
@@ -860,6 +863,8 @@
print
env._sudoEnabled=options.call_with_sudo
+ ModuleEnvironment._stopOnError=options.stopOnError
+
if module.check_build_version(env):
retval = module.build(env, options.jobs, options.force_clean)
if retval:
--- a/bake/Dependencies.py Sat Aug 31 01:06:53 2013 +0900
+++ b/bake/Dependencies.py Fri Sep 06 08:42:25 2013 +0200
@@ -332,13 +332,20 @@
except TaskError as e:
success = False
print (" > Error: " + e._reason)
+# except SystemExit as e:
+# print(sys.exc_info())
+#
+# success = False
+# print (" > Error: " + e._reason)
except:
success = False
import sys
er = sys.exc_info()[1]
-# import bake.Utils
-# bake.Utils.print_backtrace()
print (" > Error: " + str(er))
+ from bake.ModuleEnvironment import ModuleEnvironment
+ if ModuleEnvironment._stopOnError:
+ er = sys.exc_info()[1]
+ sys.exit(1)
elif callback is not None:
try:
@@ -346,11 +353,19 @@
except TaskError as e:
success = False
print (" > Error: " + e._reason)
+ from bake.ModuleEnvironment import ModuleEnvironment
+ if ModuleEnvironment._stopOnError:
+ er = sys.exc_info()[1]
+ sys.exit(1)
except:
success = False
import sys
er = sys.exc_info()[1]
print (" > Unexpected error: " + str(er))
+ from bake.ModuleEnvironment import ModuleEnvironment
+ if ModuleEnvironment._stopOnError:
+ er = sys.exc_info()[1]
+ sys.exit(1)
if not success:
if not self._sources.has_key(i.dst()):
raise DependencyUnmet(i.dst())
--- a/bake/Module.py Sat Aug 31 01:06:53 2013 +0900
+++ b/bake/Module.py Fri Sep 06 08:42:25 2013 +0200
@@ -80,6 +80,16 @@
def _directory(self):
return self._name
+ def handleStopOnError(self, e):
+ """Handles the stop on error parameter, prints the standard
+ message and calls exist."""
+ colorTool = ColorTool()
+ colorTool.cPrintln(colorTool.OK, " > Stop on error enabled (for more information call bake with -vv or -vvv)")
+ colorTool.cPrintln(colorTool.FAIL, " >> " + e._reason)
+ er = sys.exc_info()[1]
+ os._exit(1)
+
+
def _do_download(self, env, source, name, forceDownload):
""" Recursive download function, do the download for each
target module. """
@@ -157,6 +167,8 @@
if env.debug :
import bake.Utils
bake.Utils.print_backtrace()
+ if env.stopOnErrorEnabled:
+ self.handleStopOnError(e)
return False
except:
if isinstance(self._source, SystemDependency):
@@ -166,6 +178,9 @@
if env.debug :
import bake.Utils
bake.Utils.print_backtrace()
+ if env.stopOnErrorEnabled:
+ er = sys.exc_info()[1]
+ self.handleStopOnError(TaskError('Error: %s' % (er)))
return False
@@ -199,6 +214,8 @@
if env.debug :
import bake.Utils
bake.Utils.print_backtrace()
+ if env.stopOnErrorEnabled:
+ self.handleStopOnError(e)
return False
except:
self.printResult(env, " Update ", self.FAIL)
@@ -206,6 +223,9 @@
if env.debug :
import bake.Utils
bake.Utils.print_backtrace()
+ if env.stopOnErrorEnabled:
+ er = sys.exc_info()[1]
+ self.handleStopOnError(TaskError('Error: %s' % (er)))
return False
def distclean(self, env):
@@ -304,6 +324,7 @@
pass
self._installed = []
+
def build(self, env, jobs, force_clean):
""" Main build function. """
@@ -370,6 +391,10 @@
import bake.Utils
bake.Utils.print_backtrace()
env.end_build()
+
+ if env.stopOnErrorEnabled:
+ self.handleStopOnError(e)
+
return False
except:
self._installed = monitor.end()
@@ -377,6 +402,9 @@
if env.debug :
import bake.Utils
bake.Utils.print_backtrace()
+ if env.stopOnErrorEnabled:
+ er = sys.exc_info()[1]
+ self.handleStopOnError(TaskError('Error: %s' % (er)))
return False
def check_build_version(self, env):
@@ -462,12 +490,17 @@
if env.debug :
import bake.Utils
bake.Utils.print_backtrace()
+ if env.stopOnErrorEnabled:
+ self.handleStopOnError(e)
return False
except:
env.end_build()
if env.debug :
import bake.Utils
bake.Utils.print_backtrace()
+ if env.stopOnErrorEnabled:
+ er = sys.exc_info()[1]
+ self.handleStopOnError(TaskError('Error: %s' % (er)))
return False
def is_built_once(self):
--- a/bake/ModuleEnvironment.py Sat Aug 31 01:06:53 2013 +0900
+++ b/bake/ModuleEnvironment.py Fri Sep 06 08:42:25 2013 +0200
@@ -31,11 +31,13 @@
import platform
from bake.Exceptions import TaskError
+from bake.Utils import ColorTool
class ModuleEnvironment:
''' Main class to interact with the host system to execute the external
tools.
'''
+ _stopOnError = False
(HIGHER, LOWER, EQUAL) = range(0,3)
@@ -119,6 +121,12 @@
return self._sudoEnabled
+ @property
+ def stopOnErrorEnabled(self):
+ ''' Returns the setting of the --stop_on_error option'''
+
+ return ModuleEnvironment._stopOnError
+
def _pkgconfig_var(self):
''' Returns the PKG_CONFIG_PATH configured environment variable.'''