Index: build/premake/extern_libs5.lua =================================================================== --- build/premake/extern_libs5.lua +++ build/premake/extern_libs5.lua @@ -43,6 +43,8 @@ if os.istarget("macosx") then pkgconfig.additional_pc_path = libraries_dir .. "pkgconfig/" pkgconfig.static_link_libs = true +elseif not os.istarget("windows") then + pkgconfig.additional_pc_path = libraries_source_dir .. "pkgconfig/" end local function add_delayload(name, suffix, def) @@ -609,17 +611,27 @@ pkgconfig.add_includes("mozjs-78") end else + library_name = "mozjs78-ps" if os.istarget("windows") then include_dir = "include-win32" buildoptions { "/FI\"js/RequiredDefines.h\"" } - else - include_dir = "include-unix" end + filter "Debug" - sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-debug" } + if os.istarget("windows") then + sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-debug" } + else + pkgconfig.add_includes(library_name.."-debug") + end defines { "DEBUG" } + filter "Release" - sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-release" } + if os.istarget("windows") then + sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-release" } + else + pkgconfig.add_includes(library_name.."-release") + end + filter { } end end, @@ -631,18 +643,28 @@ pkgconfig.add_links("mozjs-78") end else - filter { "Debug", "action:vs*" } - links { "mozjs78-ps-debug" } - links { "mozjs78-ps-rust-debug" } - filter { "Debug", "action:not vs*" } - links { "mozjs78-ps-debug" } - links { "mozjs78-ps-rust" } - filter { "Release" } - links { "mozjs78-ps-release" } - links { "mozjs78-ps-rust" } + library_name = "mozjs78-ps" + if os.istarget("windows") then + add_source_lib_paths("spidermonkey") + end + + filter "Debug" + if os.istarget("windows") then + links { library_name.."-debug" } + else + pkgconfig.add_links(library_name.."-debug") + end + + filter "Release" + if os.istarget("windows") then + links { library_name.."-release" } + else + pkgconfig.add_links(library_name.."-release") + end + filter { } - add_source_lib_paths("spidermonkey") end + end, }, tinygettext = { Index: build/workspaces/update-workspaces.sh =================================================================== --- build/workspaces/update-workspaces.sh +++ build/workspaces/update-workspaces.sh @@ -80,11 +80,16 @@ echo "Updating bundled third-party dependencies..." echo + # Create a directory to place pkg-config's .pc files in + # This path must match the one set as pkgconfig.additional_pc_path in extern_libs5.lua + PC_PATH="$(pwd)/../../libraries/source/pkgconfig/" + mkdir -p "${PC_PATH}" + # Build/update bundled external libraries (cd ../../libraries/source/fcollada && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "FCollada build failed" echo if [ "$with_system_mozjs" = "false" ]; then - (cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed" + (cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} PC_DIR=${PC_PATH} ./build.sh) || die "SpiderMonkey build failed" fi echo if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then Index: libraries/osx/build-osx-libs.sh =================================================================== --- libraries/osx/build-osx-libs.sh +++ libraries/osx/build-osx-libs.sh @@ -981,7 +981,7 @@ fi # Use the regular build script for SM. -JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" ./build.sh || die "Error building spidermonkey" +JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" PC_DIR="$PC_PATH" ./build.sh || die "Error building spidermonkey" popd > /dev/null Index: libraries/source/spidermonkey/RemoveShellInstall.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/RemoveShellInstall.diff @@ -0,0 +1,10 @@ +--- a/js/src/Makefile.in ++++ b/js/src/Makefile.in +@@ -118,7 +118,6 @@ + + install:: + $(MAKE) -C build install +- $(MAKE) -C shell install + + ifdef HAVE_DTRACE + javascript-trace.h: $(srcdir)/devtools/javascript-trace.d Index: libraries/source/spidermonkey/build.sh =================================================================== --- libraries/source/spidermonkey/build.sh +++ libraries/source/spidermonkey/build.sh @@ -5,7 +5,7 @@ # This should match the version in config/milestone.txt FOLDER="mozjs-78.6.0" # If same-version changes are needed, increment this. -LIB_VERSION="78.6.0+2" +LIB_VERSION="78.6.0+3" LIB_NAME="mozjs78-ps" # Since this script is called by update-workspaces.sh, we want to quickly @@ -29,6 +29,7 @@ MAKE=${MAKE:="make"} fi +INSTALL_DIR=$(pwd) MAKE_OPTS="${JOBS}" # Standalone SpiderMonkey can not use jemalloc (see https://bugzilla.mozilla.org/show_bug.cgi?id=1465038) @@ -38,6 +39,7 @@ --disable-js-shell --without-intl-api --enable-shared-js + --prefix=${INSTALL_DIR} --disable-jitspew" if [ "${OS}" = "Windows_NT" ] @@ -98,11 +100,26 @@ 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" fi + + echo "Uncompressing archive..." tar xjf "${FOLDER}.tar.bz2" - # Clean up header files that may be left over by earlier versions of SpiderMonkey - rm -rf include-unix-debug - rm -rf include-unix-release + # Clean up files that may be left over by earlier versions of SpiderMonkey + if [ "${OS}" = "Windows_NT" ]; then + rm -rf include-win32-debug + rm -rf include-win32-release + rm -rf lib/ + else + rm -rf include-unix-debug + rm -rf include-unix-release + + # Remove everything except the Windows libs + rm -rf lib/*.so* + rm -rf lib/*.a + rm -rf lib/pkgconfig + fi + rm -rf bin + rm -rf include # Apply patches cd "$FOLDER" @@ -126,7 +143,7 @@ --enable-debug \ --disable-optimize \ --enable-gczeal - ${MAKE} ${MAKE_OPTS} + ${MAKE} ${MAKE_OPTS} && ${MAKE} install cd .. fi @@ -136,97 +153,58 @@ LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ ${CONF_OPTS} \ --enable-optimize -${MAKE} ${MAKE_OPTS} +${MAKE} ${MAKE_OPTS} && ${MAKE} install cd .. cd .. -if [ "${OS}" = "Windows_NT" ] -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 +pyrogenesis_dir="../../../binaries/system/" -if [ "${OS}" = "Windows_NT" ] -then +if [ "${OS}" = "Windows_NT" ]; then # Bug #776126 # 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 - pushd "${FOLDER}/build-release/dist/include" + pushd include/${LIB_NAME}-debug/ rm -f mozzconf.h zconf.h zlib.h popd - pushd "${FOLDER}/build-debug/dist/include" + pushd include/${LIB_NAME}-release/ rm -f mozzconf.h zconf.h zlib.h popd -fi - -# 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 -mkdir -p "${INCLUDE_DIR_RELEASE}" -cp -R -L "${FOLDER}"/build-release/dist/include/* "${INCLUDE_DIR_RELEASE}/" + # Move headers to where extern_libs5.lua can find them + # By having the (version-tracked) windows headers in a separate folder, we don't replace them + # when building on Linux/BSD/OSX, as this might lead to mistakenly committing the replaced headers. + mv include/${LIB_NAME}-debug include-win32-debug + mv include/${LIB_NAME}-release include-win32-release -if [ "$(uname -s)" != "FreeBSD" ]; then - mkdir -p "${INCLUDE_DIR_DEBUG}" - cp -R -L "${FOLDER}"/build-debug/dist/include/* "${INCLUDE_DIR_DEBUG}/" -fi + # Copy DLLs and debug symbols to binaries/system + cp -L lib/*.dll ${pyrogenesis_dir} + cp -L lib/*.pdb ${pyrogenesis_dir} -# These align the ligns below, making it easier to check for mistakes. -DEB="debug" -REL="release" + # Windows need some additional libraries for posix emulation. + cp -L ${FOLDER}/build-release/dist/bin/nspr4.dll ${pyrogenesis_dir} + cp -L ${FOLDER}/build-release/dist/bin/plc4.dll ${pyrogenesis_dir} + cp -L ${FOLDER}/build-release/dist/bin/plds4.dll ${pyrogenesis_dir} -mkdir -p lib/ +else + LIB_SUFFIX=.so + if [ "`uname -s`" = "OpenBSD" ]; then + LIB_SUFFIX=.so.1.0 + fi -# Fetch the jsrust static library. Path is grepped from the build file as it varies by rust toolset. -rust_path=$(grep jsrust < "${FOLDER}/build-release/js/src/build/backend.mk" | cut -d = -f 2 | cut -c2-) -cp -L "${rust_path}" "lib/${LIB_PREFIX}${LIB_NAME}-rust${STATIC_LIB_SUFFIX}" + # Copy the .pc files to somewhere that pkg-config can find them + if [ $PC_DIR ]; then + cp -L lib/pkgconfig/*.pc "${PC_DIR}" + fi -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}" + # 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 + + # Remove a copy of a static library we don't use to save ~650 MiB file space + rm lib/libjs_static.ajs + fi # Flag that it's already been built successfully so we can skip it next time Index: libraries/source/spidermonkey/patch.sh =================================================================== --- libraries/source/spidermonkey/patch.sh +++ libraries/source/spidermonkey/patch.sh @@ -53,3 +53,7 @@ # https://svnweb.freebsd.org/ports/head/lang/spidermonkey78/files/patch-third__party_rust_cc_src_lib.rs?view=log patch -p1 < ../FixFreeBSDRustThirdPartyOSDetection.diff fi + +# We disable the JS-shell via an argument to configure. +# Unfortunately, this doesn't propagate everywhere it needs to. +patch -p1 < ../RemoveShellInstall.diff