Commit graph

13 commits

Author SHA1 Message Date
Moritz Lell
491040ea72 Run 2to3 utility 2019-10-30 19:58:12 +01:00
Avery Pennarun
b196315222 Change -x/-v to only affect top-level targets by default, not recursively.
Because redo targets are nicely isolated (unlike make targets), you
usually only want to debug one of them at a time.  Using -x could be
confusing, because you might end up with a dump of output from a
dependency you're not interested in.

Now, by default we'll disable -x when recursing into sub-targets, so
you only see the trace from the targets you are actually trying to
debug.  To get recursive behaviour, specify -x twice, eg. -xx.

Same idea with -v.
2019-03-02 18:46:00 -05:00
Avery Pennarun
3dbdfbc06f Better handling if parent closes REDO_CHEATFDS or MAKEFLAGS fds.
Silently recover if REDO_CHEATFDS file descriptors are closed, because
they aren't completely essential and MAKEFLAGS-related warnings already
get printed if all file descriptors have been closed.

If MAKEFLAGS --jobserver-auth flags are closed, improve the error
message so that a) it's a normal error instead of an exception and b)
we link to documentation about why it happens.  Also write some more
detailed documentation about what's going on here.
2019-01-18 00:11:48 +00:00
Avery Pennarun
61f3e4672e Workaround for completely broken file locking on Windows 10 WSL.
WSL (Windows Services for Linux) provides a Linux-kernel-compatible ABI
for userspace processes, but the current version doesn't not implement
fcntl() locks at all; it just always returns success.  See
https://github.com/Microsoft/WSL/issues/1927.

This causes us three kinds of problem:
  1. sqlite3 in WAL mode gives "OperationalError: locking protocol".
     1b. Other sqlite3 journal modes also don't work when used by
         multiple processes.
  2. redo parallelism doesn't work, because we can't prevent the same
     target from being build several times simultaneously.
  3. "redo-log -f" doesn't work, since it can't tell whether the log
     file it's tailing is "done" or not.

To fix #1, we switch the sqlite3 journal back to PERSIST instead of
WAL.  We originally changed to WAL in commit 5156feae9d to reduce
deadlocks on MacOS.  That was never adequately explained, but PERSIST
still acts weird on MacOS, so we'll only switch to PERSIST when we
detect that locking is definitely broken.  Sigh.

To (mostly) fix #2, we disable any -j value > 1 when locking is broken.
This prevents basic forms of parallelism, but doesn't stop you from
re-entrantly starting other instances of redo.  To fix that properly,
we need to switch to a different locking mechanism entirely, which is
tough in python.  flock() locks probably work, for example, but
python's locks lie and just use fcntl locks for those.

To fix #3, we always force --no-log mode when we find that locking is
broken.
2019-01-02 14:49:33 -05:00
Avery Pennarun
19049d52fc jobserver: allow overriding the parent jobserver in a subprocess.
Previously, if you passed a -j option to a redo process in a redo or
make process hierarchy with MAKEFLAGS already set, it would ignore the
-j option and continue using the jobserver provided by the parent.

With this change, we instead initialize a new jobserver with the
desired number of tokens, which is what GNU make does in the same
situation.  A typical use case for this is to force serialization of
build steps in a subtree (by using -j1).  In make, this is often useful
for "fixing" makefiles that haven't been written correctly for parallel
builds.  In redo, that happens much less often, but it's useful at
least in unit tests.

Passing -j1 is relatively harmless (the redo you are starting inherits
a token anyway, so it doesn't create any new tokens).  Passing -j > 1
is more risky, because it creates new tokens, thus increasing the level
of parallelism in the system.  Because this may not be what you wanted,
we print a warning when you pass -j > 1 to a sub-redo.  GNU make gives
a similar warning in this situation.
2018-12-31 19:24:27 -05:00
Avery Pennarun
29f939013e Add a bunch of missing python docstrings.
This appeases pylint, so un-disable its docstring warning.
2018-12-14 09:03:53 +00:00
Avery Pennarun
2b4fe812e2 Some renaming and comments to try to clarify builder and jobserver.
The code is still a bit spaghetti-like, especialy when it comes to
redo-unlocked, but at least the new names are slightly more
comprehensible.
2018-12-11 04:17:27 +00:00
Avery Pennarun
4d2b4cfccb Make calls to logs.setup() explicit in each cmd.
Further reducing magic implicit behaviour to make code easier to
follow.
2018-12-11 02:35:11 +00:00
Avery Pennarun
bd8dbfb487 Switch to module-relative import syntax.
Now that the python scripts are all in a "redo" python module, we can
use the "new style" (ahem) package-relative imports.  This appeases
pylint, plus avoids confusion in case more than one package has
similarly-named modules.
2018-12-05 02:34:36 -05:00
Avery Pennarun
9b6d1eeb6e 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.
2018-12-05 02:27:04 -05:00
Avery Pennarun
ded14507b0 Rename vars{,_init}.py -> env{,_init}.py.
This fixes some pylint 'redefined builtins' warnings.  While I was
here, I fixed the others too by renaming a few local variables.
2018-12-05 02:26:49 -05:00
Avery Pennarun
65cf1c9854 Rename jwack.py -> jobserver.py.
I'm not really sure why I called it jwack.  I think it was kind of a
wack jobserver(tm).  But nowadays most of the wack-ness is gone.
2018-12-05 00:22:10 -05:00
Avery Pennarun
f6fe00db5c Directory reorg: move code into redo/, generate binaries in bin/.
It's time to start preparing for a version of redo that doesn't work
unless we build it first (because it will rely on C modules, and
eventually be rewritten in C altogether).

To get rolling, remove the old-style symlinks to the main programs, and
rename those programs from redo-*.py to redo/cmd_*.py.  We'll also move
all library functions into the redo/ dir, which is a more python-style
naming convention.

Previously, install.do was generating wrappers for installing in
/usr/bin, which extend sys.path and then import+run the right file.
This made "installed" redo work quite differently from running redo
inside its source tree.  Instead, let's always generate the wrappers in
bin/, and not make anything executable except those wrappers.

Since we're generating wrappers anyway, let's actually auto-detect the
right version of python for the running system; distros can't seem to
agree on what to call their python2 binaries (sigh). We'll fill in the
right #! shebang lines.  Since we're doing that, we can stop using
/usr/bin/env, which will a) make things slightly faster, and b) let us
use "python -S", which tells python not to load a bunch of extra crap
we're not using, thus improving startup times.

Annoyingly, we now have to build redo using minimal/do, then run the
tests using bin/redo.  To make this less annoying, we add a toplevel
./do script that knows the right steps, and a Makefile (whee!) for
people who are used to typing 'make' and 'make test' and 'make clean'.
2018-12-04 02:53:40 -05:00
Renamed from redo.py (Browse further)