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

@ -15,7 +15,7 @@ def _default_do_files(filename):
def possible_do_files(t):
dirname, filename = os.path.split(t)
yield (os.path.join(env.BASE, dirname), "%s.do" % filename,
yield (os.path.join(env.v.BASE, dirname), "%s.do" % filename,
'', filename, '')
# It's important to try every possibility in a directory before resorting
@ -24,7 +24,7 @@ def possible_do_files(t):
# the former one might just be an artifact of someone embedding my project
# into theirs as a subdir. When they do, my rules should still be used
# for building my project in *all* cases.
t = os.path.normpath(os.path.join(env.BASE, t))
t = os.path.normpath(os.path.join(env.v.BASE, t))
dirname, filename = os.path.split(t)
dirbits = dirname.split('/')
# since t is an absolute path, dirbits[0] is always '', so we don't