Bug 784841 - Part 5: Integrate virtualenv into SpiderMonkey configure; r=glandium

Python and virtualenv logic is now contained within an m4 file.
SpiderMonkey now requires the mozilla-central virtualenv environment to
build. If SpiderMonkey configure is invoked by mozilla-central's
configure, the virtualenv will be reused. If SpiderMonkey configure is
invoked in isolation, it will search for the virtualenv in the
mozilla-central root.
This commit is contained in:
Gregory Szorc 2013-01-16 00:21:06 -08:00
parent 3d39dd9a1a
commit ea0dd7348c
6 changed files with 161 additions and 40 deletions

1
aclocal.m4 vendored
View File

@ -26,6 +26,7 @@ builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/android.m4)dnl
builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/linux.m4)dnl
builtin(include, build/autoconf/python-virtualenv.m4)dnl
MOZ_PROG_CHECKMSYS()

View File

@ -0,0 +1,77 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_PYTHON],
[
dnl We honor the Python path defined in an environment variable. This is used
dnl to pass the virtualenv's Python from the main configure to SpiderMonkey's
dnl configure, for example.
if test -z "$PYTHON"; then
MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
if test -z "$PYTHON"; then
AC_MSG_ERROR([python was not found in \$PATH])
fi
else
AC_MSG_RESULT([Using Python from environment variable \$PYTHON])
fi
_virtualenv_topsrcdir=
_virtualenv_populate_path=
dnl If this is a mozilla-central, we'll find the virtualenv in the top
dnl source directory. If this is a SpiderMonkey build, we assume we're at
dnl js/src and try to find the virtualenv from the mozilla-central root.
for base in $MOZILLA_CENTRAL_PATH $_topsrcdir $_topsrcdir/../..; do
possible=$base/build/virtualenv/populate_virtualenv.py
if test -e $possible; then
_virtualenv_topsrcdir=$base
_virtualenv_populate_path=$possible
break
fi
done
if test -z $_virtualenv_populate_path; then
AC_MSG_ERROR([Unable to find Virtualenv population script. In order
to build, you will need mozilla-central's virtualenv.
If you are building from a mozilla-central checkout, you should never see this
message. If you are building from a source archive, the source archive was
likely not created properly (it is missing the virtualenv files).
If you have a copy of mozilla-central available, define the
MOZILLA_CENTRAL_PATH environment variable to the top source directory of
mozilla-central and relaunch configure.])
fi
if test -z $DONT_POPULATE_VIRTUALENV; then
AC_MSG_RESULT([Creating Python environment])
dnl This verifies our Python version is sane and ensures the Python
dnl virtualenv is present and up to date. It sanitizes the environment
dnl for us, so we don't need to clean anything out.
$PYTHON $_virtualenv_populate_path \
$_virtualenv_topsrcdir $MOZ_BUILD_ROOT/_virtualenv || exit 1
case "$host_os" in
mingw*)
PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe
;;
*)
PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python
;;
esac
fi
AC_SUBST(PYTHON)
AC_MSG_CHECKING([Python environment is Mozilla virtualenv])
$PYTHON -c "import mozbuild.base"
if test "$?" != 0; then
AC_MSG_ERROR([Python environment does not appear to be sane.])
fi
AC_MSG_RESULT([yes])
])

View File

@ -147,29 +147,7 @@ else
touch $_objdir/CLOBBER
fi
MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
if test -z "$PYTHON"; then
AC_MSG_ERROR([python was not found in \$PATH])
fi
AC_MSG_RESULT([Creating Python environment])
dnl This verifies our Python version is sane and ensures the Python
dnl virtualenv is present and up to date. It sanitizes the environment
dnl for us, so we don't need to clean anything out.
$PYTHON $_topsrcdir/build/virtualenv/populate_virtualenv.py \
$_topsrcdir $MOZ_BUILD_ROOT/_virtualenv || exit 1
dnl Create a virtualenv where we can install local Python packages
case "$host_os" in
mingw*)
PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe
;;
*)
PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python
;;
esac
AC_SUBST(PYTHON)
MOZ_PYTHON
MOZ_DEFAULT_COMPILER
@ -9347,6 +9325,9 @@ export MOZ_NATIVE_ZLIB
export MOZ_ZLIB_CFLAGS
export MOZ_ZLIB_LIBS
export MOZ_APP_NAME
export DONT_POPULATE_VIRTUALENV=1
export PYTHON
export MOZILLA_CENTRAL_PATH=$_topsrcdir
export STLPORT_CPPFLAGS
export STLPORT_LDFLAGS
export STLPORT_LIBS

