Changeset View
Changeset View
Standalone View
Standalone View
libraries/source/spidermonkey/build.sh
#!/bin/sh | #!/bin/sh | ||||
# This script is called by update-workspaces.sh / build-osx-libraries.sh | |||||
set -e | set -e | ||||
# This should match the version in config/milestone.txt | |||||
FOLDER="mozjs-52.9.1pre1" | |||||
# If same-version changes are needed, increment this. | |||||
LIB_VERSION="52.9.1pre1+0" | |||||
LIB_NAME="mozjs52-ps" | |||||
# Since this script is called by update-workspaces.sh, we want to quickly | # Since this script is called by update-workspaces.sh, we want to quickly | ||||
# avoid doing any work if SpiderMonkey is already built and up-to-date. | # avoid doing any work if SpiderMonkey is already built and up-to-date. | ||||
# Running SM's Makefile is a bit slow and noisy, so instead we'll make a | # Running SM's Makefile is a bit slow and noisy, so instead we'll make a | ||||
# special file and only rebuild if it's older than SVN. | # special file and only rebuild if the build.sh version differs. | ||||
# README.txt should be updated whenever we update SM, so use that as | if [ -e .already-built ] && [ "$(cat .already-built)" = "${LIB_VERSION}" ] | ||||
# a time comparison. | |||||
if [ -e .already-built -a .already-built -nt README.txt ] | |||||
then | then | ||||
echo "SpiderMonkey is already up to date" | echo "SpiderMonkey is already up to date" | ||||
exit | exit | ||||
fi | fi | ||||
echo "Building SpiderMonkey..." | echo "Building SpiderMonkey..." | ||||
echo | echo | ||||
# Use Mozilla make on Windows | # Use Mozilla make on Windows | ||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | ||||
then | then | ||||
MAKE="mozmake" | MAKE="mozmake" | ||||
else | else | ||||
MAKE=${MAKE:="make"} | MAKE=${MAKE:="make"} | ||||
fi | fi | ||||
MAKE_OPTS="${JOBS}" | MAKE_OPTS="${JOBS}" | ||||
# jemalloc is outdated on SM45, do not use it | # Standalone SpiderMonkey can not use jemalloc (see https://bugzilla.mozilla.org/show_bug.cgi?id=1465038) | ||||
CONF_OPTS="--disable-tests --disable-jemalloc --enable-shared-js --without-intl-api" | CONF_OPTS="--disable-tests | ||||
--disable-jemalloc | |||||
# Bug 1269319 | --disable-js-shell | ||||
# When compiled with GCC 6 (or later), SpiderMonkey 45 (and versions up to 49) is | --without-intl-api | ||||
# subject to segfaults. Disabling a few optimizations fixes that. | --enable-shared-js" # We're linking statically but JS has quirks with static-only compilation. | ||||
# See also #4053 | |||||
if [ "${OS}" != "Windows_NT" ] | |||||
then | |||||
if [ "`${CXX:=g++} -dumpversion | cut -f1 -d.`" -ge "6" ] | |||||
then | |||||
CXXFLAGS="${CXXFLAGS} -fno-schedule-insns2 -fno-delete-null-pointer-checks" | |||||
fi | |||||
fi | |||||
# Change the default location where the tracelogger should store its output. | |||||
# The default location is . on Windows and /tmp/ on *nix. | |||||
TLCXXFLAGS='-DTRACE_LOG_DIR="\"../../source/tools/tracelogger/\""' | |||||
# NSPR is needed on Windows for POSIX emulation. | # NSPR is needed on Windows for POSIX emulation. | ||||
# If you want to build on Windows, check README.txt and edit the absolute paths | # If you want to build on Windows, check README.txt and edit the absolute paths | ||||
# to match your environment. | # to match your environment. | ||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | ||||
then | then | ||||
NSPR_INCLUDES="-ID:/nspr-4.12/nspr/dist/include/nspr" | CONF_OPTS="${CONF_OPTS} --with-nspr-prefix="D:/nspr-4.21/nspr/"" | ||||
NSPR_LIBS=" \ | |||||
D:/nspr-4.12/nspr/dist/lib/nspr4 \ | |||||
D:/nspr-4.12/nspr/dist/lib/plds4 \ | |||||
D:/nspr-4.12/nspr/dist/lib/plc4" | |||||
else | else | ||||
CONF_OPTS="${CONF_OPTS} --enable-posix-nspr-emulation" | CONF_OPTS="${CONF_OPTS} --enable-posix-nspr-emulation" | ||||
fi | fi | ||||
if [ "`uname -s`" = "Darwin" ] | |||||
then | |||||
# Link to custom-built zlib | |||||
CONF_OPTS="${CONF_OPTS} --with-system-zlib=${ZLIB_DIR}" | |||||
# Specify target versions and SDK | |||||
if [ "${MIN_OSX_VERSION}" ] && [ "${MIN_OSX_VERSION-_}" ]; then | |||||
CONF_OPTS="${CONF_OPTS} --enable-macos-target=$MIN_OSX_VERSION" | |||||
fi | |||||
if [ "${SYSROOT}" ] && [ "${SYSROOT-_}" ]; then | |||||
CONF_OPTS="${CONF_OPTS} --with-macosx-sdk=${SYSROOT}" | |||||
fi | |||||
fi | |||||
# If Valgrind looks like it's installed, then set up SM to support it | # If Valgrind looks like it's installed, then set up SM to support it | ||||
# (else the JITs will interact poorly with it) | # (else the JITs will interact poorly with it) | ||||
if [ -e /usr/include/valgrind/valgrind.h ] | if [ -e /usr/include/valgrind/valgrind.h ] | ||||
then | then | ||||
CONF_OPTS="${CONF_OPTS} --enable-valgrind" | CONF_OPTS="${CONF_OPTS} --enable-valgrind" | ||||
fi | fi | ||||
# We need to be able to override CHOST in case it is 32bit userland on 64bit kernel | # We need to be able to override CHOST in case it is 32bit userland on 64bit kernel | ||||
CONF_OPTS="${CONF_OPTS} \ | CONF_OPTS="${CONF_OPTS} \ | ||||
${CBUILD:+--build=${CBUILD}} \ | ${CBUILD:+--build=${CBUILD}} \ | ||||
${CHOST:+--host=${CHOST}} \ | ${CHOST:+--host=${CHOST}} \ | ||||
${CTARGET:+--target=${CTARGET}}" | ${CTARGET:+--target=${CTARGET}}" | ||||
echo "SpiderMonkey build options: ${CONF_OPTS}" | echo "SpiderMonkey build options: ${CONF_OPTS}" | ||||
echo ${CONF_OPTS} | |||||
FOLDER=mozjs-45.0.2 | |||||
# It can occasionally be useful to not rebuild everything, but don't do this by default. | |||||
REBUILD=true | |||||
if $REBUILD = true; | |||||
then | |||||
# Delete the existing directory to avoid conflicts and extract the tarball | # Delete the existing directory to avoid conflicts and extract the tarball | ||||
rm -rf $FOLDER | rm -rf "$FOLDER" | ||||
tar xjf mozjs-45.0.2.tar.bz2 | if [ ! -e "${FOLDER}.tar.bz2" ]; | ||||
then | |||||
# The tarball is committed to svn, but it's useful to let jenkins download it (when testing upgrade scripts). | |||||
download="$(command -v wget || echo "curl -L -o "${FOLDER}.tar.bz2"")" | |||||
$download "https://github.com/wraitii/spidermonkey-tarballs/releases/download/v52.9.1/${FOLDER}.tar.bz2" | |||||
fi | |||||
tar xjf "${FOLDER}.tar.bz2" | |||||
# Clean up header files that may be left over by earlier versions of SpiderMonkey | # Clean up header files that may be left over by earlier versions of SpiderMonkey | ||||
rm -rf include-unix-* | rm -rf include-unix-debug | ||||
rm -rf include-unix-release | |||||
cd $FOLDER | |||||
# Apply patches | # Apply patches | ||||
cd "$FOLDER" | |||||
. ../patch.sh | . ../patch.sh | ||||
# Prevent complaining that configure is outdated. | |||||
touch ./js/src/configure | |||||
else | |||||
cd "$FOLDER" | |||||
fi | |||||
cd js/src | |||||
# Clean up data generated by previous builds that could cause problems | |||||
rm -rf build-debug | |||||
rm -rf build-release | |||||
# We want separate debug/release versions of the library, so we have to change | |||||
# the LIBRARY_NAME for each build. | |||||
# (We use perl instead of sed so that it works with MozillaBuild on Windows, | |||||
# which has an ancient sed.) | |||||
perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs45-ps-debug'\''/' moz.build | |||||
mkdir -p build-debug | mkdir -p build-debug | ||||
cd build-debug | cd build-debug | ||||
if [ "${OS}" = "Windows_NT" ] | # SM build scripts check for autoconf, but it isn't actually needed, so just pass something. | ||||
then | CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="false" ${CONF_OPTS} \ | ||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | |||||
--with-nspr-cflags="${NSPR_INCLUDES}" --with-nspr-libs="${NSPR_LIBS}" \ | |||||
--enable-debug \ | --enable-debug \ | ||||
--disable-optimize \ | --disable-optimize \ | ||||
--enable-js-diagnostics \ | |||||
--enable-gczeal | --enable-gczeal | ||||
else | |||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | |||||
--enable-debug \ | |||||
--disable-optimize \ | |||||
--enable-js-diagnostics \ | |||||
--enable-gczeal | |||||
fi | |||||
${MAKE} ${MAKE_OPTS} | ${MAKE} ${MAKE_OPTS} | ||||
cd .. | cd .. | ||||
perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs45-ps-release'\''/' moz.build | |||||
mkdir -p build-release | mkdir -p build-release | ||||
cd build-release | cd build-release | ||||
if [ "${OS}" = "Windows_NT" ] | CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="false" ${CONF_OPTS} \ | ||||
then | --enable-optimize | ||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | |||||
--with-nspr-cflags="${NSPR_INCLUDES}" --with-nspr-libs="${NSPR_LIBS}" \ | |||||
--enable-optimize \ | |||||
#--enable-gczeal \ | |||||
#--enable-debug-symbols | |||||
else | |||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | |||||
--enable-optimize \ | |||||
#--enable-gczeal \ | |||||
#--enable-debug-symbols | |||||
fi | |||||
${MAKE} ${MAKE_OPTS} | ${MAKE} ${MAKE_OPTS} | ||||
cd .. | cd ../ | ||||
cd ../../.. | cd ../ | ||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | ||||
then | then | ||||
INCLUDE_DIR_DEBUG=include-win32-debug | INCLUDE_DIR_DEBUG=include-win32-debug | ||||
INCLUDE_DIR_RELEASE=include-win32-release | INCLUDE_DIR_RELEASE=include-win32-release | ||||
DLL_SRC_SUFFIX=.dll | |||||
DLL_DST_SUFFIX=.dll | |||||
LIB_PREFIX= | LIB_PREFIX= | ||||
LIB_SRC_SUFFIX=.lib | LIB_SUFFIX=.lib | ||||
LIB_DST_SUFFIX=.lib | |||||
else | else | ||||
INCLUDE_DIR_DEBUG=include-unix-debug | INCLUDE_DIR_DEBUG=include-unix-debug | ||||
INCLUDE_DIR_RELEASE=include-unix-release | INCLUDE_DIR_RELEASE=include-unix-release | ||||
DLL_SRC_SUFFIX=.so | |||||
DLL_DST_SUFFIX=.so | |||||
LIB_PREFIX=lib | LIB_PREFIX=lib | ||||
LIB_SRC_SUFFIX=.so | LIB_SUFFIX=.a | ||||
LIB_DST_SUFFIX=.so | |||||
if [ "`uname -s`" = "OpenBSD" ] | |||||
then | |||||
DLL_SRC_SUFFIX=.so.1.0 | |||||
DLL_DST_SUFFIX=.so.1.0 | |||||
LIB_SRC_SUFFIX=.so.1.0 | |||||
LIB_DST_SUFFIX=:so.1.0 | |||||
fi | |||||
fi | fi | ||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | ||||
then | then | ||||
# Bug #776126 | # Bug #776126 | ||||
# SpiderMonkey uses a tweaked zlib when building, and it wrongly copies its own files to include dirs | # SpiderMonkey uses a tweaked zlib when building, and it wrongly copies its own files to include dirs | ||||
# afterwards, so we have to remove them to not have them conflicting with the regular zlib | # afterwards, so we have to remove them to not have them conflicting with the regular zlib | ||||
pushd ${FOLDER}/js/src/build-release/dist/include | pushd "${FOLDER}/build-release/dist/include" | ||||
rm mozzconf.h zconf.h zlib.h | rm mozzconf.h zconf.h zlib.h | ||||
popd | popd | ||||
pushd ${FOLDER}/js/src/build-debug/dist/include | pushd "${FOLDER}/build-debug/dist/include" | ||||
rm mozzconf.h zconf.h zlib.h | rm mozzconf.h zconf.h zlib.h | ||||
popd | popd | ||||
fi | fi | ||||
# Copy files into the necessary locations for building and running the game | # Copy files into the necessary locations for building and running the game | ||||
# js-config.h is different for debug and release builds, so we need different include directories for both | # js-config.h is different for debug and release builds, so we need different include directories for both | ||||
mkdir -p ${INCLUDE_DIR_DEBUG} | mkdir -p "${INCLUDE_DIR_DEBUG}" | ||||
mkdir -p ${INCLUDE_DIR_RELEASE} | mkdir -p "${INCLUDE_DIR_RELEASE}" | ||||
cp -R -L ${FOLDER}/js/src/build-release/dist/include/* ${INCLUDE_DIR_RELEASE}/ | cp -R -L "${FOLDER}"/build-release/dist/include/* "${INCLUDE_DIR_RELEASE}/" | ||||
cp -R -L ${FOLDER}/js/src/build-debug/dist/include/* ${INCLUDE_DIR_DEBUG}/ | cp -R -L "${FOLDER}"/build-debug/dist/include/* "${INCLUDE_DIR_DEBUG}/" | ||||
mkdir -p lib/ | mkdir -p lib/ | ||||
cp -L ${FOLDER}/js/src/build-debug/dist/sdk/lib/${LIB_PREFIX}mozjs45-ps-debug${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs45-ps-debug${LIB_DST_SUFFIX} | cp -L "${FOLDER}/build-debug/js/src/${LIB_PREFIX}js_static${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-debug${LIB_SUFFIX}" | ||||
cp -L ${FOLDER}/js/src/build-release/dist/sdk/lib/${LIB_PREFIX}mozjs45-ps-release${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs45-ps-release${LIB_DST_SUFFIX} | cp -L "${FOLDER}/build-release/js/src/${LIB_PREFIX}js_static${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-release${LIB_SUFFIX}" | ||||
cp -L ${FOLDER}/js/src/build-debug/dist/bin/${LIB_PREFIX}mozjs45-ps-debug${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-debug${DLL_DST_SUFFIX} | |||||
cp -L ${FOLDER}/js/src/build-release/dist/bin/${LIB_PREFIX}mozjs45-ps-release${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-release${DLL_DST_SUFFIX} | |||||
# On Windows, also copy debugging symbols files | # On Windows, also copy nspr .DLL and .pdb debug symbols. | ||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | ||||
then | then | ||||
cp -L ${FOLDER}/js/src/build-debug/js/src/${LIB_PREFIX}mozjs45-ps-debug-vc140.pdb ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-debug-vc140.pdb | cp -L "${FOLDER}/build-debug/js/src/${LIB_PREFIX}nspr4.dll" "../../../binaries/system/${LIB_PREFIX}nspr4.dll" | ||||
cp -L ${FOLDER}/js/src/build-release/js/src/${LIB_PREFIX}mozjs45-ps-release-vc140.pdb ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-release-vc140.pdb | cp -L "${FOLDER}/build-debug/js/src/${LIB_PREFIX}plc4.dll" "../../../binaries/system/${LIB_PREFIX}plc4.dll" | ||||
cp -L "${FOLDER}/build-debug/js/src/${LIB_PREFIX}plds4.dll" "../../../binaries/system/${LIB_PREFIX}plds4.dll" | |||||
cp -L "${FOLDER}/build-debug/js/src/${LIB_PREFIX}mozjs-52.pdb" "lib/${LIB_PREFIX}${LIB_NAME}-debug.pdb" | |||||
cp -L "${FOLDER}/build-release/js/src/${LIB_PREFIX}mozjs-52.pdb" "lib/${LIB_PREFIX}${LIB_NAME}-release.pdb" | |||||
fi | fi | ||||
# Flag that it's already been built successfully so we can skip it next time | # Flag that it's already been built successfully so we can skip it next time | ||||
touch .already-built | echo "${LIB_VERSION}" > .already-built |
Wildfire Games · Phabricator