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 | # 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 | # This should match the version in config/milestone.txt | ||||
FOLDER="mozjs-78.6.0" | FOLDER="mozjs-78.6.0" | ||||
# If same-version changes are needed, increment this. | # If same-version changes are needed, increment this. | ||||
LIB_VERSION="78.6.0+2" | LIB_VERSION="78.6.0+3" | ||||
LIB_NAME="mozjs78-ps" | LIB_NAME="mozjs78-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 the build.sh version differs. | # special file and only rebuild if the build.sh version differs. | ||||
if [ -e .already-built ] && [ "$(cat .already-built)" = "${LIB_VERSION}" ] | if [ -e .already-built ] && [ "$(cat .already-built)" = "${LIB_VERSION}" ] | ||||
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" | ||||
INSTALL_DIR="../../win32/spidermonkey" | |||||
else | else | ||||
MAKE=${MAKE:="make"} | MAKE=${MAKE:="make"} | ||||
INSTALL_DIR=$(pwd) | |||||
fi | fi | ||||
MAKE_OPTS="${JOBS}" | MAKE_OPTS="${JOBS}" | ||||
# Standalone SpiderMonkey can not use jemalloc (see https://bugzilla.mozilla.org/show_bug.cgi?id=1465038) | # Standalone SpiderMonkey can not use jemalloc (see https://bugzilla.mozilla.org/show_bug.cgi?id=1465038) | ||||
# Jitspew doesn't compile on VS17 in the zydis disassembler - since we don't use it, deactivate it. | # Jitspew doesn't compile on VS17 in the zydis disassembler - since we don't use it, deactivate it. | ||||
CONF_OPTS="--disable-tests | CONF_OPTS="--disable-tests | ||||
--disable-jemalloc | --disable-jemalloc | ||||
--disable-js-shell | --disable-js-shell | ||||
--without-intl-api | --without-intl-api | ||||
--enable-shared-js | --enable-shared-js | ||||
--prefix=${INSTALL_DIR} | |||||
--disable-jitspew" | --disable-jitspew" | ||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | ||||
then | then | ||||
CONF_OPTS="${CONF_OPTS} --with-visual-studio-version=2017 --target=i686" | CONF_OPTS="${CONF_OPTS} --with-visual-studio-version=2017 --target=i686" | ||||
else | else | ||||
CONF_OPTS="${CONF_OPTS}" | CONF_OPTS="${CONF_OPTS}" | ||||
fi | fi | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | 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" | ||||
if [ ! -e "${FOLDER}.tar.bz2" ]; | if [ ! -e "${FOLDER}.tar.bz2" ]; | ||||
then | then | ||||
# The tarball is committed to svn, but it's useful to let jenkins download it (when testing upgrade scripts). | # 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="$(command -v wget || echo "curl -L -o "${FOLDER}.tar.bz2"")" | ||||
$download "https://github.com/wraitii/spidermonkey-tarballs/releases/download/v78.6.0/${FOLDER}.tar.bz2" | $download "https://github.com/wraitii/spidermonkey-tarballs/releases/download/v78.6.0/${FOLDER}.tar.bz2" | ||||
fi | fi | ||||
echo "Uncompressing archive..." | |||||
tar xjf "${FOLDER}.tar.bz2" | 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-debug | rm -rf include-unix-debug | ||||
rm -rf include-unix-release | rm -rf include-unix-release | ||||
rm -rf bin | |||||
rm -rf include | |||||
rm -rf lib | |||||
# Apply patches | # Apply patches | ||||
cd "$FOLDER" | cd "$FOLDER" | ||||
. ../patch.sh | . ../patch.sh | ||||
# Prevent complaining that configure is outdated. | # Prevent complaining that configure is outdated. | ||||
touch ./js/src/configure | touch ./js/src/configure | ||||
else | else | ||||
cd "$FOLDER" | cd "$FOLDER" | ||||
fi | fi | ||||
# Debug version of SM is broken on FreeBSD. | # Debug version of SM is broken on FreeBSD. | ||||
if [ "$(uname -s)" != "FreeBSD" ]; then | if [ "$(uname -s)" != "FreeBSD" ]; then | ||||
mkdir -p build-debug | mkdir -p build-debug | ||||
cd build-debug | cd build-debug | ||||
# SM configure checks for autoconf, but we don't actually need it. | # SM configure checks for autoconf, but we don't actually need it. | ||||
# To avoid a dependency, pass something arbitrary (it does need to be an actual program). | # To avoid a dependency, pass something arbitrary (it does need to be an actual program). | ||||
# llvm-objdump is searched for with the complete name, not simply 'objdump', account for that. | # llvm-objdump is searched for with the complete name, not simply 'objdump', account for that. | ||||
CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="ls" \ | CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="ls" \ | ||||
LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ | LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ | ||||
${CONF_OPTS} \ | ${CONF_OPTS} \ | ||||
--enable-debug \ | --enable-debug \ | ||||
--disable-optimize \ | --disable-optimize \ | ||||
--enable-gczeal | --enable-gczeal | ||||
${MAKE} ${MAKE_OPTS} | ${MAKE} ${MAKE_OPTS} && ${MAKE} install | ||||
cd .. | cd .. | ||||
fi | fi | ||||
mkdir -p build-release | mkdir -p build-release | ||||
cd build-release | cd build-release | ||||
CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="ls" \ | CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="ls" \ | ||||
LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ | LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ | ||||
${CONF_OPTS} \ | ${CONF_OPTS} \ | ||||
--enable-optimize | --enable-optimize | ||||
${MAKE} ${MAKE_OPTS} | ${MAKE} ${MAKE_OPTS} && ${MAKE} install | ||||
cd .. | cd .. | ||||
cd .. | cd .. | ||||
if [ "${OS}" = "Windows_NT" ] | pyrogenesis_dir="../../../binaries/system/" | ||||
then | |||||
INCLUDE_DIR_DEBUG=include-win32-debug | |||||
INCLUDE_DIR_RELEASE=include-win32-release | |||||
LIB_PREFIX= | |||||
LIB_SUFFIX=.dll | |||||
STATIC_LIB_SUFFIX=.lib | |||||
else | |||||
INCLUDE_DIR_DEBUG=include-unix-debug | |||||
INCLUDE_DIR_RELEASE=include-unix-release | |||||
LIB_PREFIX=lib | |||||
LIB_SUFFIX=.so | |||||
STATIC_LIB_SUFFIX=.a | |||||
if [ "`uname -s`" = "OpenBSD" ]; | |||||
then | |||||
LIB_SUFFIX=.so.1.0 | |||||
elif [ "`uname -s`" = "Darwin" ]; | |||||
then | |||||
LIB_SUFFIX=.a | |||||
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}/build-release/dist/include" | pushd "${INSTALL_DIR}/include/include-win32-release/" | ||||
rm -f mozzconf.h zconf.h zlib.h | rm -f mozzconf.h zconf.h zlib.h | ||||
popd | popd | ||||
pushd "${FOLDER}/build-debug/dist/include" | pushd "${INSTALL_DIR}/include/include-win32-debug/" | ||||
rm -f mozzconf.h zconf.h zlib.h | rm -f mozzconf.h zconf.h zlib.h | ||||
popd | popd | ||||
fi | |||||
# Copy files into the necessary locations for building and running the game | # Copy DLLs and debug symbols to binaries/system | ||||
cp -L ${INSTALL_DIR}/lib/*.dll ${pyrogenesis_dir} | |||||
cp -L ${INSTALL_DIR}/lib/*.pdb ${pyrogenesis_dir} | |||||
# js-config.h is different for debug and release builds, so we need different include directories for both | # Windows need some additional libraries for posix emulation. | ||||
mkdir -p "${INCLUDE_DIR_RELEASE}" | cp -L ${FOLDER}/build-release/dist/bin/nspr4.dll ${pyrogenesis_dir} | ||||
cp -R -L "${FOLDER}"/build-release/dist/include/* "${INCLUDE_DIR_RELEASE}/" | cp -L ${FOLDER}/build-release/dist/bin/plc4.dll ${pyrogenesis_dir} | ||||
cp -L ${FOLDER}/build-release/dist/bin/plds4.dll ${pyrogenesis_dir} | |||||
if [ "$(uname -s)" != "FreeBSD" ]; then | else | ||||
mkdir -p "${INCLUDE_DIR_DEBUG}" | LIB_SUFFIX=.so | ||||
cp -R -L "${FOLDER}"/build-debug/dist/include/* "${INCLUDE_DIR_DEBUG}/" | if [ "`uname -s`" = "OpenBSD" ]; then | ||||
LIB_SUFFIX=.so.1.0 | |||||
fi | fi | ||||
# These align the ligns below, making it easier to check for mistakes. | # Copy the .pc files to somewhere that pkg-config can find them | ||||
DEB="debug" | cp -L lib/pkgconfig/*.pc $PC_DIR | ||||
REL="release" | |||||
mkdir -p lib/ | # Create hard links of shared libraries so as to save space, but still allow bundling to be possible (in theory) | ||||
if [ "`uname -s`" != "Darwin" ]; then | |||||
ln -f lib/*${LIB_SUFFIX} ${pyrogenesis_dir} | |||||
fi | |||||
# Fetch the jsrust static library. Path is grepped from the build file as it varies by rust toolset. | # Remove a copy of a static library we don't use to save ~650 MiB file space | ||||
rust_path=$(grep jsrust < "${FOLDER}/build-release/js/src/build/backend.mk" | cut -d = -f 2 | cut -c2-) | rm lib/libjs_static.ajs | ||||
cp -L "${rust_path}" "lib/${LIB_PREFIX}${LIB_NAME}-rust${STATIC_LIB_SUFFIX}" | |||||
if [ "`uname -s`" = "Darwin" ] | |||||
then | |||||
# On MacOS, copy the static libraries only. | |||||
cp -L "${FOLDER}/build-${DEB}/js/src/build/${LIB_PREFIX}js_static${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-${DEB}${LIB_SUFFIX}" | |||||
cp -L "${FOLDER}/build-${REL}/js/src/build/${LIB_PREFIX}js_static${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-${REL}${LIB_SUFFIX}" | |||||
elif [ "${OS}" = "Windows_NT" ] | |||||
then | |||||
# Windows needs DLLs to binaries/, static stubs to lib/ and debug symbols | |||||
cp -L "${FOLDER}/build-${DEB}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${DEB}${LIB_SUFFIX}" "../../../binaries/system/${LIB_PREFIX}${LIB_NAME}-${DEB}${LIB_SUFFIX}" | |||||
cp -L "${FOLDER}/build-${REL}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${REL}${LIB_SUFFIX}" "../../../binaries/system/${LIB_PREFIX}${LIB_NAME}-${REL}${LIB_SUFFIX}" | |||||
cp -L "${FOLDER}/build-${DEB}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${DEB}${STATIC_LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-${DEB}${STATIC_LIB_SUFFIX}" | |||||
cp -L "${FOLDER}/build-${REL}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${REL}${STATIC_LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-${REL}${STATIC_LIB_SUFFIX}" | |||||
# Copy debug symbols as well. | |||||
cp -L "${FOLDER}/build-${DEB}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${DEB}.pdb" "../../../binaries/system/${LIB_PREFIX}${LIB_NAME}-${DEB}.pdb" | |||||
cp -L "${FOLDER}/build-${REL}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${REL}.pdb" "../../../binaries/system/${LIB_PREFIX}${LIB_NAME}-${REL}.pdb" | |||||
# Copy the debug jsrust library. | |||||
rust_path=$(grep jsrust < "${FOLDER}/build-debug/js/src/build/backend.mk" | cut -d = -f 2 | cut -c2-) | |||||
cp -L "${rust_path}" "lib/${LIB_PREFIX}${LIB_NAME}-rust-debug${STATIC_LIB_SUFFIX}" | |||||
# Windows need some additional libraries for posix emulation. | |||||
cp -L "${FOLDER}/build-release/dist/bin/${LIB_PREFIX}nspr4.dll" "../../../binaries/system/${LIB_PREFIX}nspr4.dll" | |||||
cp -L "${FOLDER}/build-release/dist/bin/${LIB_PREFIX}plc4.dll" "../../../binaries/system/${LIB_PREFIX}plc4.dll" | |||||
cp -L "${FOLDER}/build-release/dist/bin/${LIB_PREFIX}plds4.dll" "../../../binaries/system/${LIB_PREFIX}plds4.dll" | |||||
else | |||||
# Copy shared libs to both lib/ and binaries/ so the compiler and executable (resp.) can find them. | |||||
cp -L "${FOLDER}/build-${REL}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${REL}${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-${REL}${LIB_SUFFIX}" | |||||
cp -L "${FOLDER}/build-${REL}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${REL}${LIB_SUFFIX}" "../../../binaries/system/${LIB_PREFIX}${LIB_NAME}-${REL}${LIB_SUFFIX}" | |||||
if [ "$(uname -s)" != "FreeBSD" ]; then | |||||
cp -L "${FOLDER}/build-${DEB}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${DEB}${LIB_SUFFIX}" "../../../binaries/system/${LIB_PREFIX}${LIB_NAME}-${DEB}${LIB_SUFFIX}" | |||||
cp -L "${FOLDER}/build-${DEB}/js/src/build/${LIB_PREFIX}${LIB_NAME}-${DEB}${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-${DEB}${LIB_SUFFIX}" | |||||
fi | |||||
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 | ||||
echo "${LIB_VERSION}" > .already-built | echo "${LIB_VERSION}" > .already-built |
Wildfire Games · Phabricator