2012-08-04 06:47:28 +00:00
|
|
|
# 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/.
|
|
|
|
|
|
|
|
# Combined with build/autoconf/config.status.m4, ConfigStatus is an almost
|
|
|
|
# drop-in replacement for autoconf 2.13's config.status, with features
|
|
|
|
# borrowed from autoconf > 2.5, and additional features.
|
|
|
|
|
2013-03-04 18:32:57 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2013-02-25 20:47:11 +00:00
|
|
|
import logging
|
2013-01-29 14:24:24 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2012-08-04 06:47:28 +00:00
|
|
|
from optparse import OptionParser
|
2013-01-16 06:22:56 +00:00
|
|
|
|
2013-02-25 20:47:11 +00:00
|
|
|
from mach.logging import LoggingManager
|
2013-01-29 14:24:24 +00:00
|
|
|
from mozbuild.backend.configenvironment import ConfigEnvironment
|
2013-02-25 20:47:11 +00:00
|
|
|
from mozbuild.backend.recursivemake import RecursiveMakeBackend
|
|
|
|
from mozbuild.frontend.emitter import TreeMetadataEmitter
|
|
|
|
from mozbuild.frontend.reader import BuildReader
|
2013-08-08 06:48:41 +00:00
|
|
|
from mozbuild.mozinfo import write_mozinfo
|
2012-08-04 06:47:28 +00:00
|
|
|
|
2013-02-25 20:47:11 +00:00
|
|
|
|
|
|
|
log_manager = LoggingManager()
|
|
|
|
|
|
|
|
|
2013-10-23 21:43:32 +00:00
|
|
|
def config_status(topobjdir='.', topsrcdir='.',
|
|
|
|
defines=[], non_global_defines=[], substs=[]):
|
2012-08-04 06:47:28 +00:00
|
|
|
'''Main function, providing config.status functionality.
|
|
|
|
|
|
|
|
Contrary to config.status, it doesn't use CONFIG_FILES or CONFIG_HEADERS
|
2013-10-23 21:43:32 +00:00
|
|
|
variables.
|
2012-08-04 06:47:28 +00:00
|
|
|
|
|
|
|
Without the -n option, this program acts as config.status and considers
|
|
|
|
the current directory as the top object directory, even when config.status
|
|
|
|
is in a different directory. It will, however, treat the directory
|
2013-10-23 21:43:32 +00:00
|
|
|
containing config.status as the top object directory with the -n option.
|
2012-08-04 06:47:28 +00:00
|
|
|
|
|
|
|
The --recheck option, like with the original config.status, runs configure
|
|
|
|
again, with the options given in the "ac_configure_args" subst.
|
|
|
|
|
|
|
|
The options to this function are passed when creating the
|
2013-10-23 21:43:32 +00:00
|
|
|
ConfigEnvironment. These lists, as well as the actual wrapper script
|
|
|
|
around this function, are meant to be generated by configure.
|
|
|
|
See build/autoconf/config.status.m4.
|
2012-08-04 06:47:28 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
if 'CONFIG_FILES' in os.environ:
|
2013-10-23 21:43:32 +00:00
|
|
|
raise Exception('Using the CONFIG_FILES environment variable is not '
|
|
|
|
'supported.')
|
2012-08-04 06:47:28 +00:00
|
|
|
if 'CONFIG_HEADERS' in os.environ:
|
2013-10-23 21:43:32 +00:00
|
|
|
raise Exception('Using the CONFIG_HEADERS environment variable is not '
|
|
|
|
'supported.')
|
|
|
|
|
|
|
|
if not os.path.isabs(topsrcdir):
|
|
|
|
raise Exception('topsrcdir must be defined as an absolute directory: '
|
|
|
|
'%s' % topsrcdir)
|
2012-08-04 06:47:28 +00:00
|
|
|
|
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option('--recheck', dest='recheck', action='store_true',
|
|
|
|
help='update config.status by reconfiguring in the same conditions')
|
|
|
|
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
|
|
|
|
help='display verbose output')
|
|
|
|
parser.add_option('-n', dest='not_topobjdir', action='store_true',
|
|
|
|
help='do not consider current directory as top object directory')
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
# Without -n, the current directory is meant to be the top object directory
|
|
|
|
if not options.not_topobjdir:
|
2013-05-21 06:26:20 +00:00
|
|
|
topobjdir = os.path.abspath('.')
|
2012-08-04 06:47:28 +00:00
|
|
|
|
2013-01-29 14:24:24 +00:00
|
|
|
env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
|
|
|
|
non_global_defines=non_global_defines, substs=substs)
|
2012-08-04 06:47:28 +00:00
|
|
|
|
2013-08-08 06:48:41 +00:00
|
|
|
# mozinfo.json only needs written if configure changes and configure always
|
|
|
|
# passes this environment variable.
|
|
|
|
if 'WRITE_MOZINFO' in os.environ:
|
|
|
|
write_mozinfo(os.path.join(topobjdir, 'mozinfo.json'), env, os.environ)
|
|
|
|
|
2013-02-25 20:47:11 +00:00
|
|
|
reader = BuildReader(env)
|
|
|
|
emitter = TreeMetadataEmitter(env)
|
|
|
|
backend = RecursiveMakeBackend(env)
|
|
|
|
# This won't actually do anything because of the magic of generators.
|
|
|
|
definitions = emitter.emit(reader.read_topsrcdir())
|
|
|
|
|
2012-08-04 06:47:28 +00:00
|
|
|
if options.recheck:
|
|
|
|
# Execute configure from the top object directory
|
|
|
|
os.chdir(topobjdir)
|
|
|
|
os.execlp('sh', 'sh', '-c', ' '.join([os.path.join(topsrcdir, 'configure'), env.substs['ac_configure_args'], '--no-create', '--no-recursion']))
|
|
|
|
|
2013-10-23 21:43:32 +00:00
|
|
|
log_level = logging.DEBUG if options.verbose else logging.INFO
|
2013-02-25 20:47:11 +00:00
|
|
|
log_manager.add_terminal_logging(level=log_level)
|
|
|
|
log_manager.enable_unstructured()
|
|
|
|
|
2013-10-23 21:43:32 +00:00
|
|
|
print('Reticulating splines...', file=sys.stderr)
|
|
|
|
summary = backend.consume(definitions)
|
2012-08-04 06:47:28 +00:00
|
|
|
|
2013-10-23 21:43:32 +00:00
|
|
|
for line in summary.summaries():
|
|
|
|
print(line, file=sys.stderr)
|