Bug 1448349 - Warn about autoconf $PATH problems on win32 r=firefox-build-system-reviewers,chmanchester

Detect if Unix utilities on win32 are being picked up from a foreign
installation of MinGW, such as the tools packaged with Git for Windows.
If autoconf dies during `./mach configure` and foreign tools are found
in $PATH then warn the user that their $PATH may need to change to fix
the problem.

Differential Revision: https://phabricator.services.mozilla.com/D52960

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Māris Fogels 2019-11-21 00:20:56 +00:00
parent 566e87fdab
commit 1d657c8499

View File

@ -69,7 +69,7 @@ def prepare_mozconfig(mozconfig):
return items
@depends('OLD_CONFIGURE', prepare_mozconfig, autoconf, check_build_environment,
@depends('OLD_CONFIGURE', 'MOZILLABUILD', prepare_mozconfig, autoconf, check_build_environment,
shell, old_configure_assignments, build_project)
@imports(_from='__builtin__', _import='open')
@imports(_from='__builtin__', _import='print')
@ -82,10 +82,12 @@ def prepare_mozconfig(mozconfig):
@imports(_from='os.path', _import='exists')
@imports(_from='mozbuild.shellutil', _import='quote')
@imports(_from='tempfile', _import='NamedTemporaryFile')
@imports(_from='os', _import='environ')
@imports(_from='os', _import='remove')
@imports(_from='os', _import='rename')
@imports(_from='subprocess', _import='CalledProcessError')
@imports(_from='__builtin__', _import='OSError')
def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
def prepare_configure(old_configure, mozillabuild, mozconfig, autoconf, build_env, shell,
old_configure_assignments, build_project):
# os.path.abspath in the sandbox will ensure forward slashes on Windows,
# which is actually necessary because this path actually ends up literally
@ -115,10 +117,25 @@ def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
if refresh:
log.info('Refreshing %s with %s', old_configure, autoconf)
script = subprocess.check_output([
shell, autoconf,
'--localdir=%s' % os.path.dirname(old_configure),
old_configure + '.in'])
try:
script = subprocess.check_output([
shell, autoconf,
'--localdir=%s' % os.path.dirname(old_configure),
old_configure + '.in'])
except CalledProcessError as exc:
# Autoconf on win32 may break due to a bad $PATH. Let the user know
# their $PATH is suspect.
if mozillabuild:
mozillabuild_path = normsep(mozillabuild[0])
sh_path = normsep(find_program('sh'))
if mozillabuild_path not in sh_path:
log.warning("The '{}msys/bin' directory is not first in $PATH. "
"This may cause autoconf to fail. ($PATH is currently "
"set to: {})".format(mozillabuild_path, environ[
'PATH']))
die('autoconf exited with return code {}'.format(exc.returncode))
if not script:
die('Generated old-configure is empty! Check that your autoconf 2.13 program works!')