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.
This commit is contained in:
parent
cb05a7bd98
commit
484ed925ad
1 changed files with 13 additions and 6 deletions
17
jwack.py
17
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,7 +107,9 @@ def setup(maxjobs):
|
|||
_fds = _make_pipe(100)
|
||||
_release(maxjobs-1)
|
||||
os.putenv('MAKEFLAGS',
|
||||
'%s --jobserver-fds=%d,%d -j' % (os.getenv('MAKEFLAGS'),
|
||||
'%s -j --jobserver-auth=%d,%d --jobserver-fds=%d,%d' %
|
||||
(os.getenv('MAKEFLAGS', ''),
|
||||
_fds[0], _fds[1],
|
||||
_fds[0], _fds[1]))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue