Move env.{add,get}_lock() into cycles.py, and rename.

They really aren't locks at all, they're a cycle detector.  Also rename
REDO_LOCKS to a more meaningful REDO_CYCLES.  And we'll move the
CyclicDependencyError exception in here as well, instead of state.py
where it doesn't really belong.
This commit is contained in:
Avery Pennarun 2018-12-05 00:18:07 -05:00
commit f1305b49eb
5 changed files with 32 additions and 25 deletions

View file

@ -1,5 +1,5 @@
import sys, os, errno, stat, signal, time
import env, jobserver, state, paths
import cycles, env, jobserver, state, paths
from helpers import unlink, close_on_exec
import logs
from logs import debug2, err, warn, meta, check_tty
@ -129,7 +129,7 @@ class BuildJob(object):
try:
try:
is_target, dirty = self.shouldbuildfunc(self.t)
except state.CyclicDependencyError:
except cycles.CyclicDependencyError:
err('cyclic dependency while checking %s\n' % _nice(self.t))
raise ImmediateReturn(208)
if not dirty:
@ -264,7 +264,7 @@ class BuildJob(object):
os.environ['REDO_PWD'] = state.relpath(newp, env.STARTDIR)
os.environ['REDO_TARGET'] = self.basename + self.ext
os.environ['REDO_DEPTH'] = env.DEPTH + ' '
env.add_lock(str(self.lock.fid))
cycles.add(self.lock.fid)
if dn:
os.chdir(dn)
os.dup2(self.f.fileno(), 1)
@ -499,7 +499,7 @@ def main(targets, shouldbuildfunc):
meta('waiting', state.target_relpath(t))
try:
lock.check()
except state.CyclicDependencyError:
except cycles.CyclicDependencyError:
err('cyclic dependency while building %s\n' % _nice(t))
retcode[0] = 208
return retcode[0]