2016-07-14 19:16:42 +03:00
|
|
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
2016-03-04 11:31:10 +03:00
|
|
|
# vim: set filetype=python:
|
|
|
|
# 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/.
|
|
|
|
|
|
|
|
include('util.configure')
|
2016-03-24 12:37:03 +03:00
|
|
|
include('checks.configure')
|
2016-03-04 11:31:10 +03:00
|
|
|
|
|
|
|
option(env='DIST', nargs=1, help='DIST directory')
|
|
|
|
|
|
|
|
# Do not allow objdir == srcdir builds.
|
|
|
|
# ==============================================================
|
|
|
|
@depends('--help', 'DIST')
|
2016-11-04 00:50:43 +03:00
|
|
|
@imports(_from='os.path', _import='exists')
|
2016-03-04 11:31:10 +03:00
|
|
|
def check_build_environment(help, dist):
|
|
|
|
topobjdir = os.path.realpath(os.path.abspath('.'))
|
|
|
|
topsrcdir = os.path.realpath(os.path.abspath(
|
|
|
|
os.path.join(os.path.dirname(__file__), '..', '..')))
|
|
|
|
|
2016-03-22 09:46:16 +03:00
|
|
|
if dist:
|
|
|
|
dist = normsep(dist[0])
|
|
|
|
else:
|
|
|
|
dist = os.path.join(topobjdir, 'dist')
|
|
|
|
|
|
|
|
result = namespace(
|
|
|
|
topsrcdir=topsrcdir,
|
|
|
|
topobjdir=topobjdir,
|
|
|
|
dist=dist,
|
|
|
|
)
|
2016-03-04 11:31:10 +03:00
|
|
|
|
|
|
|
if help:
|
2016-03-22 09:46:16 +03:00
|
|
|
return result
|
2016-03-04 11:31:10 +03:00
|
|
|
|
|
|
|
if topsrcdir == topobjdir:
|
2016-03-25 09:48:21 +03:00
|
|
|
die(' ***\n'
|
2016-03-04 11:31:10 +03:00
|
|
|
' * Building directly in the main source directory is not allowed.\n'
|
|
|
|
' *\n'
|
|
|
|
' * To build, you must run configure from a separate directory\n'
|
|
|
|
' * (referred to as an object directory).\n'
|
|
|
|
' *\n'
|
|
|
|
' * If you are building with a mozconfig, you will need to change your\n'
|
|
|
|
' * mozconfig to point to a different object directory.\n'
|
|
|
|
' ***'
|
2017-10-12 16:08:35 +03:00
|
|
|
)
|
2016-03-04 11:31:10 +03:00
|
|
|
|
|
|
|
# Check for a couple representative files in the source tree
|
|
|
|
conflict_files = [
|
|
|
|
'* %s' % f for f in ('Makefile', 'config/autoconf.mk')
|
2016-11-04 00:50:43 +03:00
|
|
|
if exists(os.path.join(topsrcdir, f))
|
2016-03-04 11:31:10 +03:00
|
|
|
]
|
|
|
|
if conflict_files:
|
2016-03-25 09:48:21 +03:00
|
|
|
die(' ***\n'
|
2016-03-04 11:31:10 +03:00
|
|
|
' * Your source tree contains these files:\n'
|
|
|
|
' %s\n'
|
|
|
|
' * This indicates that you previously built in the source tree.\n'
|
|
|
|
' * A source tree build can confuse the separate objdir build.\n'
|
|
|
|
' *\n'
|
|
|
|
' * To clean up the source tree:\n'
|
|
|
|
' * 1. cd %s\n'
|
|
|
|
' * 2. gmake distclean\n'
|
|
|
|
' ***'
|
|
|
|
% ('\n '.join(conflict_files), topsrcdir)
|
2017-10-12 16:08:35 +03:00
|
|
|
)
|
2016-03-04 11:31:10 +03:00
|
|
|
|
2016-03-22 09:46:16 +03:00
|
|
|
return result
|
|
|
|
|
2017-05-17 10:13:34 +03:00
|
|
|
set_config('TOPSRCDIR', check_build_environment.topsrcdir)
|
|
|
|
set_config('TOPOBJDIR', check_build_environment.topobjdir)
|
|
|
|
set_config('MOZ_BUILD_ROOT', check_build_environment.topobjdir)
|
|
|
|
set_config('DIST', check_build_environment.dist)
|
2016-03-22 08:21:32 +03:00
|
|
|
|
2016-11-24 03:47:15 +03:00
|
|
|
add_old_configure_assignment(
|
2017-05-17 10:13:34 +03:00
|
|
|
'_topsrcdir', check_build_environment.topsrcdir)
|
2016-11-24 03:47:15 +03:00
|
|
|
add_old_configure_assignment(
|
2017-05-17 10:13:34 +03:00
|
|
|
'_objdir', check_build_environment.topobjdir)
|
2016-11-24 03:47:15 +03:00
|
|
|
add_old_configure_assignment(
|
2017-05-17 10:13:34 +03:00
|
|
|
'MOZ_BUILD_ROOT', check_build_environment.topobjdir)
|
2016-11-24 03:47:15 +03:00
|
|
|
add_old_configure_assignment(
|
2017-05-17 10:13:34 +03:00
|
|
|
'DIST', check_build_environment.dist)
|
2016-03-04 11:31:10 +03:00
|
|
|
|
2016-08-09 01:43:27 +03:00
|
|
|
option(env='MOZ_AUTOMATION', help='Enable options for automated builds')
|
|
|
|
set_config('MOZ_AUTOMATION', depends_if('MOZ_AUTOMATION')(lambda x: True))
|
|
|
|
|
|
|
|
|
2016-03-11 05:30:54 +03:00
|
|
|
option(env='OLD_CONFIGURE', nargs=1, help='Path to the old configure script')
|
|
|
|
|
2016-03-04 11:31:10 +03:00
|
|
|
option(env='MOZ_CURRENT_PROJECT', nargs=1, help='Current build project')
|
|
|
|
option(env='MOZCONFIG', nargs=1, help='Mozconfig location')
|
|
|
|
|
2017-03-09 05:50:35 +03:00
|
|
|
option('--with-external-source-dir', env='EXTERNAL_SOURCE_DIR', nargs=1,
|
|
|
|
help='External directory containing additional build files')
|
|
|
|
|
|
|
|
@depends('--with-external-source-dir')
|
|
|
|
def external_source_dir(value):
|
|
|
|
if value:
|
|
|
|
return value[0]
|
|
|
|
|
|
|
|
set_config('EXTERNAL_SOURCE_DIR', external_source_dir)
|
|
|
|
add_old_configure_assignment('EXTERNAL_SOURCE_DIR', external_source_dir)
|
|
|
|
|
2016-03-04 11:31:10 +03:00
|
|
|
# Read user mozconfig
|
|
|
|
# ==============================================================
|
|
|
|
# Note: the dependency on --help is only there to always read the mozconfig,
|
|
|
|
# even when --help is passed. Without this dependency, the function wouldn't
|
|
|
|
# be called when --help is passed, and the mozconfig wouldn't be read.
|
2016-03-11 05:30:54 +03:00
|
|
|
@depends('MOZ_CURRENT_PROJECT', 'MOZCONFIG', 'OLD_CONFIGURE',
|
2017-03-09 05:50:35 +03:00
|
|
|
check_build_environment, '--with-external-source-dir',
|
|
|
|
'--help')
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports(_from='mozbuild.mozconfig', _import='MozconfigLoader')
|
2017-03-09 05:50:35 +03:00
|
|
|
def mozconfig(current_project, mozconfig, old_configure, build_env,
|
|
|
|
external_source_dir, help):
|
2016-03-11 05:30:54 +03:00
|
|
|
if not old_configure:
|
2016-03-25 09:48:21 +03:00
|
|
|
die('The OLD_CONFIGURE environment variable must be set')
|
2016-03-11 05:30:54 +03:00
|
|
|
|
2016-03-04 11:31:10 +03:00
|
|
|
# Don't read the mozconfig for the js configure (yay backwards
|
|
|
|
# compatibility)
|
2016-03-11 05:30:54 +03:00
|
|
|
# While the long term goal is that js and top-level use the same configure
|
|
|
|
# and the same overall setup, including the possibility to use mozconfigs,
|
|
|
|
# figuring out what we want to do wrt mozconfig vs. command line and
|
|
|
|
# environment variable is not a clear-cut case, and it's more important to
|
|
|
|
# fix the immediate problem mozconfig causes to js developers by
|
|
|
|
# "temporarily" returning to the previous behavior of not loading the
|
|
|
|
# mozconfig for the js configure.
|
|
|
|
# Separately to the immediate problem for js developers, there is also the
|
|
|
|
# need to not load a mozconfig when running js configure as a subconfigure.
|
|
|
|
# Unfortunately, there is no direct way to tell whether the running
|
|
|
|
# configure is the js configure. The indirect way is to look at the
|
|
|
|
# OLD_CONFIGURE path, which points to js/src/old-configure.
|
|
|
|
# I expect we'll have figured things out for mozconfigs well before
|
|
|
|
# old-configure dies.
|
2016-03-11 09:32:55 +03:00
|
|
|
if os.path.dirname(os.path.abspath(old_configure[0])).endswith('/js/src'):
|
2016-03-04 11:31:10 +03:00
|
|
|
return {'path': None}
|
|
|
|
|
2017-03-09 05:50:35 +03:00
|
|
|
topsrcdir = build_env.topsrcdir
|
|
|
|
if external_source_dir:
|
|
|
|
topsrcdir = external_source_dir[0]
|
|
|
|
loader = MozconfigLoader(topsrcdir)
|
2016-03-04 11:31:10 +03:00
|
|
|
current_project = current_project[0] if current_project else None
|
|
|
|
mozconfig = mozconfig[0] if mozconfig else None
|
|
|
|
mozconfig = loader.find_mozconfig(env={'MOZCONFIG': mozconfig})
|
|
|
|
mozconfig = loader.read_mozconfig(mozconfig, moz_build_app=current_project)
|
|
|
|
|
|
|
|
return mozconfig
|
|
|
|
|
2016-07-08 02:43:17 +03:00
|
|
|
set_config('MOZCONFIG', depends(mozconfig)(lambda m: m['path']))
|
|
|
|
|
2016-03-04 11:31:10 +03:00
|
|
|
|
2016-03-04 08:31:08 +03:00
|
|
|
option(env='PYTHON', nargs=1, help='Python interpreter')
|
|
|
|
|
|
|
|
# Setup python virtualenv
|
|
|
|
# ==============================================================
|
2016-04-12 15:32:38 +03:00
|
|
|
@depends('PYTHON', check_build_environment, mozconfig, '--help')
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports('os')
|
|
|
|
@imports('sys')
|
|
|
|
@imports('subprocess')
|
|
|
|
@imports(_from='mozbuild.configure.util', _import='LineIO')
|
|
|
|
@imports(_from='mozbuild.virtualenv', _import='VirtualenvManager')
|
|
|
|
@imports(_from='mozbuild.virtualenv', _import='verify_python_version')
|
|
|
|
@imports('distutils.sysconfig')
|
2016-04-12 15:32:38 +03:00
|
|
|
def virtualenv_python(env_python, build_env, mozconfig, help):
|
|
|
|
if help:
|
|
|
|
return
|
|
|
|
|
2016-03-04 08:31:08 +03:00
|
|
|
python = env_python[0] if env_python else None
|
|
|
|
|
|
|
|
# Ideally we'd rely on the mozconfig injection from mozconfig_options,
|
|
|
|
# but we'd rather avoid the verbosity when we need to reexecute with
|
|
|
|
# a different python.
|
|
|
|
if mozconfig['path']:
|
|
|
|
if 'PYTHON' in mozconfig['env']['added']:
|
|
|
|
python = mozconfig['env']['added']['PYTHON']
|
|
|
|
elif 'PYTHON' in mozconfig['env']['modified']:
|
|
|
|
python = mozconfig['env']['modified']['PYTHON'][1]
|
|
|
|
elif 'PYTHON' in mozconfig['vars']['added']:
|
|
|
|
python = mozconfig['vars']['added']['PYTHON']
|
|
|
|
elif 'PYTHON' in mozconfig['vars']['modified']:
|
|
|
|
python = mozconfig['vars']['modified']['PYTHON'][1]
|
|
|
|
|
2016-03-25 10:37:37 +03:00
|
|
|
with LineIO(lambda l: log.error(l)) as out:
|
|
|
|
verify_python_version(out)
|
2016-03-22 09:46:16 +03:00
|
|
|
topsrcdir, topobjdir = build_env.topsrcdir, build_env.topobjdir
|
2016-03-04 08:31:08 +03:00
|
|
|
if topobjdir.endswith('/js/src'):
|
|
|
|
topobjdir = topobjdir[:-7]
|
|
|
|
|
2016-03-25 10:37:37 +03:00
|
|
|
with LineIO(lambda l: log.info(l)) as out:
|
|
|
|
manager = VirtualenvManager(
|
|
|
|
topsrcdir, topobjdir,
|
|
|
|
os.path.join(topobjdir, '_virtualenv'), out,
|
|
|
|
os.path.join(topsrcdir, 'build', 'virtualenv_packages.txt'))
|
2016-03-04 08:31:08 +03:00
|
|
|
|
|
|
|
if python:
|
|
|
|
# If we're not in the virtualenv, we need the which module for
|
|
|
|
# find_program.
|
|
|
|
if normsep(sys.executable) != normsep(manager.python_path):
|
2017-10-12 16:08:35 +03:00
|
|
|
sys.path.append(os.path.join(topsrcdir, 'third_party', 'python', 'which'))
|
2016-03-04 08:31:08 +03:00
|
|
|
found_python = find_program(python)
|
|
|
|
if not found_python:
|
2016-03-25 09:48:21 +03:00
|
|
|
die('The PYTHON environment variable does not contain '
|
|
|
|
'a valid path. Cannot find %s', python)
|
2016-03-04 08:31:08 +03:00
|
|
|
python = found_python
|
|
|
|
else:
|
|
|
|
python = sys.executable
|
|
|
|
|
|
|
|
if not manager.up_to_date(python):
|
2016-03-25 10:30:42 +03:00
|
|
|
log.info('Creating Python environment')
|
2016-03-04 08:31:08 +03:00
|
|
|
manager.build(python)
|
|
|
|
|
|
|
|
python = normsep(manager.python_path)
|
|
|
|
|
|
|
|
if python != normsep(sys.executable):
|
2016-03-25 10:30:42 +03:00
|
|
|
log.info('Reexecuting in the virtualenv')
|
2016-03-04 08:31:08 +03:00
|
|
|
if env_python:
|
|
|
|
del os.environ['PYTHON']
|
|
|
|
# One would prefer to use os.execl, but that's completely borked on
|
|
|
|
# Windows.
|
|
|
|
sys.exit(subprocess.call([python] + sys.argv))
|
|
|
|
|
|
|
|
# We are now in the virtualenv
|
|
|
|
if not distutils.sysconfig.get_python_lib():
|
2016-03-25 09:48:21 +03:00
|
|
|
die('Could not determine python site packages directory')
|
2016-03-04 08:31:08 +03:00
|
|
|
|
|
|
|
return python
|
|
|
|
|
2016-03-22 08:21:32 +03:00
|
|
|
set_config('PYTHON', virtualenv_python)
|
2016-03-23 10:34:59 +03:00
|
|
|
add_old_configure_assignment('PYTHON', virtualenv_python)
|
2016-03-04 08:31:08 +03:00
|
|
|
|
|
|
|
# Inject mozconfig options
|
|
|
|
# ==============================================================
|
2016-03-15 08:17:23 +03:00
|
|
|
# All options defined above this point can't be injected in mozconfig_options
|
|
|
|
# below, so collect them.
|
|
|
|
@template
|
|
|
|
def early_options():
|
2016-08-09 09:55:10 +03:00
|
|
|
@dependable
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports('__sandbox__')
|
2016-08-09 09:55:10 +03:00
|
|
|
def early_options():
|
2016-03-15 08:17:23 +03:00
|
|
|
return set(
|
|
|
|
option.env
|
2016-03-27 05:40:13 +03:00
|
|
|
for option in __sandbox__._options.itervalues()
|
2016-03-15 08:17:23 +03:00
|
|
|
if option.env
|
|
|
|
)
|
|
|
|
return early_options
|
|
|
|
|
|
|
|
early_options = early_options()
|
|
|
|
|
2016-12-21 10:58:38 +03:00
|
|
|
@depends(mozconfig, 'MOZ_AUTOMATION', '--help')
|
2016-03-27 05:40:13 +03:00
|
|
|
# This gives access to the sandbox. Don't copy this blindly.
|
|
|
|
@imports('__sandbox__')
|
2016-10-14 21:06:30 +03:00
|
|
|
@imports('os')
|
2016-12-21 10:58:38 +03:00
|
|
|
def mozconfig_options(mozconfig, automation, help):
|
2016-03-04 11:31:10 +03:00
|
|
|
if mozconfig['path']:
|
2016-12-21 10:58:38 +03:00
|
|
|
if 'MOZ_AUTOMATION_MOZCONFIG' in mozconfig['env']['added']:
|
|
|
|
if not automation:
|
|
|
|
log.error('%s directly or indirectly includes an in-tree '
|
|
|
|
'mozconfig.', mozconfig['path'])
|
|
|
|
log.error('In-tree mozconfigs make strong assumptions about '
|
2017-01-09 12:12:45 +03:00
|
|
|
'and are only meant to be used by Mozilla '
|
2016-12-21 10:58:38 +03:00
|
|
|
'automation.')
|
|
|
|
die("Please don't use them.")
|
2016-03-27 05:40:13 +03:00
|
|
|
helper = __sandbox__._helper
|
2016-03-25 10:30:42 +03:00
|
|
|
log.info('Adding configure options from %s' % mozconfig['path'])
|
2016-03-04 11:31:10 +03:00
|
|
|
for arg in mozconfig['configure_args']:
|
2016-03-25 10:30:42 +03:00
|
|
|
log.info(' %s' % arg)
|
2016-03-04 11:31:10 +03:00
|
|
|
# We could be using imply_option() here, but it has other
|
|
|
|
# contraints that don't really apply to the command-line
|
|
|
|
# emulation that mozconfig provides.
|
|
|
|
helper.add(arg, origin='mozconfig', args=helper._args)
|
|
|
|
|
2016-03-15 08:17:23 +03:00
|
|
|
def add(key, value):
|
2016-04-14 02:51:09 +03:00
|
|
|
if key.isupper():
|
2016-03-15 08:17:23 +03:00
|
|
|
arg = '%s=%s' % (key, value)
|
2016-03-25 10:30:42 +03:00
|
|
|
log.info(' %s' % arg)
|
2016-03-15 08:17:23 +03:00
|
|
|
helper.add(arg, origin='mozconfig', args=helper._args)
|
|
|
|
|
|
|
|
for key, value in mozconfig['env']['added'].iteritems():
|
|
|
|
add(key, value)
|
2016-10-14 21:06:30 +03:00
|
|
|
os.environ[key] = value
|
2016-03-15 08:17:23 +03:00
|
|
|
for key, (_, value) in mozconfig['env']['modified'].iteritems():
|
|
|
|
add(key, value)
|
2016-10-14 21:06:30 +03:00
|
|
|
os.environ[key] = value
|
2016-03-15 08:17:23 +03:00
|
|
|
for key, value in mozconfig['vars']['added'].iteritems():
|
2017-07-20 08:22:11 +03:00
|
|
|
add(key, value)
|
2016-03-15 08:17:23 +03:00
|
|
|
for key, (_, value) in mozconfig['vars']['modified'].iteritems():
|
|
|
|
add(key, value)
|
|
|
|
|
2016-03-04 11:31:10 +03:00
|
|
|
|
2016-03-11 16:52:40 +03:00
|
|
|
# Mozilla-Build
|
|
|
|
# ==============================================================
|
2016-03-04 11:31:10 +03:00
|
|
|
option(env='MOZILLABUILD', nargs=1,
|
|
|
|
help='Path to Mozilla Build (Windows-only)')
|
2016-03-08 07:49:35 +03:00
|
|
|
|
2016-04-20 04:40:07 +03:00
|
|
|
option(env='CONFIG_SHELL', nargs=1, help='Path to a POSIX shell')
|
|
|
|
|
2016-03-11 16:52:40 +03:00
|
|
|
# It feels dirty replicating this from python/mozbuild/mozbuild/mozconfig.py,
|
|
|
|
# but the end goal being that the configure script would go away...
|
2016-04-20 04:40:07 +03:00
|
|
|
@depends('CONFIG_SHELL', 'MOZILLABUILD')
|
2016-04-07 11:11:44 +03:00
|
|
|
@checking('for a shell')
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports('sys')
|
2016-04-20 04:40:07 +03:00
|
|
|
def shell(value, mozillabuild):
|
|
|
|
if value:
|
|
|
|
return find_program(value[0])
|
2016-03-11 16:52:40 +03:00
|
|
|
shell = 'sh'
|
|
|
|
if mozillabuild:
|
|
|
|
shell = mozillabuild[0] + '/msys/bin/sh'
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
shell = shell + '.exe'
|
2016-04-07 11:11:44 +03:00
|
|
|
return find_program(shell)
|
2016-03-11 16:52:40 +03:00
|
|
|
|
2016-03-08 07:49:35 +03:00
|
|
|
|
2017-07-28 07:19:25 +03:00
|
|
|
# Python 3
|
|
|
|
# ========
|
|
|
|
|
|
|
|
option(env='PYTHON3', nargs=1, help='Python 3 interpreter (3.5 or later)')
|
|
|
|
|
|
|
|
@depends('PYTHON3')
|
|
|
|
@checking('for Python 3',
|
|
|
|
callback=lambda x: '%s (%s)' % (x.path, x.str_version) if x else 'no')
|
|
|
|
@imports(_from='__builtin__', _import='Exception')
|
|
|
|
@imports(_from='mozbuild.pythonutil', _import='find_python3_executable')
|
|
|
|
@imports(_from='mozbuild.pythonutil', _import='python_executable_version')
|
|
|
|
def python3(env_python):
|
|
|
|
python = env_python[0] if env_python else None
|
|
|
|
|
|
|
|
# If Python given by environment variable, it must work.
|
|
|
|
if python:
|
|
|
|
try:
|
|
|
|
version = python_executable_version(python).version
|
|
|
|
except Exception as e:
|
|
|
|
raise FatalCheckError('could not determine version of PYTHON '
|
|
|
|
'(%s): %s' % (python, e))
|
|
|
|
|
|
|
|
if version < (3, 5, 0):
|
|
|
|
raise FatalCheckError('PYTHON3 must point to Python 3.5 or newer; '
|
|
|
|
'%d.%d found' % (version[0], version[1]))
|
|
|
|
else:
|
|
|
|
# Fall back to the search routine.
|
|
|
|
python, version = find_python3_executable(min_version='3.5.0')
|
|
|
|
|
|
|
|
if not python:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# The API returns a bytes whereas everything in configure is unicode.
|
|
|
|
python = python.decode('utf-8')
|
|
|
|
|
|
|
|
return namespace(
|
|
|
|
path=python,
|
|
|
|
version=version,
|
|
|
|
str_version='.'.join(str(v) for v in version),
|
|
|
|
)
|
|
|
|
|
|
|
|
set_config('PYTHON3', depends_if(python3)(lambda p: p.path))
|
|
|
|
set_config('PYTHON3_VERSION', depends_if(python3)(lambda p: p.str_version))
|
|
|
|
|
Bug 1377216 - Discover version control info in configure; r=glandium
For reasons unknown to me, Windows CI is periodically failing to find
the Mercurial binary.
In addition, we've also reimplemented various VCS logic throughout
the build system. There is room to cut down on code complexity by
e.g. recording VCS info in configure instead of determining it
at run-time.
Also, for forensic purposes it is sometimes desirable to know which
VCS tool is in use by a build and which version of that tool is being
used.
This commit adds VCS type detection, binary searching, and version
resolution to configure.
substs now contains VCS_CHECKOUT_TYPE, HG, and GIT, which can be
consulted by downstream consumers.
If the Mercurial or Git versions could not be resolved, all variables
are not set. Otherwise, VCS_CHECKOUT_TYPE and one of HG or GIT is set.
If MOZ_AUTOMATION is set, we require that the VCS info be resolved.
This helps prevents weirdness in automation due to unexpected
environment configuration.
MozReview-Commit-ID: AMLy0Hfx5rD
--HG--
extra : rebase_source : edef9165d32dc47308a14b0fbabce3c1d3d28176
2017-07-19 04:07:29 +03:00
|
|
|
# Source checkout and version control integration.
|
|
|
|
# ================================================
|
|
|
|
|
2017-07-21 01:08:20 +03:00
|
|
|
@depends(check_build_environment, 'MOZ_AUTOMATION', '--help')
|
Bug 1377216 - Discover version control info in configure; r=glandium
For reasons unknown to me, Windows CI is periodically failing to find
the Mercurial binary.
In addition, we've also reimplemented various VCS logic throughout
the build system. There is room to cut down on code complexity by
e.g. recording VCS info in configure instead of determining it
at run-time.
Also, for forensic purposes it is sometimes desirable to know which
VCS tool is in use by a build and which version of that tool is being
used.
This commit adds VCS type detection, binary searching, and version
resolution to configure.
substs now contains VCS_CHECKOUT_TYPE, HG, and GIT, which can be
consulted by downstream consumers.
If the Mercurial or Git versions could not be resolved, all variables
are not set. Otherwise, VCS_CHECKOUT_TYPE and one of HG or GIT is set.
If MOZ_AUTOMATION is set, we require that the VCS info be resolved.
This helps prevents weirdness in automation due to unexpected
environment configuration.
MozReview-Commit-ID: AMLy0Hfx5rD
--HG--
extra : rebase_source : edef9165d32dc47308a14b0fbabce3c1d3d28176
2017-07-19 04:07:29 +03:00
|
|
|
@checking('for vcs source checkout')
|
|
|
|
@imports('os')
|
2017-07-21 01:08:20 +03:00
|
|
|
def vcs_checkout_type(build_env, automation, _):
|
Bug 1377216 - Discover version control info in configure; r=glandium
For reasons unknown to me, Windows CI is periodically failing to find
the Mercurial binary.
In addition, we've also reimplemented various VCS logic throughout
the build system. There is room to cut down on code complexity by
e.g. recording VCS info in configure instead of determining it
at run-time.
Also, for forensic purposes it is sometimes desirable to know which
VCS tool is in use by a build and which version of that tool is being
used.
This commit adds VCS type detection, binary searching, and version
resolution to configure.
substs now contains VCS_CHECKOUT_TYPE, HG, and GIT, which can be
consulted by downstream consumers.
If the Mercurial or Git versions could not be resolved, all variables
are not set. Otherwise, VCS_CHECKOUT_TYPE and one of HG or GIT is set.
If MOZ_AUTOMATION is set, we require that the VCS info be resolved.
This helps prevents weirdness in automation due to unexpected
environment configuration.
MozReview-Commit-ID: AMLy0Hfx5rD
--HG--
extra : rebase_source : edef9165d32dc47308a14b0fbabce3c1d3d28176
2017-07-19 04:07:29 +03:00
|
|
|
if os.path.exists(os.path.join(build_env.topsrcdir, '.hg')):
|
|
|
|
return 'hg'
|
|
|
|
elif os.path.exists(os.path.join(build_env.topsrcdir, '.git')):
|
|
|
|
return 'git'
|
|
|
|
elif automation:
|
|
|
|
raise FatalCheckError('unable to resolve VCS type; must run '
|
|
|
|
'from a source checkout when MOZ_AUTOMATION '
|
|
|
|
'is set')
|
|
|
|
|
|
|
|
# Resolve VCS binary for detected repository type.
|
2017-07-21 09:07:55 +03:00
|
|
|
|
|
|
|
# TODO remove hg.exe once bug 1382940 addresses ambiguous executables case.
|
|
|
|
hg = check_prog('HG', ('hg.exe', 'hg',), allow_missing=True,
|
Bug 1377216 - Discover version control info in configure; r=glandium
For reasons unknown to me, Windows CI is periodically failing to find
the Mercurial binary.
In addition, we've also reimplemented various VCS logic throughout
the build system. There is room to cut down on code complexity by
e.g. recording VCS info in configure instead of determining it
at run-time.
Also, for forensic purposes it is sometimes desirable to know which
VCS tool is in use by a build and which version of that tool is being
used.
This commit adds VCS type detection, binary searching, and version
resolution to configure.
substs now contains VCS_CHECKOUT_TYPE, HG, and GIT, which can be
consulted by downstream consumers.
If the Mercurial or Git versions could not be resolved, all variables
are not set. Otherwise, VCS_CHECKOUT_TYPE and one of HG or GIT is set.
If MOZ_AUTOMATION is set, we require that the VCS info be resolved.
This helps prevents weirdness in automation due to unexpected
environment configuration.
MozReview-Commit-ID: AMLy0Hfx5rD
--HG--
extra : rebase_source : edef9165d32dc47308a14b0fbabce3c1d3d28176
2017-07-19 04:07:29 +03:00
|
|
|
when=depends(vcs_checkout_type)(lambda x: x == 'hg'))
|
|
|
|
git = check_prog('GIT', ('git',), allow_missing=True,
|
|
|
|
when=depends(vcs_checkout_type)(lambda x: x == 'git'))
|
|
|
|
|
|
|
|
@depends_if(hg)
|
|
|
|
@checking('for Mercurial version')
|
|
|
|
@imports('os')
|
|
|
|
@imports('re')
|
|
|
|
def hg_version(hg):
|
|
|
|
# HGPLAIN in Mercurial 1.5+ forces stable output, regardless of set
|
|
|
|
# locale or encoding.
|
|
|
|
env = dict(os.environ)
|
|
|
|
env['HGPLAIN'] = '1'
|
|
|
|
|
|
|
|
out = check_cmd_output(hg, '--version', env=env)
|
|
|
|
|
|
|
|
match = re.search(r'Mercurial Distributed SCM \(version ([^\)]+)', out)
|
|
|
|
|
|
|
|
if not match:
|
2017-10-12 16:08:35 +03:00
|
|
|
raise FatalCheckError('unable to determine Mercurial version: %s' % out)
|
Bug 1377216 - Discover version control info in configure; r=glandium
For reasons unknown to me, Windows CI is periodically failing to find
the Mercurial binary.
In addition, we've also reimplemented various VCS logic throughout
the build system. There is room to cut down on code complexity by
e.g. recording VCS info in configure instead of determining it
at run-time.
Also, for forensic purposes it is sometimes desirable to know which
VCS tool is in use by a build and which version of that tool is being
used.
This commit adds VCS type detection, binary searching, and version
resolution to configure.
substs now contains VCS_CHECKOUT_TYPE, HG, and GIT, which can be
consulted by downstream consumers.
If the Mercurial or Git versions could not be resolved, all variables
are not set. Otherwise, VCS_CHECKOUT_TYPE and one of HG or GIT is set.
If MOZ_AUTOMATION is set, we require that the VCS info be resolved.
This helps prevents weirdness in automation due to unexpected
environment configuration.
MozReview-Commit-ID: AMLy0Hfx5rD
--HG--
extra : rebase_source : edef9165d32dc47308a14b0fbabce3c1d3d28176
2017-07-19 04:07:29 +03:00
|
|
|
|
|
|
|
# The version string may be "unknown" for Mercurial run out of its own
|
|
|
|
# source checkout or for bad builds. But LooseVersion handles it.
|
|
|
|
|
|
|
|
return Version(match.group(1))
|
|
|
|
|
2017-07-28 00:12:35 +03:00
|
|
|
# Resolve Mercurial config items so other checks have easy access.
|
|
|
|
# Do NOT set this in the config because it may contain sensitive data
|
|
|
|
# like API keys.
|
|
|
|
@depends_all(check_build_environment, hg, hg_version)
|
|
|
|
@imports('os')
|
|
|
|
def hg_config(build_env, hg, version):
|
|
|
|
env = dict(os.environ)
|
|
|
|
env['HGPLAIN'] = '1'
|
|
|
|
|
|
|
|
# Warnings may get sent to stderr. But check_cmd_output() ignores
|
|
|
|
# stderr if exit code is 0. And the command should always succeed if
|
|
|
|
# `hg version` worked.
|
|
|
|
out = check_cmd_output(hg, 'config', env=env, cwd=build_env.topsrcdir)
|
|
|
|
|
|
|
|
# out is bytes. However, unicode literals are in effect, so implicit
|
|
|
|
# type coercion can occur. The underlying Mercurial config file may be
|
|
|
|
# in a user-defined encoding. However, HGPLAIN both overrides the decoding
|
|
|
|
# inside Mercurial *and* ensures output is utf-8. Because moz.configure
|
|
|
|
# is using unicode literals, our returned config object uses unicode
|
|
|
|
# keys and values to limit potential for coercion.
|
|
|
|
|
|
|
|
# Mercurial should emit utf-8. But be paranoid and ignore invalid utf-8
|
|
|
|
# byte sequences.
|
|
|
|
out = out.decode('utf-8', 'replace')
|
|
|
|
|
|
|
|
config = {}
|
|
|
|
|
|
|
|
for line in out.strip().splitlines():
|
|
|
|
key, value = [s.strip() for s in line.split('=', 1)]
|
|
|
|
config[key] = value
|
|
|
|
|
|
|
|
return config
|
|
|
|
|
Bug 1377216 - Discover version control info in configure; r=glandium
For reasons unknown to me, Windows CI is periodically failing to find
the Mercurial binary.
In addition, we've also reimplemented various VCS logic throughout
the build system. There is room to cut down on code complexity by
e.g. recording VCS info in configure instead of determining it
at run-time.
Also, for forensic purposes it is sometimes desirable to know which
VCS tool is in use by a build and which version of that tool is being
used.
This commit adds VCS type detection, binary searching, and version
resolution to configure.
substs now contains VCS_CHECKOUT_TYPE, HG, and GIT, which can be
consulted by downstream consumers.
If the Mercurial or Git versions could not be resolved, all variables
are not set. Otherwise, VCS_CHECKOUT_TYPE and one of HG or GIT is set.
If MOZ_AUTOMATION is set, we require that the VCS info be resolved.
This helps prevents weirdness in automation due to unexpected
environment configuration.
MozReview-Commit-ID: AMLy0Hfx5rD
--HG--
extra : rebase_source : edef9165d32dc47308a14b0fbabce3c1d3d28176
2017-07-19 04:07:29 +03:00
|
|
|
@depends_if(git)
|
|
|
|
@checking('for Git version')
|
|
|
|
@imports('re')
|
|
|
|
def git_version(git):
|
|
|
|
out = check_cmd_output(git, '--version').rstrip()
|
|
|
|
|
|
|
|
match = re.search('git version (.*)$', out)
|
|
|
|
|
|
|
|
if not match:
|
|
|
|
raise FatalCheckError('unable to determine Git version: %s' % out)
|
|
|
|
|
|
|
|
return Version(match.group(1))
|
|
|
|
|
|
|
|
# Only set VCS_CHECKOUT_TYPE if we resolved the VCS binary.
|
|
|
|
# Require resolved VCS info when running in automation so automation's
|
|
|
|
# environment is more well-defined.
|
|
|
|
@depends(vcs_checkout_type, hg_version, git_version, 'MOZ_AUTOMATION')
|
|
|
|
def exposed_vcs_checkout_type(vcs_checkout_type, hg, git, automation):
|
|
|
|
if vcs_checkout_type == 'hg':
|
|
|
|
if hg:
|
|
|
|
return 'hg'
|
|
|
|
|
|
|
|
if automation:
|
|
|
|
raise FatalCheckError('could not resolve Mercurial binary info')
|
|
|
|
|
|
|
|
elif vcs_checkout_type == 'git':
|
|
|
|
if git:
|
|
|
|
return 'git'
|
|
|
|
|
|
|
|
if automation:
|
|
|
|
raise FatalCheckError('could not resolve Git binary info')
|
|
|
|
elif vcs_checkout_type:
|
|
|
|
raise FatalCheckError('unhandled VCS type: %s' % vcs_checkout_type)
|
|
|
|
|
|
|
|
set_config('VCS_CHECKOUT_TYPE', exposed_vcs_checkout_type)
|
|
|
|
|
2017-08-23 06:26:46 +03:00
|
|
|
# Obtain a Repository interface for the current VCS repository.
|
|
|
|
@depends(check_build_environment, exposed_vcs_checkout_type, hg, git)
|
|
|
|
@imports(_from='mozversioncontrol', _import='get_repository_object')
|
|
|
|
def vcs_repository(build_env, vcs_checkout_type, hg, git):
|
|
|
|
if vcs_checkout_type == 'hg':
|
|
|
|
return get_repository_object(build_env.topsrcdir, hg=hg)
|
|
|
|
elif vcs_checkout_type == 'git':
|
|
|
|
return get_repository_object(build_env.topsrcdir, git=git)
|
|
|
|
elif vcs_checkout_type:
|
|
|
|
raise FatalCheckError('unhandled VCS type: %s' % vcs_checkout_type)
|
|
|
|
|
|
|
|
@depends_if(vcs_repository)
|
|
|
|
@checking('for sparse checkout')
|
|
|
|
def vcs_sparse_checkout(repo):
|
|
|
|
return repo.sparse_checkout_present()
|
|
|
|
|
|
|
|
set_config('VCS_SPARSE_CHECKOUT', vcs_sparse_checkout)
|
|
|
|
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
# Host and target systems
|
|
|
|
# ==============================================================
|
|
|
|
option('--host', nargs=1, help='Define the system type performing the build')
|
|
|
|
|
|
|
|
option('--target', nargs=1,
|
|
|
|
help='Define the system type where the resulting executables will be '
|
|
|
|
'used')
|
|
|
|
|
2016-04-06 03:56:35 +03:00
|
|
|
@imports(_from='mozbuild.configure.constants', _import='CPU')
|
2016-08-10 05:39:16 +03:00
|
|
|
@imports(_from='mozbuild.configure.constants', _import='CPU_bitness')
|
2016-04-06 03:56:35 +03:00
|
|
|
@imports(_from='mozbuild.configure.constants', _import='Endianness')
|
|
|
|
@imports(_from='mozbuild.configure.constants', _import='Kernel')
|
|
|
|
@imports(_from='mozbuild.configure.constants', _import='OS')
|
2017-10-05 10:10:45 +03:00
|
|
|
@imports(_from='__builtin__', _import='KeyError')
|
|
|
|
@imports(_from='__builtin__', _import='ValueError')
|
|
|
|
def split_triplet(triplet, allow_unknown=False):
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
# The standard triplet is defined as
|
|
|
|
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
|
|
|
# There is also a quartet form:
|
|
|
|
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
|
|
|
# But we can consider the "KERNEL-OPERATING_SYSTEM" as one.
|
|
|
|
cpu, manufacturer, os = triplet.split('-', 2)
|
|
|
|
|
|
|
|
# Autoconf uses config.sub to validate and canonicalize those triplets,
|
|
|
|
# but the granularity of its results has never been satisfying to our
|
|
|
|
# use, so we've had our own, different, canonicalization. We've also
|
|
|
|
# historically not been very consistent with how we use the canonicalized
|
|
|
|
# values. Hopefully, this will help us make things better.
|
|
|
|
# The tests are inherited from our decades-old autoconf-based configure,
|
|
|
|
# which can probably be improved/cleaned up because they are based on a
|
|
|
|
# mix of uname and config.guess output, while we now only use the latter,
|
|
|
|
# which presumably has a cleaner and leaner output. Let's refine later.
|
|
|
|
os = os.replace('/', '_')
|
|
|
|
if 'android' in os:
|
|
|
|
canonical_os = 'Android'
|
|
|
|
canonical_kernel = 'Linux'
|
|
|
|
elif os.startswith('linux'):
|
|
|
|
canonical_os = 'GNU'
|
|
|
|
canonical_kernel = 'Linux'
|
|
|
|
elif os.startswith('kfreebsd') and os.endswith('-gnu'):
|
|
|
|
canonical_os = 'GNU'
|
|
|
|
canonical_kernel = 'kFreeBSD'
|
|
|
|
elif os.startswith('gnu'):
|
|
|
|
canonical_os = canonical_kernel = 'GNU'
|
|
|
|
elif os.startswith('mingw'):
|
|
|
|
canonical_os = canonical_kernel = 'WINNT'
|
|
|
|
elif os.startswith('darwin'):
|
2016-03-16 02:23:31 +03:00
|
|
|
canonical_kernel = 'Darwin'
|
|
|
|
canonical_os = 'OSX'
|
|
|
|
elif os.startswith('ios'):
|
|
|
|
canonical_kernel = 'Darwin'
|
|
|
|
canonical_os = 'iOS'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif os.startswith('dragonfly'):
|
|
|
|
canonical_os = canonical_kernel = 'DragonFly'
|
|
|
|
elif os.startswith('freebsd'):
|
|
|
|
canonical_os = canonical_kernel = 'FreeBSD'
|
|
|
|
elif os.startswith('netbsd'):
|
|
|
|
canonical_os = canonical_kernel = 'NetBSD'
|
|
|
|
elif os.startswith('openbsd'):
|
|
|
|
canonical_os = canonical_kernel = 'OpenBSD'
|
2017-04-11 10:01:32 +03:00
|
|
|
elif os.startswith('solaris'):
|
|
|
|
canonical_os = canonical_kernel = 'SunOS'
|
2017-10-05 10:10:45 +03:00
|
|
|
elif allow_unknown:
|
|
|
|
canonical_os = canonical_kernel = os
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
else:
|
2016-03-25 09:48:21 +03:00
|
|
|
die('Unknown OS: %s' % os)
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
|
|
|
# The CPU granularity is probably not enough. Moving more things from
|
|
|
|
# old-configure will tell us if we need more
|
|
|
|
if cpu.endswith('86') or (cpu.startswith('i') and '86' in cpu):
|
|
|
|
canonical_cpu = 'x86'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'little'
|
|
|
|
elif cpu in ('x86_64', 'ia64'):
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
canonical_cpu = cpu
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'little'
|
|
|
|
elif cpu in ('s390', 's390x'):
|
|
|
|
canonical_cpu = cpu
|
|
|
|
endianness = 'big'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu in ('powerpc64', 'ppc64', 'powerpc64le', 'ppc64le'):
|
|
|
|
canonical_cpu = 'ppc64'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'little' if 'le' in cpu else 'big'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu in ('powerpc', 'ppc', 'rs6000') or cpu.startswith('powerpc'):
|
|
|
|
canonical_cpu = 'ppc'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'big'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu in ('Alpha', 'alpha', 'ALPHA'):
|
|
|
|
canonical_cpu = 'Alpha'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'little'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu.startswith('hppa') or cpu == 'parisc':
|
|
|
|
canonical_cpu = 'hppa'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'big'
|
|
|
|
elif cpu.startswith('sparc64'):
|
|
|
|
canonical_cpu = 'sparc64'
|
|
|
|
endianness = 'big'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu.startswith('sparc') or cpu == 'sun4u':
|
|
|
|
canonical_cpu = 'sparc'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'big'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu.startswith('arm'):
|
|
|
|
canonical_cpu = 'arm'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'big' if cpu.startswith(('armeb', 'armbe')) else 'little'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu in ('mips', 'mipsel'):
|
|
|
|
canonical_cpu = 'mips32'
|
2016-07-21 02:24:45 +03:00
|
|
|
endianness = 'little' if 'el' in cpu else 'big'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu in ('mips64', 'mips64el'):
|
|
|
|
canonical_cpu = 'mips64'
|
2016-07-21 02:24:45 +03:00
|
|
|
endianness = 'little' if 'el' in cpu else 'big'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
elif cpu.startswith('aarch64'):
|
|
|
|
canonical_cpu = 'aarch64'
|
2016-03-30 08:27:40 +03:00
|
|
|
endianness = 'little'
|
2016-12-29 12:50:17 +03:00
|
|
|
elif cpu == 'sh4':
|
|
|
|
canonical_cpu = 'sh4'
|
|
|
|
endianness = 'little'
|
2017-10-05 10:10:45 +03:00
|
|
|
elif allow_unknown:
|
|
|
|
canonical_cpu = cpu
|
|
|
|
endianness = 'unknown'
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
else:
|
2016-04-26 10:27:46 +03:00
|
|
|
die('Unknown CPU type: %s' % cpu)
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2017-10-05 10:10:45 +03:00
|
|
|
def sanitize(cls, value):
|
|
|
|
try:
|
|
|
|
return cls(value)
|
|
|
|
except (KeyError, ValueError):
|
|
|
|
if allow_unknown:
|
|
|
|
return value
|
|
|
|
raise
|
|
|
|
|
|
|
|
def bitness(cpu):
|
|
|
|
return CPU_bitness[cpu]
|
|
|
|
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
return namespace(
|
|
|
|
alias=triplet,
|
2017-10-05 10:10:45 +03:00
|
|
|
cpu=sanitize(CPU, canonical_cpu),
|
|
|
|
bitness=sanitize(bitness, canonical_cpu),
|
|
|
|
kernel=sanitize(Kernel, canonical_kernel),
|
|
|
|
os=sanitize(OS, canonical_os),
|
|
|
|
endianness=sanitize(Endianness, endianness),
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
raw_cpu=cpu,
|
2016-03-15 04:14:09 +03:00
|
|
|
raw_os=os,
|
2016-03-30 08:47:13 +03:00
|
|
|
# Toolchains, most notably for cross compilation may use cpu-os
|
|
|
|
# prefixes.
|
|
|
|
toolchain='%s-%s' % (cpu, os),
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-01-25 11:54:16 +03:00
|
|
|
# This defines a fake target/host namespace for when running with --help
|
|
|
|
@depends('--help')
|
|
|
|
def help_host_target(help):
|
|
|
|
if help:
|
|
|
|
return namespace(
|
|
|
|
alias='unknown-unknown-unknown',
|
|
|
|
cpu='unknown',
|
|
|
|
bitness='unknown',
|
|
|
|
kernel='unknown',
|
|
|
|
os='unknown',
|
|
|
|
endianness='unknown',
|
|
|
|
raw_cpu='unknown',
|
|
|
|
raw_os='unknown',
|
|
|
|
toolchain='unknown-unknown',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports('subprocess')
|
2016-03-18 00:52:50 +03:00
|
|
|
def config_sub(shell, triplet):
|
|
|
|
config_sub = os.path.join(os.path.dirname(__file__), '..',
|
|
|
|
'autoconf', 'config.sub')
|
|
|
|
return subprocess.check_output([shell, config_sub, triplet]).strip()
|
|
|
|
|
|
|
|
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
@depends('--host', shell)
|
2016-03-24 12:37:03 +03:00
|
|
|
@checking('for host system type', lambda h: h.alias)
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports('subprocess')
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
def host(value, shell):
|
|
|
|
if not value:
|
|
|
|
config_guess = os.path.join(os.path.dirname(__file__), '..',
|
|
|
|
'autoconf', 'config.guess')
|
|
|
|
host = subprocess.check_output([shell, config_guess]).strip()
|
|
|
|
else:
|
|
|
|
host = value[0]
|
|
|
|
|
2016-03-18 00:52:50 +03:00
|
|
|
return split_triplet(config_sub(shell, host))
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2017-01-25 11:54:16 +03:00
|
|
|
host = help_host_target | host
|
|
|
|
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2016-03-18 00:52:50 +03:00
|
|
|
@depends('--target', host, shell)
|
2016-03-24 12:37:03 +03:00
|
|
|
@checking('for target system type', lambda t: t.alias)
|
2016-03-18 00:52:50 +03:00
|
|
|
def target(value, host, shell):
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
if not value:
|
|
|
|
return host
|
2016-03-18 00:52:50 +03:00
|
|
|
return split_triplet(config_sub(shell, value[0]))
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2017-01-25 11:54:16 +03:00
|
|
|
target = help_host_target | target
|
|
|
|
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2016-03-30 06:43:21 +03:00
|
|
|
@depends(host, target)
|
|
|
|
@checking('whether cross compiling')
|
|
|
|
def cross_compiling(host, target):
|
|
|
|
return host != target
|
|
|
|
|
|
|
|
set_config('CROSS_COMPILE', cross_compiling)
|
|
|
|
set_define('CROSS_COMPILE', cross_compiling)
|
|
|
|
add_old_configure_assignment('CROSS_COMPILE', cross_compiling)
|
|
|
|
|
|
|
|
|
2016-08-10 05:39:16 +03:00
|
|
|
@depends(target)
|
|
|
|
def have_64_bit(target):
|
|
|
|
if target.bitness == 64:
|
|
|
|
return True
|
|
|
|
|
|
|
|
set_config('HAVE_64BIT_BUILD', have_64_bit)
|
|
|
|
set_define('HAVE_64BIT_BUILD', have_64_bit)
|
|
|
|
add_old_configure_assignment('HAVE_64BIT_BUILD', have_64_bit)
|
|
|
|
|
2017-04-20 09:11:26 +03:00
|
|
|
@depends(host)
|
|
|
|
def host_os_kernel_major_version(host):
|
|
|
|
versions = host.raw_os.split('.')
|
|
|
|
version = ''.join(x for x in versions[0] if x.isdigit())
|
|
|
|
return version
|
|
|
|
|
|
|
|
set_config('HOST_MAJOR_VERSION', host_os_kernel_major_version)
|
2016-08-10 05:39:16 +03:00
|
|
|
|
2016-03-28 01:12:42 +03:00
|
|
|
# Autoconf needs these set
|
|
|
|
@depends(host)
|
|
|
|
def host_for_old_configure(host):
|
|
|
|
return '--host=%s' % host.alias
|
|
|
|
|
|
|
|
add_old_configure_arg(host_for_old_configure)
|
2016-03-16 02:23:31 +03:00
|
|
|
|
2016-11-11 06:52:37 +03:00
|
|
|
@depends(target)
|
|
|
|
def target_for_old_configure(target):
|
2016-03-16 02:23:31 +03:00
|
|
|
target_alias = target.alias
|
|
|
|
# old-configure does plenty of tests against $target and $target_os
|
|
|
|
# and expects darwin for iOS, so make it happy.
|
|
|
|
if target.os == 'iOS':
|
|
|
|
target_alias = target_alias.replace('-ios', '-darwin')
|
2016-03-28 01:12:42 +03:00
|
|
|
return '--target=%s' % target_alias
|
|
|
|
|
|
|
|
add_old_configure_arg(target_for_old_configure)
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
# These variables are for compatibility with the current moz.builds and
|
|
|
|
# old-configure. Eventually, we'll want to canonicalize better.
|
|
|
|
@depends(target)
|
|
|
|
def target_variables(target):
|
|
|
|
if target.kernel == 'kFreeBSD':
|
|
|
|
os_target = 'GNU/kFreeBSD'
|
|
|
|
os_arch = 'GNU_kFreeBSD'
|
2016-03-16 02:23:31 +03:00
|
|
|
elif target.kernel == 'Darwin' or (target.kernel == 'Linux' and
|
|
|
|
target.os == 'GNU'):
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
os_target = target.kernel
|
|
|
|
os_arch = target.kernel
|
|
|
|
else:
|
|
|
|
os_target = target.os
|
|
|
|
os_arch = target.kernel
|
|
|
|
|
2016-04-06 03:56:35 +03:00
|
|
|
if target.kernel == 'Darwin' and target.cpu == 'x86':
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
os_test = 'i386'
|
|
|
|
else:
|
|
|
|
os_test = target.raw_cpu
|
|
|
|
|
2016-03-22 08:21:32 +03:00
|
|
|
return namespace(
|
|
|
|
OS_TARGET=os_target,
|
|
|
|
OS_ARCH=os_arch,
|
|
|
|
OS_TEST=os_test,
|
|
|
|
INTEL_ARCHITECTURE=target.cpu in ('x86', 'x86_64') or None,
|
|
|
|
)
|
|
|
|
|
2017-05-17 10:13:34 +03:00
|
|
|
set_config('OS_TARGET', target_variables.OS_TARGET)
|
2016-03-23 10:34:59 +03:00
|
|
|
add_old_configure_assignment('OS_TARGET',
|
2017-05-17 10:13:34 +03:00
|
|
|
target_variables.OS_TARGET)
|
|
|
|
set_config('OS_ARCH', target_variables.OS_ARCH)
|
2016-03-23 10:34:59 +03:00
|
|
|
add_old_configure_assignment('OS_ARCH',
|
2017-05-17 10:13:34 +03:00
|
|
|
target_variables.OS_ARCH)
|
|
|
|
set_config('OS_TEST', target_variables.OS_TEST)
|
2016-03-23 10:34:59 +03:00
|
|
|
add_old_configure_assignment('OS_TEST',
|
2017-05-17 10:13:34 +03:00
|
|
|
target_variables.OS_TEST)
|
|
|
|
set_config('CPU_ARCH', target.cpu)
|
|
|
|
add_old_configure_assignment('CPU_ARCH', target.cpu)
|
|
|
|
set_config('INTEL_ARCHITECTURE', target_variables.INTEL_ARCHITECTURE)
|
|
|
|
set_config('TARGET_CPU', target.raw_cpu)
|
|
|
|
set_config('TARGET_OS', target.raw_os)
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2016-03-15 04:14:09 +03:00
|
|
|
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
@depends(host)
|
|
|
|
def host_variables(host):
|
|
|
|
if host.kernel == 'kFreeBSD':
|
|
|
|
os_arch = 'GNU_kFreeBSD'
|
|
|
|
else:
|
|
|
|
os_arch = host.kernel
|
2016-03-22 08:21:32 +03:00
|
|
|
return namespace(
|
|
|
|
HOST_OS_ARCH=os_arch,
|
|
|
|
)
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2017-05-17 10:13:34 +03:00
|
|
|
set_config('HOST_CPU_ARCH', host.cpu)
|
|
|
|
set_config('HOST_OS_ARCH', host_variables.HOST_OS_ARCH)
|
2016-03-23 10:34:59 +03:00
|
|
|
add_old_configure_assignment('HOST_OS_ARCH',
|
2017-05-17 10:13:34 +03:00
|
|
|
host_variables.HOST_OS_ARCH)
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
|
2016-03-17 11:13:53 +03:00
|
|
|
@depends(target)
|
2016-03-23 04:22:08 +03:00
|
|
|
def target_is_windows(target):
|
2016-03-17 11:13:53 +03:00
|
|
|
if target.kernel == 'WINNT':
|
2016-03-23 04:22:08 +03:00
|
|
|
return True
|
|
|
|
|
|
|
|
set_define('_WINDOWS', target_is_windows)
|
|
|
|
set_define('WIN32', target_is_windows)
|
|
|
|
set_define('XP_WIN', target_is_windows)
|
|
|
|
set_define('XP_WIN32', target_is_windows)
|
|
|
|
|
|
|
|
@depends(target)
|
|
|
|
def target_is_unix(target):
|
|
|
|
if target.kernel != 'WINNT':
|
|
|
|
return True
|
2016-03-17 11:13:53 +03:00
|
|
|
|
2016-03-23 04:22:08 +03:00
|
|
|
set_define('XP_UNIX', target_is_unix)
|
|
|
|
|
|
|
|
@depends(target)
|
|
|
|
def target_is_darwin(target):
|
2016-03-17 11:13:53 +03:00
|
|
|
if target.kernel == 'Darwin':
|
2016-03-23 04:22:08 +03:00
|
|
|
return True
|
|
|
|
|
|
|
|
set_define('XP_DARWIN', target_is_darwin)
|
|
|
|
|
|
|
|
@depends(target)
|
|
|
|
def target_is_ios(target):
|
|
|
|
if target.kernel == 'Darwin' and target.os == 'iOS':
|
|
|
|
return True
|
|
|
|
|
|
|
|
set_define('XP_IOS', target_is_ios)
|
|
|
|
|
|
|
|
@depends(target)
|
|
|
|
def target_is_osx(target):
|
|
|
|
if target.kernel == 'Darwin' and target.os == 'OSX':
|
|
|
|
return True
|
|
|
|
|
|
|
|
set_define('XP_MACOSX', target_is_osx)
|
|
|
|
|
|
|
|
@depends(target)
|
|
|
|
def target_is_linux(target):
|
|
|
|
if target.kernel == 'Linux':
|
|
|
|
return True
|
2016-03-17 11:13:53 +03:00
|
|
|
|
2016-03-23 04:22:08 +03:00
|
|
|
set_define('XP_LINUX', target_is_linux)
|
2016-03-17 11:13:53 +03:00
|
|
|
|
2017-04-11 10:01:32 +03:00
|
|
|
@depends(target)
|
|
|
|
def target_is_solaris(target):
|
|
|
|
if target.kernel == 'SunOS':
|
|
|
|
return True
|
|
|
|
|
|
|
|
set_define('XP_SOLARIS', target_is_solaris)
|
|
|
|
|
Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester
With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.
Eventually, we'd settle on the output of split_triplet.
This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
2016-03-11 16:57:15 +03:00
|
|
|
# The application/project to build
|
|
|
|
# ==============================================================
|
2016-03-08 07:49:35 +03:00
|
|
|
option('--enable-application', nargs=1, env='MOZ_BUILD_APP',
|
|
|
|
help='Application to build. Same as --enable-project.')
|
|
|
|
|
|
|
|
@depends('--enable-application', '--help')
|
|
|
|
def application(app, help):
|
|
|
|
if app:
|
2016-03-23 08:18:57 +03:00
|
|
|
return app
|
|
|
|
|
|
|
|
imply_option('--enable-project', application)
|
2016-03-08 07:49:35 +03:00
|
|
|
|
|
|
|
|
|
|
|
@depends(check_build_environment, '--help')
|
|
|
|
def default_project(build_env, help):
|
2016-03-22 09:46:16 +03:00
|
|
|
if build_env.topobjdir.endswith('/js/src'):
|
2016-03-08 07:49:35 +03:00
|
|
|
return 'js'
|
|
|
|
return 'browser'
|
|
|
|
|
|
|
|
option('--enable-project', nargs=1, default=default_project,
|
|
|
|
help='Project to build')
|
|
|
|
|
2016-03-10 01:15:01 +03:00
|
|
|
@depends('--enable-project', '--with-external-source-dir',
|
|
|
|
check_build_environment, '--help')
|
2016-11-04 00:50:43 +03:00
|
|
|
@imports(_from='os.path', _import='exists')
|
2016-03-10 01:15:01 +03:00
|
|
|
def include_project_configure(project, external_source_dir, build_env, help):
|
2016-03-08 07:49:35 +03:00
|
|
|
if not project:
|
2016-03-25 09:48:21 +03:00
|
|
|
die('--enable-project is required.')
|
2016-03-08 07:49:35 +03:00
|
|
|
|
2016-03-22 09:46:16 +03:00
|
|
|
base_dir = build_env.topsrcdir
|
2016-03-10 01:15:01 +03:00
|
|
|
if external_source_dir:
|
|
|
|
base_dir = os.path.join(base_dir, external_source_dir[0])
|
|
|
|
|
|
|
|
path = os.path.join(base_dir, project[0], 'moz.configure')
|
2016-11-04 00:50:43 +03:00
|
|
|
if not exists(path):
|
2016-03-25 09:48:21 +03:00
|
|
|
die('Cannot find project %s', project[0])
|
2016-03-08 07:49:35 +03:00
|
|
|
return path
|
|
|
|
|
2016-03-22 08:21:32 +03:00
|
|
|
|
2016-03-10 01:15:01 +03:00
|
|
|
@depends(include_project_configure, check_build_environment, '--help')
|
|
|
|
def build_project(include_project_configure, build_env, help):
|
2016-03-10 02:23:10 +03:00
|
|
|
ret = os.path.dirname(os.path.relpath(include_project_configure,
|
2016-03-22 09:46:16 +03:00
|
|
|
build_env.topsrcdir))
|
2016-03-10 02:23:10 +03:00
|
|
|
return ret
|
2016-03-09 09:59:39 +03:00
|
|
|
|
2016-03-22 08:21:32 +03:00
|
|
|
set_config('MOZ_BUILD_APP', build_project)
|
2016-03-23 04:22:08 +03:00
|
|
|
set_define('MOZ_BUILD_APP', build_project)
|
2016-03-23 10:34:59 +03:00
|
|
|
add_old_configure_assignment('MOZ_BUILD_APP', build_project)
|
2016-03-22 08:21:32 +03:00
|
|
|
|
2016-03-09 09:59:39 +03:00
|
|
|
|
2016-10-08 12:14:49 +03:00
|
|
|
# set RELEASE_OR_BETA and NIGHTLY_BUILD variables depending on the cycle we're in
|
2016-03-18 21:24:11 +03:00
|
|
|
# The logic works like this:
|
|
|
|
# - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
|
|
|
|
# - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
|
2016-10-08 12:14:49 +03:00
|
|
|
# - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
|
2016-04-22 23:01:21 +03:00
|
|
|
@depends(check_build_environment, '--help')
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports(_from='__builtin__', _import='open')
|
2016-04-22 23:01:21 +03:00
|
|
|
def milestone(build_env, _):
|
2016-03-22 09:46:16 +03:00
|
|
|
milestone_path = os.path.join(build_env.topsrcdir,
|
2016-03-18 21:24:11 +03:00
|
|
|
'config',
|
|
|
|
'milestone.txt')
|
|
|
|
with open(milestone_path, 'r') as fh:
|
|
|
|
milestone = fh.read().splitlines()[-1]
|
|
|
|
|
2016-10-08 12:14:49 +03:00
|
|
|
is_nightly = is_release_or_beta = None
|
2016-03-18 21:24:11 +03:00
|
|
|
|
|
|
|
if 'a1' in milestone:
|
|
|
|
is_nightly = True
|
|
|
|
elif 'a' not in milestone:
|
2016-10-08 12:14:49 +03:00
|
|
|
is_release_or_beta = True
|
2016-03-18 21:24:11 +03:00
|
|
|
|
|
|
|
return namespace(version=milestone,
|
|
|
|
is_nightly=is_nightly,
|
2016-10-08 12:14:49 +03:00
|
|
|
is_release_or_beta=is_release_or_beta)
|
2016-03-18 21:24:11 +03:00
|
|
|
|
2017-05-17 10:13:34 +03:00
|
|
|
set_config('GRE_MILESTONE', milestone.version)
|
2017-05-17 11:33:25 +03:00
|
|
|
set_config('NIGHTLY_BUILD', milestone.is_nightly)
|
|
|
|
set_define('NIGHTLY_BUILD', milestone.is_nightly)
|
|
|
|
add_old_configure_assignment('NIGHTLY_BUILD', milestone.is_nightly)
|
2017-05-17 10:13:34 +03:00
|
|
|
set_config('RELEASE_OR_BETA', milestone.is_release_or_beta)
|
|
|
|
set_define('RELEASE_OR_BETA', milestone.is_release_or_beta)
|
2016-10-08 12:14:49 +03:00
|
|
|
add_old_configure_assignment('RELEASE_OR_BETA',
|
2017-05-17 10:13:34 +03:00
|
|
|
milestone.is_release_or_beta)
|
2016-03-22 08:21:32 +03:00
|
|
|
|
2016-05-18 00:40:03 +03:00
|
|
|
# The app update channel is 'default' when not supplied. The value is used in
|
|
|
|
# the application's confvars.sh (and is made available to a project specific
|
|
|
|
# moz.configure).
|
|
|
|
option('--enable-update-channel',
|
|
|
|
nargs=1,
|
|
|
|
help='Select application update channel',
|
|
|
|
default='default')
|
|
|
|
|
|
|
|
@depends('--enable-update-channel')
|
|
|
|
def update_channel(channel):
|
|
|
|
if channel[0] == '':
|
|
|
|
return 'default'
|
|
|
|
return channel[0].lower()
|
|
|
|
|
|
|
|
set_config('MOZ_UPDATE_CHANNEL', update_channel)
|
|
|
|
set_define('MOZ_UPDATE_CHANNEL', update_channel)
|
|
|
|
add_old_configure_assignment('MOZ_UPDATE_CHANNEL', update_channel)
|
|
|
|
|
|
|
|
|
2016-05-12 21:55:58 +03:00
|
|
|
# A template providing a shorthand for setting a variable. The created
|
|
|
|
# option will only be settable with imply_option.
|
|
|
|
# It is expected that a project-specific moz.configure will call imply_option
|
|
|
|
# to set a value other than the default.
|
2016-04-22 23:01:21 +03:00
|
|
|
# If required, the set_as_define and set_for_old_configure arguments
|
|
|
|
# will additionally cause the variable to be set using set_define and
|
|
|
|
# add_old_configure_assignment. util.configure would be an appropriate place for
|
|
|
|
# this, but it uses add_old_configure_assignment, which is defined in this file.
|
|
|
|
@template
|
2016-05-12 21:55:58 +03:00
|
|
|
def project_flag(env=None, set_for_old_configure=False,
|
|
|
|
set_as_define=False, **kwargs):
|
2016-04-22 23:01:21 +03:00
|
|
|
|
|
|
|
if not env:
|
2017-10-12 16:08:35 +03:00
|
|
|
configure_error("A project_flag must be passed a variable name to set.")
|
2016-04-22 23:01:21 +03:00
|
|
|
|
2016-05-12 21:55:58 +03:00
|
|
|
opt = option(env=env, possible_origins=('implied',), **kwargs)
|
2016-04-22 23:01:21 +03:00
|
|
|
|
|
|
|
@depends(opt.option)
|
|
|
|
def option_implementation(value):
|
|
|
|
if value:
|
|
|
|
if len(value):
|
|
|
|
return value
|
|
|
|
return bool(value)
|
|
|
|
|
|
|
|
set_config(env, option_implementation)
|
|
|
|
if set_as_define:
|
|
|
|
set_define(env, option_implementation)
|
|
|
|
if set_for_old_configure:
|
|
|
|
add_old_configure_assignment(env, option_implementation)
|
|
|
|
|
|
|
|
# milestone.is_nightly corresponds to cases NIGHTLY_BUILD is set.
|
|
|
|
@depends(milestone, '--help')
|
|
|
|
def enabled_in_nightly(milestone, _):
|
|
|
|
return milestone.is_nightly
|
2016-03-22 08:21:32 +03:00
|
|
|
|
2016-04-13 05:52:12 +03:00
|
|
|
# Set the MOZ_CONFIGURE_OPTIONS variable with all the options that
|
|
|
|
# were passed somehow (environment, command line, mozconfig)
|
2016-11-11 06:52:37 +03:00
|
|
|
@dependable
|
2016-04-13 05:52:12 +03:00
|
|
|
@imports(_from='mozbuild.shellutil', _import='quote')
|
|
|
|
@imports('__sandbox__')
|
2016-11-11 06:52:37 +03:00
|
|
|
def all_configure_options():
|
2016-04-13 05:52:12 +03:00
|
|
|
result = []
|
|
|
|
previous = None
|
|
|
|
for option in __sandbox__._options.itervalues():
|
|
|
|
# __sandbox__._options contains items for both option.name and
|
|
|
|
# option.env. But it's also an OrderedDict, meaning both are
|
|
|
|
# consecutive.
|
|
|
|
# Also ignore OLD_CONFIGURE and MOZCONFIG because they're not
|
|
|
|
# interesting.
|
|
|
|
if option == previous or option.env in ('OLD_CONFIGURE', 'MOZCONFIG'):
|
|
|
|
continue
|
|
|
|
previous = option
|
|
|
|
value = __sandbox__._value_for(option)
|
|
|
|
# We only want options that were explicitly given on the command
|
|
|
|
# line, the environment, or mozconfig, and that differ from the
|
|
|
|
# defaults.
|
2016-10-21 00:15:38 +03:00
|
|
|
if (value is not None and value.origin not in ('default', 'implied') and
|
2016-04-13 05:52:12 +03:00
|
|
|
value != option.default):
|
|
|
|
result.append(__sandbox__._raw_options[option])
|
|
|
|
# We however always include options that are sent to old configure
|
|
|
|
# because we don't know their actual defaults. (Keep the conditions
|
|
|
|
# separate for ease of understanding and ease of removal)
|
|
|
|
elif (option.help == 'Help missing for old configure options' and
|
|
|
|
option in __sandbox__._raw_options):
|
|
|
|
result.append(__sandbox__._raw_options[option])
|
|
|
|
|
|
|
|
return quote(*result)
|
|
|
|
|
|
|
|
set_config('MOZ_CONFIGURE_OPTIONS', all_configure_options)
|
|
|
|
|
|
|
|
|
2016-03-09 09:59:39 +03:00
|
|
|
# This is temporary until js/src/configure and configure are merged.
|
2016-03-30 08:47:13 +03:00
|
|
|
# Use instead of option() in js/moz.configure and more generally, for
|
|
|
|
# options that are shared between configure and js/src/configure.
|
2016-03-09 09:59:39 +03:00
|
|
|
@template
|
|
|
|
def js_option(*args, **kwargs):
|
|
|
|
opt = option(*args, **kwargs)
|
|
|
|
|
2017-07-26 11:22:47 +03:00
|
|
|
@depends(opt.option, build_project, when=kwargs.get('when'))
|
2016-03-11 16:53:48 +03:00
|
|
|
def js_option(value, build_project):
|
|
|
|
if build_project != 'js':
|
2016-03-28 01:12:42 +03:00
|
|
|
return value.format(opt.option)
|
|
|
|
|
|
|
|
add_old_configure_arg(js_option)
|