Bug 1250294 - Make configure a Python script that invokes the old configure.sh. r=ted

This commit is contained in:
Mike Hommey 2016-02-23 09:42:40 +09:00
parent 5679b750b4
commit 9f1a6ba990
8 changed files with 13008 additions and 12853 deletions

View File

@ -66,19 +66,19 @@ CLOBBER: $(topsrcdir)/CLOBBER
@exit 1
endif
$(topsrcdir)/configure: $(topsrcdir)/configure.in
$(topsrcdir)/js/src/configure: $(topsrcdir)/js/src/configure.in
$(topsrcdir)/configure: $(topsrcdir)/configure.in $(topsrcdir)/old-configure.in
$(topsrcdir)/js/src/configure: $(topsrcdir)/js/src/configure.in $(topsrcdir)/js/src/old-configure.in
$(topsrcdir)/configure $(topsrcdir)/js/src/configure:
@echo 'STOP! $^ has changed, and your configure is out of date.'
@echo 'STOP! $? has changed, and your configure is out of date.'
@echo 'Please rerun autoconf and re-configure your build directory.'
@echo 'To ignore this message, touch "$@",'
@echo 'but your build might not succeed.'
@exit 1
config.status: $(configure_dir)/configure
js/src/config.status: $(topsrcdir)/js/src/configure
config.status: $(configure_dir)/configure $(configure_dir)/old-configure
js/src/config.status: $(topsrcdir)/js/src/configure $(topsrcdir)/js/src/old-configure
config.status js/src/config.status:
@echo 'STOP! $^ has changed and needs to be run again.'
@echo 'STOP! $? has changed and needs to be run again.'
@echo 'Please rerun it.'
@echo 'To ignore this message, touch "$(CURDIR)/$@",'
@echo 'but your build might not succeed.'

View File

@ -303,7 +303,22 @@ def run(objdir):
relobjdir = os.path.relpath(objdir, os.getcwd())
if not skip_configure:
command = [data['shell'], configure]
if mozpath.normsep(relobjdir) == 'js/src':
# Because configure is a shell script calling a python script
# calling a shell script, on Windows, with msys screwing the
# environment, we lose the benefits from our own efforts in this
# script to get past the msys problems. So manually call the python
# script instead, so that we don't do a native->msys transition
# here. Then the python configure will still have the right
# environment when calling the shell configure.
command = [
sys.executable,
os.path.join(os.path.dirname(__file__), '..', 'configure.py'),
]
data['env']['OLD_CONFIGURE'] = os.path.join(
os.path.dirname(configure), 'old-configure')
else:
command = [data['shell'], configure]
for kind in ('target', 'build', 'host'):
if data.get(kind) is not None:
command += ['--%s=%s' % (kind, data[kind])]

View File

@ -291,8 +291,10 @@ CONFIG_CACHE = $(wildcard $(OBJDIR)/config.cache)
EXTRA_CONFIG_DEPS := \
$(TOPSRCDIR)/aclocal.m4 \
$(TOPSRCDIR)/old-configure.in \
$(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
$(TOPSRCDIR)/js/src/aclocal.m4 \
$(TOPSRCDIR)/js/src/old-configure.in \
$(NULL)
$(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)

File diff suppressed because it is too large Load Diff

90
configure.py Normal file
View File

@ -0,0 +1,90 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function, unicode_literals
import glob
import itertools
import os
import subprocess
import sys
base_dir = os.path.dirname(__file__)
sys.path.append(os.path.join(base_dir, 'python', 'which'))
from which import which, WhichError
# If feel dirty replicating this from python/mozbuild/mozbuild/mozconfig.py,
# but the end goal being that the configure script would go away...
shell = 'sh'
if 'MOZILLABUILD' in os.environ:
shell = os.environ['MOZILLABUILD'] + '/msys/bin/sh'
if sys.platform == 'win32':
shell = shell + '.exe'
def find_program(file):
try:
return which(file)
except WhichError:
return None
def autoconf_refresh(configure):
if os.path.exists(configure):
mtime = os.path.getmtime(configure)
aclocal = os.path.join(base_dir, 'build', 'autoconf', '*.m4')
for input in itertools.chain(
(configure + '.in',
os.path.join(os.path.dirname(configure), 'aclocal.m4')),
glob.iglob(aclocal),
):
if os.path.getmtime(input) > mtime:
break
else:
return
for ac in ('autoconf-2.13', 'autoconf2.13', 'autoconf213'):
autoconf = find_program(ac)
if autoconf:
break
else:
fink = find_program('fink')
if fink:
autoconf = os.path.normpath(os.path.join(
fink, '..', '..', 'lib', 'autoconf2.13', 'bin', 'autoconf'))
if not autoconf:
raise RuntimeError('Could not find autoconf 2.13')
print('Refreshing %s' % configure, file=sys.stderr)
with open(configure, 'wb') as fh:
subprocess.check_call([
shell, autoconf, '--localdir=%s' % os.path.dirname(configure),
configure + '.in'], stdout=fh)
def main(args):
old_configure = os.environ.get('OLD_CONFIGURE')
if not old_configure:
raise Exception('The OLD_CONFIGURE environment variable must be set')
# We need to replace backslashes with forward slashes on Windows because
# this path actually ends up literally as $0, which breaks autoconf's
# detection of the source directory.
old_configure = os.path.abspath(old_configure).replace(os.sep, '/')
try:
autoconf_refresh(old_configure)
except RuntimeError as e:
print(e.message, file=sys.stderr)
return 1
return subprocess.call([shell, old_configure] + args)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))

File diff suppressed because it is too large Load Diff

3672
js/src/old-configure.in Normal file

File diff suppressed because it is too large Load Diff

9184
old-configure.in Normal file

File diff suppressed because it is too large Load Diff