Ticket #2442: 0ad_mozjs24_osx_build_fixes_03092014.patch

File 0ad_mozjs24_osx_build_fixes_03092014.patch, 6.1 KB (added by historic_bruno, 10 years ago)
  • build/premake/extern_libs4.lua

    diff --git a/build/premake/extern_libs4.lua b/build/premake/extern_libs4.lua
    index e6c74eb..674cf67 100644
    a b extern_lib_defs = {  
    571571            else
    572572                if os.is("windows") then
    573573                    include_dir = "include-win32"
    574                 elseif os.is("macosx") then
    575                     include_dir = "include-unix"
    576574                else
    577575                    include_dir = "include-unix"
    578576                end
    extern_lib_defs = {  
    593591                --  pkgconfig_libs("mozjs185")
    594592                --end
    595593            else
     594                if os.is("macosx") then
     595                    add_default_lib_paths("nspr")
     596                    links { "nspr4", "plc4", "plds4" }
     597                end
    596598                configuration "Debug"
    597599                    links { "mozjs24-ps-debug" }
    598600                configuration "Release"
  • libraries/osx/build-osx-libs.sh

    diff --git a/libraries/osx/build-osx-libs.sh b/libraries/osx/build-osx-libs.sh
    index f3a0a2b..cb85759 100755
    a b OGG_VERSION="libogg-1.3.0"  
    3838VORBIS_VERSION="libvorbis-1.3.3"
    3939# gloox is necessary for multiplayer lobby
    4040GLOOX_VERSION="gloox-1.0.9"
     41# NSPR is necessary for threadsafe Spidermonkey
     42NSPR_VERSION="4.10.3"
    4143# --------------------------------------------------------------
    4244# Bundled with the game:
    43 # * SpiderMonkey 1.8.5
     45# * SpiderMonkey 24
    4446# * ENet 1.3.3
    4547# * NVTT
    4648# * FCollada
    else  
    518520fi
    519521popd > /dev/null
    520522
     523# --------------------------------------------------------------
     524echo -e "Building NSPR..."
     525
     526LIB_VERSION="${NSPR_VERSION}"
     527LIB_ARCHIVE="nspr-$LIB_VERSION.tar.gz"
     528LIB_DIRECTORY="nspr-$LIB_VERSION"
     529LIB_URL="https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v$LIB_VERSION/src/"
     530
     531mkdir -p nspr
     532pushd nspr > /dev/null
     533
     534NSPR_DIR="$(pwd)"
     535
     536if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
     537then
     538  rm -f .already-built
     539  download_lib $LIB_URL $LIB_ARCHIVE
     540
     541  rm -rf $LIB_DIRECTORY bin include lib share
     542  tar -xf $LIB_ARCHIVE
     543  pushd $LIB_DIRECTORY/nspr
     544
     545  (CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$NSPR_DIR" && make ${JOBS} && make install) || die "NSPR build failed"
     546  popd
     547  # TODO: how can we not build the dylibs?
     548  rm -f lib/*.dylib
     549  touch .already-built
     550else
     551  already_built
     552fi
     553popd > /dev/null
     554
    521555# --------------------------------------------------------------------
    522556# The following libraries are shared on different OSes and may
    523557# be customzied, so we build and install them from bundled sources
    524558# --------------------------------------------------------------------
    525559echo -e "Building Spidermonkey..."
    526560
    527 LIB_VERSION="js185-1.0.0"
    528 LIB_ARCHIVE="$LIB_VERSION.tar.gz"
    529 LIB_DIRECTORY="js-1.8.5"
     561LIB_VERSION="mozjs-24.2.0"
     562LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
     563LIB_DIRECTORY="mozjs24"
    530564
    531565pushd ../source/spidermonkey/ > /dev/null
    532566
    533567if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
    534568then
    535569  INSTALL_DIR="$(pwd)"
     570  INCLUDE_DIR_DEBUG=$INSTALL_DIR/include-unix-debug
     571  INCLUDE_DIR_RELEASE=$INSTALL_DIR/include-unix-release
    536572
    537573  rm -f .already-built
    538574  rm -f lib/*.a
    539   rm -rf $LIB_DIRECTORY
     575  rm -rf $LIB_DIRECTORY $INCLUDE_DIR_DEBUG $INCLUDE_DIR_RELEASE
    540576  tar -xf $LIB_ARCHIVE
     577  # rename the extracted directory to something shorter
     578  mv $LIB_VERSION $LIB_DIRECTORY
    541579  pushd $LIB_DIRECTORY/js/src
    542580
     581  NSPR_INCLUDES="`${NSPR_DIR}/bin/nspr-config --cflags`"
     582  NSPR_LIBS="`${NSPR_DIR}/bin/nspr-config --libs`"
     583
    543584  # We want separate debug/release versions of the library, so change their install name in the Makefile
    544   sed -i.bak -e 's/\(STATIC_LIBRARY_NAME),mozjs185-\)\(\$(SRCREL_ABI_VERSION)\)\{0,1\}/\1ps-debug/' Makefile.in
     585  perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1mozjs24-ps-debug/' Makefile.in
     586  perl -i.bak -pe 's/js_static/mozjs24-ps-debug/g' shell/Makefile.in
    545587
    546   CONF_OPTS="--prefix=${INSTALL_DIR} --disable-tests --disable-shared-js"
     588  CONF_OPTS="--prefix=${INSTALL_DIR} --enable-threadsafe --disable-tests --disable-shared-js" # --enable-trace-logging"
    547589  # Uncomment this line for 32-bit 10.5 cross compile:
    548590  #CONF_OPTS="$CONF_OPTS --target=i386-apple-darwin9.0.0"
    549591  if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then
    then  
    555597
    556598  mkdir -p build-debug
    557599  pushd build-debug
    558   (CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-debug --disable-optimize && make ${JOBS} && make install) || die "Spidermonkey build failed"
     600  (CC="clang -arch $ARCH" CXX="clang++ -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-debug --disable-optimize --enable-js-diagnostics --enable-gczeal --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" && make ${JOBS}) || die "Spidermonkey build failed"
     601  # js-config.h is different for debug and release builds, so we need different include directories for both
     602  mkdir -p $INCLUDE_DIR_DEBUG
     603  cp -R -L dist/include/* $INCLUDE_DIR_DEBUG/
     604  cp *.a $INSTALL_DIR/lib
    559605  popd
    560606  mv Makefile.in.bak Makefile.in
    561  
    562   sed -i.bak -e 's/\(STATIC_LIBRARY_NAME),mozjs185-\)\(\$(SRCREL_ABI_VERSION)\)\{0,1\}/\1ps-release/' Makefile.in
     607  mv shell/Makefile.in.bak shell/Makefile.in
    563608
     609  perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1mozjs24-ps-release/' Makefile.in
     610  perl -i.bak -pe 's/js_static/mozjs24-ps-release/g' shell/Makefile.in
    564611  mkdir -p build-release
    565612  pushd build-release
    566   (CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS && make ${JOBS} && make install) || die "Spidermonkey build failed"
     613  (CC="clang -arch $ARCH" CXX="clang++ -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-optimize --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" && make ${JOBS}) || die "Spidermonkey build failed"
     614  # js-config.h is different for debug and release builds, so we need different include directories for both
     615  mkdir -p $INCLUDE_DIR_RELEASE
     616  cp -R -L dist/include/* $INCLUDE_DIR_RELEASE/
     617  cp *.a $INSTALL_DIR/lib
    567618  popd
    568619  mv Makefile.in.bak Makefile.in
     620  mv shell/Makefile.in.bak shell/Makefile.in
    569621 
    570622  popd
    571623  touch .already-built