forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1253203 - Move parts of configure.py into sandboxed moz.configure…
…. r=nalexander,r=chmanchester This moves all the reading mozconfig, finding autoconf, refreshing the old configure, and running the old configure into sandboxed moz.configure. This effectively bootstraps the sandboxed python configure.
- Loading branch information
Showing
10 changed files
with
645 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- | ||
# 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') | ||
|
||
option(env='DIST', nargs=1, help='DIST directory') | ||
|
||
# Do not allow objdir == srcdir builds. | ||
# ============================================================== | ||
@depends('--help', 'DIST') | ||
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__), '..', '..'))) | ||
|
||
set_config('TOPSRCDIR', topsrcdir) | ||
set_config('TOPOBJDIR', topobjdir) | ||
set_config('MOZ_BUILD_ROOT', topobjdir) | ||
if dist: | ||
set_config('DIST', normsep(dist[0])) | ||
else: | ||
set_config('DIST', os.path.join(topobjdir, 'dist')) | ||
|
||
if help: | ||
return | ||
|
||
if topsrcdir == topobjdir: | ||
error( | ||
' ***\n' | ||
' * 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' | ||
' ***' | ||
) | ||
|
||
# Check for a couple representative files in the source tree | ||
conflict_files = [ | ||
'* %s' % f for f in ('Makefile', 'config/autoconf.mk') | ||
if os.path.exists(os.path.join(topsrcdir, f)) | ||
] | ||
if conflict_files: | ||
error( | ||
' ***\n' | ||
' * 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) | ||
) | ||
|
||
|
||
option(env='MOZ_CURRENT_PROJECT', nargs=1, help='Current build project') | ||
option(env='MOZCONFIG', nargs=1, help='Mozconfig location') | ||
|
||
# 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. | ||
@depends('MOZ_CURRENT_PROJECT', 'MOZCONFIG', check_build_environment, '--help') | ||
@advanced | ||
def mozconfig(current_project, mozconfig, build_env, help): | ||
from mozbuild.mozconfig import MozconfigLoader | ||
|
||
# Don't read the mozconfig for the js configure (yay backwards | ||
# compatibility) | ||
if build_env['TOPOBJDIR'].endswith('/js/src'): | ||
return {'path': None} | ||
|
||
loader = MozconfigLoader(build_env['TOPSRCDIR']) | ||
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 | ||
|
||
|
||
@template | ||
@advanced | ||
def command_line_helper(): | ||
# This escapes the sandbox. Don't copy this. This is only here because | ||
# it is a one off and because the required functionality doesn't need | ||
# to be exposed for other usecases. | ||
return depends.__self__._helper | ||
|
||
|
||
@depends(mozconfig) | ||
def mozconfig_options(mozconfig): | ||
if mozconfig['path']: | ||
helper = command_line_helper() | ||
warn('Adding configure options from %s' % mozconfig['path']) | ||
for arg in mozconfig['configure_args']: | ||
warn(' %s' % arg) | ||
# 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) | ||
|
||
# Ideally we'd handle mozconfig['env'] and mozconfig['vars'] here, | ||
# but at the moment, moz.configure has no knowledge of the options | ||
# that may appear there. We'll opt-in when we move things from | ||
# old-configure.in, which will be tedious but necessary until we | ||
# can discriminate what old-configure.in supports. | ||
|
||
del command_line_helper | ||
|
||
|
||
option(env='MOZILLABUILD', nargs=1, | ||
help='Path to Mozilla Build (Windows-only)') |
Oops, something went wrong.