From 484ed925ade356ff9260d94635cf30933018d610 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 3 Oct 2018 19:54:54 -0400 Subject: [PATCH] Fix bug setting MAKEFLAGS, and support --jobserver-auth GNU make post-4.2 renamed the --jobserver-fds option to --jobserver-auth. For compatibility with both older and newer versions, when we set MAKEFLAGS we set both, and when we read MAKEFLAGS we will accept either one. Also, when MAKEFLAGS was not already set, redo would set a MAKEFLAGS with a leading 'None' string, which was incorrect. It should be the empty string instead. --- jwack.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/jwack.py b/jwack.py index 99303d8..4717faf 100644 --- a/jwack.py +++ b/jwack.py @@ -77,8 +77,13 @@ def setup(maxjobs): return # already set up _debug('setup(%d)\n' % maxjobs) flags = ' ' + os.getenv('MAKEFLAGS', '') + ' ' - FIND = ' --jobserver-fds=' - ofs = flags.find(FIND) + FIND1 = ' --jobserver-auth=' # renamed in GNU make 4.2 + FIND2 = ' --jobserver-fds=' # fallback syntax + FIND = FIND1 + ofs = flags.find(FIND1) + if ofs < 0: + FIND = FIND2 + ofs = flags.find(FIND2) if ofs >= 0: s = flags[ofs+len(FIND):] (arg,junk) = s.split(' ', 1) @@ -86,13 +91,13 @@ def setup(maxjobs): a = atoi(a) b = atoi(b) if a <= 0 or b <= 0: - raise ValueError('invalid --jobserver-fds: %r' % arg) + raise ValueError('invalid --jobserver-auth: %r' % arg) try: fcntl.fcntl(a, fcntl.F_GETFL) fcntl.fcntl(b, fcntl.F_GETFL) except IOError, e: if e.errno == errno.EBADF: - raise ValueError('broken --jobserver-fds from make; prefix your Makefile rule with a "+"') + raise ValueError('broken --jobserver-auth from make; prefix your Makefile rule with a "+"') else: raise _fds = (a,b) @@ -102,8 +107,10 @@ def setup(maxjobs): _fds = _make_pipe(100) _release(maxjobs-1) os.putenv('MAKEFLAGS', - '%s --jobserver-fds=%d,%d -j' % (os.getenv('MAKEFLAGS'), - _fds[0], _fds[1])) + '%s -j --jobserver-auth=%d,%d --jobserver-fds=%d,%d' % + (os.getenv('MAKEFLAGS', ''), + _fds[0], _fds[1], + _fds[0], _fds[1])) def wait(want_token):