1
js/src/aclocal.m4 vendored
View File

@ -25,5 +25,6 @@ builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/android.m4)dnl
builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/linux.m4)dnl
builtin(include, build/autoconf/python-virtualenv.m4)dnl
MOZ_PROG_CHECKMSYS()

View File

@ -0,0 +1,77 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_PYTHON],
[
dnl We honor the Python path defined in an environment variable. This is used
dnl to pass the virtualenv's Python from the main configure to SpiderMonkey's
dnl configure, for example.
if test -z "$PYTHON"; then
MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
if test -z "$PYTHON"; then
AC_MSG_ERROR([python was not found in \$PATH])
fi
else
AC_MSG_RESULT([Using Python from environment variable \$PYTHON])
fi
_virtualenv_topsrcdir=
_virtualenv_populate_path=
dnl If this is a mozilla-central, we'll find the virtualenv in the top
dnl source directory. If this is a SpiderMonkey build, we assume we're at
dnl js/src and try to find the virtualenv from the mozilla-central root.
for base in $MOZILLA_CENTRAL_PATH $_topsrcdir $_topsrcdir/../..; do
possible=$base/build/virtualenv/populate_virtualenv.py
if test -e $possible; then
_virtualenv_topsrcdir=$base
_virtualenv_populate_path=$possible
break
fi
done
if test -z $_virtualenv_populate_path; then
AC_MSG_ERROR([Unable to find Virtualenv population script. In order
to build, you will need mozilla-central's virtualenv.
If you are building from a mozilla-central checkout, you should never see this
message. If you are building from a source archive, the source archive was
likely not created properly (it is missing the virtualenv files).
If you have a copy of mozilla-central available, define the
MOZILLA_CENTRAL_PATH environment variable to the top source directory of
mozilla-central and relaunch configure.])
fi
if test -z $DONT_POPULATE_VIRTUALENV; then
AC_MSG_RESULT([Creating Python environment])
dnl This verifies our Python version is sane and ensures the Python
dnl virtualenv is present and up to date. It sanitizes the environment
dnl for us, so we don't need to clean anything out.
$PYTHON $_virtualenv_populate_path \
$_virtualenv_topsrcdir $MOZ_BUILD_ROOT/_virtualenv || exit 1
case "$host_os" in
mingw*)
PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe
;;
*)
PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python
;;
esac
fi
AC_SUBST(PYTHON)
AC_MSG_CHECKING([Python environment is Mozilla virtualenv])
$PYTHON -c "import mozbuild.base"
if test "$?" != 0; then
AC_MSG_ERROR([Python environment does not appear to be sane.])
fi
AC_MSG_RESULT([yes])
])

View File

@ -55,7 +55,6 @@ NSPR_VERSION=4
dnl Set the minimum version of toolkit libs used by mozilla
dnl ========================================================
PERL_VERSION=5.006
PYTHON_VERSION=2.7
WINDRES_VERSION=2.14.90
W32API_VERSION=3.14
@ -665,10 +664,7 @@ else
AC_MSG_RESULT([yes])
fi
MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
if test -z "$PYTHON"; then
AC_MSG_ERROR([python was not found in \$PATH])
fi
MOZ_PYTHON
if test -z "$COMPILE_ENVIRONMENT"; then
NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
@ -1463,17 +1459,6 @@ case "$host" in
;;
esac
dnl We require version 2.7 of Python to build.
AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION but not 3.x])
changequote(,)
$PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
_python_res=$?
changequote([,])
if test "$_python_res" != 0; then
AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
fi
AC_MSG_RESULT([yes])
dnl Check for using a custom <stdint.h> implementation
dnl ========================================================
AC_MSG_CHECKING(for custom <stdint.h> implementation)
@ -4268,7 +4253,6 @@ dnl win32 options
AC_SUBST(MOZ_MAPINFO)
AC_SUBST(MOZ_BROWSE_INFO)
AC_SUBST(MOZ_TOOLS_DIR)
AC_SUBST(PYTHON)
dnl Echo the CFLAGS to remove extra whitespace.
CFLAGS=`echo \