Skip to content

Commit

Permalink
builder.py: remove the build() wrapper function and BuildError.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apenwarr committed Nov 22, 2010
1 parent 7aa7c41 commit 547dbe5
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions builder.py
Expand Up @@ -3,10 +3,6 @@
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)
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 547dbe5

Please sign in to comment.