builder.py: remove the build() wrapper function and BuildError.
The only thing we want to do on a build error is return a nonzero exit code, so let's just do that, simplifying the code a bit.
This commit is contained in:
parent
7aa7c41e38
commit
547dbe550f
1 changed files with 5 additions and 15 deletions
20
builder.py
20
builder.py
|
|
@ -3,10 +3,6 @@ import vars, jwack, state
|
|||
from helpers import log, log_, debug2, err, unlink
|
||||
|
||||
|
||||
class BuildError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def _possible_do_files(t):
|
||||
yield "%s.do" % t, t, ''
|
||||
dirname,filename = os.path.split(t)
|
||||
|
|
@ -45,7 +41,7 @@ def _nice(t):
|
|||
return os.path.normpath(os.path.join(vars.PWD, t))
|
||||
|
||||
|
||||
def _build(t):
|
||||
def build(t):
|
||||
if (os.path.exists(t) and not state.is_generated(t)
|
||||
and not os.path.exists('%s.do' % t)):
|
||||
# an existing source file that is not marked as a generated file.
|
||||
|
|
@ -58,7 +54,8 @@ def _build(t):
|
|||
state.start(t)
|
||||
(dofile, basename, ext) = _find_do_file(t)
|
||||
if not dofile:
|
||||
raise BuildError('no rule to make %r' % t)
|
||||
err('no rule to make %r\n' % t)
|
||||
return 1
|
||||
state.stamp(dofile)
|
||||
tmpname = '%s.redo.tmp' % t
|
||||
unlink(tmpname)
|
||||
|
|
@ -94,19 +91,12 @@ def _build(t):
|
|||
state.unstamp(t)
|
||||
f.close()
|
||||
if rv != 0:
|
||||
raise BuildError('%s: exit code %d' % (_nice(t),rv))
|
||||
err('%s: exit code %d\n' % (_nice(t),rv))
|
||||
return 1
|
||||
if vars.VERBOSE or vars.XTRACE:
|
||||
log('%s (done)\n\n' % _nice(t))
|
||||
|
||||
|
||||
def build(t):
|
||||
try:
|
||||
return _build(t)
|
||||
except BuildError, e:
|
||||
err('%s\n' % e)
|
||||
return 1
|
||||
|
||||
|
||||
def main(targets, buildfunc):
|
||||
retcode = [0] # a list so that it can be reassigned from done()
|
||||
if vars.SHUFFLE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue