2016-02-23 00:42:40 +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/.
|
|
|
|
|
|
|
|
from __future__ import print_function, unicode_literals
|
|
|
|
|
2016-02-25 19:59:53 +00:00
|
|
|
import codecs
|
|
|
|
import json
|
2016-02-23 00:42:40 +00:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2016-02-25 19:59:53 +00:00
|
|
|
|
|
|
|
base_dir = os.path.abspath(os.path.dirname(__file__))
|
2016-02-25 17:49:03 +00:00
|
|
|
sys.path.append(os.path.join(base_dir, 'python', 'mozbuild'))
|
2016-03-04 08:31:10 +00:00
|
|
|
from mozbuild.configure import ConfigureSandbox
|
2016-02-23 00:42:40 +00:00
|
|
|
|
|
|
|
|
2016-03-04 08:31:10 +00:00
|
|
|
def main(argv):
|
|
|
|
config = {}
|
|
|
|
sandbox = ConfigureSandbox(config, os.environ, argv)
|
|
|
|
sandbox.run(os.path.join(os.path.dirname(__file__), 'moz.configure'))
|
2016-02-25 19:59:53 +00:00
|
|
|
|
2016-03-04 08:31:10 +00:00
|
|
|
if sandbox._help:
|
|
|
|
return 0
|
2016-02-25 19:59:53 +00:00
|
|
|
|
2016-03-15 07:41:53 +00:00
|
|
|
return config_status(config)
|
|
|
|
|
|
|
|
|
|
|
|
def config_status(config):
|
2016-03-04 08:31:10 +00:00
|
|
|
# Sanitize config data to feed config.status
|
2016-03-22 05:03:26 +00:00
|
|
|
# Ideally, all the backend and frontend code would handle the booleans, but
|
|
|
|
# there are so many things involved, that it's easier to keep config.status
|
|
|
|
# untouched for now.
|
|
|
|
def sanitized_bools(v):
|
|
|
|
if v is True:
|
|
|
|
return '1'
|
|
|
|
if v is False:
|
|
|
|
return ''
|
|
|
|
return v
|
|
|
|
|
2016-03-04 08:31:10 +00:00
|
|
|
sanitized_config = {}
|
|
|
|
sanitized_config['substs'] = {
|
2016-03-22 05:03:26 +00:00
|
|
|
k: sanitized_bools(v) for k, v in config.iteritems()
|
2016-03-04 08:31:10 +00:00
|
|
|
if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR')
|
2016-02-25 19:59:53 +00:00
|
|
|
}
|
2016-03-22 05:03:26 +00:00
|
|
|
sanitized_config['defines'] = {
|
|
|
|
k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems()
|
|
|
|
}
|
2016-03-04 08:31:10 +00:00
|
|
|
sanitized_config['non_global_defines'] = config['non_global_defines']
|
|
|
|
sanitized_config['topsrcdir'] = config['TOPSRCDIR']
|
|
|
|
sanitized_config['topobjdir'] = config['TOPOBJDIR']
|
2016-02-25 19:59:53 +00:00
|
|
|
|
|
|
|
# Create config.status. Eventually, we'll want to just do the work it does
|
|
|
|
# here, when we're able to skip configure tests/use cached results/not rely
|
|
|
|
# on autoconf.
|
|
|
|
print("Creating config.status", file=sys.stderr)
|
2016-03-04 08:31:10 +00:00
|
|
|
encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
|
2016-02-25 19:59:53 +00:00
|
|
|
with codecs.open('config.status', 'w', encoding) as fh:
|
2016-03-04 08:31:10 +00:00
|
|
|
fh.write('#!%s\n' % config['PYTHON'])
|
2016-02-25 19:59:53 +00:00
|
|
|
fh.write('# coding=%s\n' % encoding)
|
2016-03-15 22:27:22 +00:00
|
|
|
# Because we're serializing as JSON but reading as python, the values
|
|
|
|
# for True, False and None are true, false and null, which don't exist.
|
|
|
|
# Define them.
|
|
|
|
fh.write('true, false, null = True, False, None\n')
|
2016-03-04 08:31:10 +00:00
|
|
|
for k, v in sanitized_config.iteritems():
|
2016-02-25 19:59:53 +00:00
|
|
|
fh.write('%s = ' % k)
|
|
|
|
json.dump(v, fh, sort_keys=True, indent=4, ensure_ascii=False)
|
|
|
|
fh.write('\n')
|
|
|
|
fh.write("__all__ = ['topobjdir', 'topsrcdir', 'defines', "
|
|
|
|
"'non_global_defines', 'substs']")
|
|
|
|
|
2016-03-18 09:33:18 +00:00
|
|
|
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
|
2016-02-25 19:59:53 +00:00
|
|
|
fh.write('''
|
|
|
|
if __name__ == '__main__':
|
|
|
|
args = dict([(name, globals()[name]) for name in __all__])
|
|
|
|
from mozbuild.config_status import config_status
|
|
|
|
config_status(**args)
|
|
|
|
''')
|
|
|
|
|
|
|
|
# Other things than us are going to run this file, so we need to give it
|
|
|
|
# executable permissions.
|
|
|
|
os.chmod('config.status', 0755)
|
2016-03-18 09:33:18 +00:00
|
|
|
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
|
Bug 1278415 - Also write a mozinfo for js standalone builds. r=gps
Historically, a mozinfo for js standalone build has not been necessary,
but with the move towards a) having things work with mach and b)
buildconfig using the MozbuildObject.from_environment in next patch,
mozinfo becomes necessary (it's required for
MozbuildObject.from_environment to find the directory is an objdir).
Interestingly, hazard builds do both a js standalone build and a desktop
Firefox build at the same time, both of which are done with MOZCONFIG
set in the environment... with the Firefox mozconfig. The result of now
writing a mozinfo for js standalone builds is that in that case, they
end up with a reference to the mozconfig, which the build system then
reads, and finds a MOZ_OBJDIR, which then doesn't match the js
standalone build objdir. So for those builds, reset MOZCONFIG.
2016-06-07 04:49:14 +00:00
|
|
|
os.environ['WRITE_MOZINFO'] = '1'
|
2016-03-16 02:21:27 +00:00
|
|
|
# Until we have access to the virtualenv from this script, execute
|
|
|
|
# config.status externally, with the virtualenv python.
|
|
|
|
return subprocess.call([config['PYTHON'], 'config.status'])
|
2016-02-25 19:59:53 +00:00
|
|
|
return 0
|
2016-02-23 00:42:40 +00:00
|
|
|
|
2016-03-15 07:41:53 +00:00
|
|
|
|
2016-02-23 00:42:40 +00:00
|
|
|
if __name__ == '__main__':
|
2016-03-04 08:31:10 +00:00
|
|
|
sys.exit(main(sys.argv))
|