env and env_init: Eliminate weird auto-initialization of globals.

Merge the two files into env, and make each command explicitly call the
function that sets it up in the way that's needed for that command.

This means we can finally just import all the modules at the top of
each file, without worrying about import order.  Phew.

While we're here, remove the weird auto-appending-'all'-to-targets
feature in env.init().  Instead, do it explicitly, and only from redo and
redo-ifchange, only if is_toplevel and no other targets are given.
This commit is contained in:
Avery Pennarun 2018-12-05 01:07:16 -05:00
commit 9b6d1eeb6e
19 changed files with 267 additions and 256 deletions

View file

@ -16,7 +16,7 @@ def isdirty(f, depth, max_changed,
# is unaffected
already_checked = list(already_checked) + [f.id]
if env.DEBUG >= 1:
if env.v.DEBUG >= 1:
debug('%s?%s %r,%r\n'
% (depth, f.nicename(), f.is_generated, f.is_override))
@ -28,10 +28,10 @@ def isdirty(f, depth, max_changed,
return DIRTY
if f.changed_runid > max_changed:
debug('%s-- DIRTY (built %d > %d; %d)\n'
% (depth, f.changed_runid, max_changed, env.RUNID))
% (depth, f.changed_runid, max_changed, env.v.RUNID))
return DIRTY # has been built more recently than parent
if is_checked(f):
if env.DEBUG >= 1:
if env.v.DEBUG >= 1:
debug('%s-- CLEAN (checked)\n' % depth)
return CLEAN # has already been checked during this session
if not f.stamp:
@ -65,7 +65,7 @@ def isdirty(f, depth, max_changed,
for mode, f2 in f.deps():
dirty = CLEAN
if mode == 'c':
if os.path.exists(os.path.join(env.BASE, f2.name)):
if os.path.exists(os.path.join(env.v.BASE, f2.name)):
debug('%s-- DIRTY (created)\n' % depth)
dirty = DIRTY
elif mode == 'm':