From abdda508922b373c0a9dab01fba7cddc29e08f53 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sun, 25 Aug 2024 11:55:44 +0200 Subject: [PATCH] Format shell scripts using shfmt This updates shell scripts to use a consistent style that can be enforced via pre-commit hook. As for choosing tabs over spaces, some arguments are: - tabs can help people with visual impairment - tabs allow for indenting heredocs in bash - tabs are the default for the tool shfmt Signed-off-by: Ralph Sennhauser --- build/android/setup-libs.sh | 169 ++- build/coverage/gen.sh | 28 +- build/premake/.already-built | 1 + build/premake/build.sh | 27 +- build/resources/0ad.sh | 10 +- build/workspaces/update-workspaces.sh | 80 +- libraries/build-macos-libs.sh | 1119 ++++++++--------- libraries/build-source-libs.sh | 93 +- libraries/clean-source-libs.sh | 4 +- source/tools/dist/build-archives.sh | 25 +- source/tools/dist/build-osx-executable.sh | 22 +- source/tools/dist/build-unix-win32.sh | 6 +- source/tools/i18n/get-nightly-translations.sh | 2 +- source/tools/spirv/get-nightly-shaders.sh | 2 +- .../tools/templatessorter/templatessorter.sh | 5 +- .../tools/tracelogger/tracelogger_options.sh | 11 +- 16 files changed, 788 insertions(+), 816 deletions(-) create mode 100644 build/premake/.already-built diff --git a/build/android/setup-libs.sh b/build/android/setup-libs.sh index bf8c049402..da9c438db7 100755 --- a/build/android/setup-libs.sh +++ b/build/android/setup-libs.sh @@ -28,143 +28,142 @@ mkdir -p files pushd files if [ ! -e boost_1_45_0.tar.bz2 ]; then - wget http://downloads.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.bz2 + wget http://downloads.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.bz2 fi if [ ! -e curl-7.33.0.tar.bz2 ]; then - wget http://curl.haxx.se/download/curl-7.33.0.tar.bz2 + wget http://curl.haxx.se/download/curl-7.33.0.tar.bz2 fi if [ ! -e MysticTreeGames-Boost-for-Android-70838fc.tar.gz ]; then - wget https://github.com/MysticTreeGames/Boost-for-Android/tarball/70838fcfba930646cac724a77f5c626e930431f6 -O MysticTreeGames-Boost-for-Android-70838fc.tar.gz + wget https://github.com/MysticTreeGames/Boost-for-Android/tarball/70838fcfba930646cac724a77f5c626e930431f6 -O MysticTreeGames-Boost-for-Android-70838fc.tar.gz fi if [ ! -e enet-1.3.3.tar.gz ]; then - wget http://enet.bespin.org/download/enet-1.3.3.tar.gz + wget http://enet.bespin.org/download/enet-1.3.3.tar.gz fi if [ ! -e js185-1.0.0.tar.gz ]; then - cp ../../../libraries/source/spidermonkey/js185-1.0.0.tar.gz . + cp ../../../libraries/source/spidermonkey/js185-1.0.0.tar.gz . fi if [ ! -e libjpeg-turbo-1.3.0.tar.gz ]; then - wget http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz + wget http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz fi if [ ! -e libpng-1.5.8.tar.xz ]; then - wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.8.tar.xz + wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.8.tar.xz fi if [ ! -e libxml2-2.7.8.tar.gz ]; then - wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz + wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz fi popd - if [ "$build_toolchain" = "true" ]; then - rm -r $TOOLCHAIN || true - $NDK/build/tools/make-standalone-toolchain.sh --platform=android-14 --toolchain=arm-linux-androideabi-4.6 --install-dir=$TOOLCHAIN --system=linux-x86_64 + rm -r $TOOLCHAIN || true + $NDK/build/tools/make-standalone-toolchain.sh --platform=android-14 --toolchain=arm-linux-androideabi-4.6 --install-dir=$TOOLCHAIN --system=linux-x86_64 - mkdir -p $SYSROOT/usr/local + mkdir -p $SYSROOT/usr/local - # Set up some symlinks to make the SpiderMonkey build system happy - ln -sfT ../platforms $NDK/build/platforms - for f in $TOOLCHAIN/bin/arm-linux-androideabi-*; do - ln -sf $f ${f/arm-linux-androideabi-/arm-eabi-} - done + # Set up some symlinks to make the SpiderMonkey build system happy + ln -sfT ../platforms $NDK/build/platforms + for f in $TOOLCHAIN/bin/arm-linux-androideabi-*; do + ln -sf $f ${f/arm-linux-androideabi-/arm-eabi-} + done - # Set up some symlinks for the typical autoconf-based build systems - for f in $TOOLCHAIN/bin/arm-linux-androideabi-*; do - ln -sf $f ${f/arm-linux-androideabi-/arm-linux-eabi-} - done + # Set up some symlinks for the typical autoconf-based build systems + for f in $TOOLCHAIN/bin/arm-linux-androideabi-*; do + ln -sf $f ${f/arm-linux-androideabi-/arm-linux-eabi-} + done fi mkdir -p temp if [ "$build_boost" = "true" ]; then - rm -rf temp/MysticTreeGames-Boost-for-Android-70838fc - tar xvf files/MysticTreeGames-Boost-for-Android-70838fc.tar.gz -C temp/ - cp files/boost_1_45_0.tar.bz2 temp/MysticTreeGames-Boost-for-Android-70838fc/ - patch temp/MysticTreeGames-Boost-for-Android-70838fc/build-android.sh < boost-android-build.patch - pushd temp/MysticTreeGames-Boost-for-Android-70838fc - ./build-android.sh $TOOLCHAIN - cp -rv build/{include,lib} $SYSROOT/usr/local/ - popd + rm -rf temp/MysticTreeGames-Boost-for-Android-70838fc + tar xvf files/MysticTreeGames-Boost-for-Android-70838fc.tar.gz -C temp/ + cp files/boost_1_45_0.tar.bz2 temp/MysticTreeGames-Boost-for-Android-70838fc/ + patch temp/MysticTreeGames-Boost-for-Android-70838fc/build-android.sh .already-built +echo "${LIB_VERSION}" >.already-built diff --git a/build/resources/0ad.sh b/build/resources/0ad.sh index 944f8c364f..5d2f0dde91 100755 --- a/build/resources/0ad.sh +++ b/build/resources/0ad.sh @@ -1,9 +1,9 @@ #!/bin/sh -pyrogenesis=$(which pyrogenesis 2> /dev/null) -if [ -x "$pyrogenesis" ] ; then - "$pyrogenesis" "$@" +pyrogenesis=$(which pyrogenesis 2>/dev/null) +if [ -x "$pyrogenesis" ]; then + "$pyrogenesis" "$@" else - echo "Error: pyrogenesis not found in ($PATH)" - exit 1 + echo "Error: pyrogenesis not found in ($PATH)" + exit 1 fi diff --git a/build/workspaces/update-workspaces.sh b/build/workspaces/update-workspaces.sh index 96d123467a..54a26bd8d0 100755 --- a/build/workspaces/update-workspaces.sh +++ b/build/workspaces/update-workspaces.sh @@ -1,14 +1,14 @@ #!/bin/sh if [ "$(id -u)" = "0" ]; then - echo "Running as root will mess up file permissions. Aborting ..." 1>&2 - exit 1 + echo "Running as root will mess up file permissions. Aborting ..." 1>&2 + exit 1 fi die() { - echo ERROR: $* - exit 1 + echo ERROR: $* + exit 1 } OS=${OS:="$(uname -s)"} @@ -16,12 +16,12 @@ OS=${OS:="$(uname -s)"} # Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE # is not set. case "$OS" in - "FreeBSD" | "OpenBSD" ) - MAKE=${MAKE:="gmake"} - ;; - * ) - MAKE=${MAKE:="make"} - ;; + "FreeBSD" | "OpenBSD") + MAKE=${MAKE:="gmake"} + ;; + *) + MAKE=${MAKE:="make"} + ;; esac cd "$(dirname $0)" @@ -35,37 +35,35 @@ enable_atlas=true JOBS=${JOBS:="-j2"} -for i in "$@" -do - case $i in - --with-system-premake5 ) with_system_premake5=true ;; - --enable-atlas ) enable_atlas=true ;; - --disable-atlas ) enable_atlas=false ;; - -j* ) JOBS=$i ;; - # Assume any other --options are for Premake - --* ) premake_args="${premake_args} $i" ;; - esac +for i in "$@"; do + case $i in + --with-system-premake5) with_system_premake5=true ;; + --enable-atlas) enable_atlas=true ;; + --disable-atlas) enable_atlas=false ;; + -j*) JOBS=$i ;; + # Assume any other --options are for Premake + --*) premake_args="${premake_args} $i" ;; + esac done if [ "$enable_atlas" = "true" ]; then - premake_args="${premake_args} --atlas" - if [ "$OS" = "Darwin" ]; then - # Provide path to wx-config on OS X (as wxwidgets doesn't support pkgconfig) - export WX_CONFIG="${WX_CONFIG:="$(pwd)/../../libraries/macos/wxwidgets/bin/wx-config"}" - else - export WX_CONFIG="${WX_CONFIG:="wx-config"}" - fi + premake_args="${premake_args} --atlas" + if [ "$OS" = "Darwin" ]; then + # Provide path to wx-config on OS X (as wxwidgets doesn't support pkgconfig) + export WX_CONFIG="${WX_CONFIG:="$(pwd)/../../libraries/macos/wxwidgets/bin/wx-config"}" + else + export WX_CONFIG="${WX_CONFIG:="wx-config"}" + fi - if [ ! -x "$(command -v $WX_CONFIG)" ] - then - echo 'WX_CONFIG must be set and valid or wx-config must be present when --atlas is passed as argument.' - exit 1 - fi + if [ ! -x "$(command -v $WX_CONFIG)" ]; then + echo 'WX_CONFIG must be set and valid or wx-config must be present when --atlas is passed as argument.' + exit 1 + fi fi if [ "$OS" = "Darwin" ]; then - # Set minimal SDK version - export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.12"} + # Set minimal SDK version + export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.12"} fi # Now build Premake or use system's. @@ -74,10 +72,10 @@ cd ../premake premake_command="premake5" if [ "$with_system_premake5" = "false" ]; then - # Build bundled premake - MAKE=${MAKE} JOBS=${JOBS} ./build.sh || die "Premake 5 build failed" + # Build bundled premake + MAKE=${MAKE} JOBS=${JOBS} ./build.sh || die "Premake 5 build failed" - premake_command="premake5/bin/release/premake5" + premake_command="premake5/bin/release/premake5" fi echo @@ -87,11 +85,11 @@ export HOSTTYPE="$HOSTTYPE" # Now run Premake to create the makefiles echo "Premake args: ${premake_args}" if [ "$OS" != "Darwin" ]; then - ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed" + ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed" else - ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} gmake || die "Premake failed" - # Also generate xcode workspaces if on OS X - ${premake_command} --file="premake5.lua" --outpath="../workspaces/xcode4" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} xcode4 || die "Premake failed" + ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} gmake || die "Premake failed" + # Also generate xcode workspaces if on OS X + ${premake_command} --file="premake5.lua" --outpath="../workspaces/xcode4" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} xcode4 || die "Premake failed" fi # test_root.cpp gets generated by cxxtestgen and passing different arguments to premake could require a regeneration of this file. diff --git a/libraries/build-macos-libs.sh b/libraries/build-macos-libs.sh index 449423c656..3eb29529b7 100755 --- a/libraries/build-macos-libs.sh +++ b/libraries/build-macos-libs.sh @@ -75,15 +75,15 @@ export ARCH=${ARCH:=""} # Check if SYSROOT is set and not empty if [[ $SYSROOT && ${SYSROOT-_} ]]; then - C_FLAGS="-isysroot $SYSROOT" - LDFLAGS="$LDFLAGS -Wl,-syslibroot,$SYSROOT" + C_FLAGS="-isysroot $SYSROOT" + LDFLAGS="$LDFLAGS -Wl,-syslibroot,$SYSROOT" fi # Check if MIN_OSX_VERSION is set and not empty if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then - C_FLAGS="$C_FLAGS -mmacosx-version-min=$MIN_OSX_VERSION" - # clang and llvm-gcc look at mmacosx-version-min to determine link target - # and CRT version, and use it to set the macosx_version_min linker flag - LDFLAGS="$LDFLAGS -mmacosx-version-min=$MIN_OSX_VERSION" + C_FLAGS="$C_FLAGS -mmacosx-version-min=$MIN_OSX_VERSION" + # clang and llvm-gcc look at mmacosx-version-min to determine link target + # and CRT version, and use it to set the macosx_version_min linker flag + LDFLAGS="$LDFLAGS -mmacosx-version-min=$MIN_OSX_VERSION" fi CFLAGS="$CFLAGS $C_FLAGS -fvisibility=hidden" @@ -100,15 +100,15 @@ ARCHLESS_LDFLAGS="$LDFLAGS -stdlib=libc++" # If ARCH isn't set, select either x86_64 or arm64 if [ -z "${ARCH}" ]; then - ARCH=`uname -m` + ARCH=$(uname -m) fi if [ $ARCH == "arm64" ]; then - # Some libs want this passed to configure for cross compilation. - HOST_PLATFORM="--host=aarch64-apple-darwin" + # Some libs want this passed to configure for cross compilation. + HOST_PLATFORM="--host=aarch64-apple-darwin" else - CXXFLAGS="$CXXFLAGS -msse4.1" - # Some libs want this passed to configure for cross compilation. - HOST_PLATFORM="--host=x86_64-apple-darwin" + CXXFLAGS="$CXXFLAGS -msse4.1" + # Some libs want this passed to configure for cross compilation. + HOST_PLATFORM="--host=x86_64-apple-darwin" fi CFLAGS="$CFLAGS -arch $ARCH" @@ -125,51 +125,49 @@ set -e die() { - echo ERROR: $* - exit 1 + echo ERROR: $* + exit 1 } download_lib() { - local url=$1 - local filename=$2 + local url=$1 + local filename=$2 - if [ ! -e $filename ]; then - echo "Downloading $filename" - curl -fLo ${filename} ${url}${filename} || die "Download of $url$filename failed" - fi + if [ ! -e $filename ]; then + echo "Downloading $filename" + curl -fLo ${filename} ${url}${filename} || die "Download of $url$filename failed" + fi } already_built() { - echo -e "Skipping - already built (use --force-rebuild to override)" + echo -e "Skipping - already built (use --force-rebuild to override)" } # Check that we're actually on macOS -if [ "`uname -s`" != "Darwin" ]; then - die "This script is intended for macOS only" +if [ "$(uname -s)" != "Darwin" ]; then + die "This script is intended for macOS only" fi # Parse command-line options: force_rebuild=false -for i in "$@" -do - case $i in - --force-rebuild ) force_rebuild=true;; - -j* ) JOBS=$i ;; - esac +for i in "$@"; do + case $i in + --force-rebuild) force_rebuild=true ;; + -j*) JOBS=$i ;; + esac done cd "$(dirname $0)" # Now in libraries/ (where we assume this script resides) mkdir -p macos cd macos - # Create a location to create copies of dependencies' *.pc files, so they can be found by pkg-config PC_PATH="$(pwd)/pkgconfig/" -if [[ "$force_rebuild" = "true" ]]; then - rm -rf $PC_PATH +if [[ $force_rebuild == "true" ]]; then + rm -rf $PC_PATH fi mkdir -p $PC_PATH @@ -182,33 +180,32 @@ LIB_DIRECTORY=$LIB_VERSION LIB_URL="https://zlib.net/fossils/" mkdir -p zlib -pushd zlib > /dev/null +pushd zlib >/dev/null ZLIB_DIR="$(pwd)" -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # patch zlib's configure script to use our CFLAGS and LDFLAGS - (patch -Np0 -i ../../../macos-patches/zlib_flags.diff \ - && CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ - ./configure --prefix="$ZLIB_DIR" \ - --static \ - && make ${JOBS} && make install) || die "zlib build failed" + # patch zlib's configure script to use our CFLAGS and LDFLAGS + (patch -Np0 -i ../../../macos-patches/zlib_flags.diff && + CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ + ./configure --prefix="$ZLIB_DIR" \ + --static && + make ${JOBS} && make install) || die "zlib build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building libcurl..." @@ -219,55 +216,54 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://curl.haxx.se/download/" mkdir -p libcurl -pushd libcurl > /dev/null +pushd libcurl >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --prefix="$INSTALL_DIR" \ - --enable-ipv6 \ - --with-darwinssl \ - --without-gssapi \ - --without-libmetalink \ - --without-libpsl \ - --without-librtmp \ - --without-libssh2 \ - --without-nghttp2 \ - --without-nss \ - --without-polarssl \ - --without-ssl \ - --without-gnutls \ - --without-brotli \ - --without-cyassl \ - --without-winssl \ - --without-mbedtls \ - --without-wolfssl \ - --without-spnego \ - --disable-ares \ - --disable-ldap \ - --disable-ldaps \ - --without-libidn2 \ - --with-zlib="${ZLIB_DIR}" \ - --enable-shared=no \ - && make ${JOBS} && make install) || die "libcurl build failed" + (./configure CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --prefix="$INSTALL_DIR" \ + --enable-ipv6 \ + --with-darwinssl \ + --without-gssapi \ + --without-libmetalink \ + --without-libpsl \ + --without-librtmp \ + --without-libssh2 \ + --without-nghttp2 \ + --without-nss \ + --without-polarssl \ + --without-ssl \ + --without-gnutls \ + --without-brotli \ + --without-cyassl \ + --without-winssl \ + --without-mbedtls \ + --without-wolfssl \ + --without-spnego \ + --disable-ares \ + --disable-ldap \ + --disable-ldaps \ + --without-libidn2 \ + --with-zlib="${ZLIB_DIR}" \ + --enable-shared=no && + make ${JOBS} && make install) || die "libcurl build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building libiconv..." @@ -278,33 +274,32 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://ftp.gnu.org/pub/gnu/libiconv/" mkdir -p iconv -pushd iconv > /dev/null +pushd iconv >/dev/null ICONV_DIR="$(pwd)" -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --prefix="$ICONV_DIR" \ - --without-libiconv-prefix \ - --without-libintl-prefix \ - --disable-nls \ - --enable-shared=no \ - && make ${JOBS} && make install) || die "libiconv build failed" - popd - echo "$LIB_VERSION" > .already-built + (./configure CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --prefix="$ICONV_DIR" \ + --without-libiconv-prefix \ + --without-libintl-prefix \ + --disable-nls \ + --enable-shared=no && + make ${JOBS} && make install) || die "libiconv build failed" + popd + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building libxml2..." @@ -315,36 +310,35 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="ftp://xmlsoft.org/libxml2/" mkdir -p libxml2 -pushd libxml2 > /dev/null +pushd libxml2 >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --prefix="$INSTALL_DIR" \ - --without-lzma \ - --without-python \ - --with-iconv="${ICONV_DIR}" \ - --with-zlib="${ZLIB_DIR}" \ - --enable-shared=no \ - && make ${JOBS} && make install) || die "libxml2 build failed" + (./configure CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --prefix="$INSTALL_DIR" \ + --without-lzma \ + --without-python \ + --with-iconv="${ICONV_DIR}" \ + --with-zlib="${ZLIB_DIR}" \ + --enable-shared=no && + make ${JOBS} && make install) || die "libxml2 build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- @@ -356,39 +350,38 @@ LIB_DIRECTORY=$LIB_VERSION LIB_URL="https://libsdl.org/release/" mkdir -p sdl2 -pushd sdl2 > /dev/null +pushd sdl2 >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # We don't want SDL2 to pull in system iconv, force it to detect ours with flags. - # Don't use X11 - we don't need it and Mountain Lion removed it - (./configure CPPFLAGS="-I${ICONV_DIR}/include" \ - CFLAGS="$CFLAGS" \ - CXXFLAGS="$CXXFLAGS" \ - LDFLAGS="$LDFLAGS -L${ICONV_DIR}/lib" \ - --prefix="$INSTALL_DIR" \ - --disable-video-x11 \ - --without-x \ - --enable-video-cocoa \ - --enable-shared=no \ - && make $JOBS && make install) || die "SDL2 build failed" + # We don't want SDL2 to pull in system iconv, force it to detect ours with flags. + # Don't use X11 - we don't need it and Mountain Lion removed it + (./configure CPPFLAGS="-I${ICONV_DIR}/include" \ + CFLAGS="$CFLAGS" \ + CXXFLAGS="$CXXFLAGS" \ + LDFLAGS="$LDFLAGS -L${ICONV_DIR}/lib" \ + --prefix="$INSTALL_DIR" \ + --disable-video-x11 \ + --without-x \ + --enable-video-cocoa \ + --enable-shared=no && + make $JOBS && make install) || die "SDL2 build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building Boost..." @@ -399,40 +392,40 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/" mkdir -p boost -pushd boost > /dev/null +pushd boost >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY include lib - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY include lib + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # Can't use macosx-version, see above comment. - (./bootstrap.sh --with-libraries=filesystem,system \ - --prefix=$INSTALL_DIR \ - && ./b2 cflags="$CFLAGS" \ - toolset=clang \ - cxxflags="$CXXFLAGS" \ - linkflags="$LDFLAGS" ${JOBS} \ - -d2 \ - --layout=system \ - --debug-configuration \ - link=static \ - threading=multi \ - variant=release install \ - ) || die "Boost build failed" + # Can't use macosx-version, see above comment. + ( + ./bootstrap.sh --with-libraries=filesystem,system \ + --prefix=$INSTALL_DIR && + ./b2 cflags="$CFLAGS" \ + toolset=clang \ + cxxflags="$CXXFLAGS" \ + linkflags="$LDFLAGS" ${JOBS} \ + -d2 \ + --layout=system \ + --debug-configuration \ + link=static \ + threading=multi \ + variant=release install + ) || die "Boost build failed" - popd - echo "$LIB_VERSION" > .already-built + popd + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- # TODO: This build takes ages, anything we can exclude? @@ -444,23 +437,22 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://github.com/wxWidgets/wxWidgets/releases/download/v3.1.4/" mkdir -p wxwidgets -pushd wxwidgets > /dev/null +pushd wxwidgets >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - mkdir -p build-release - pushd build-release + mkdir -p build-release + pushd build-release - CONF_OPTS="--prefix=$INSTALL_DIR + CONF_OPTS="--prefix=$INSTALL_DIR --disable-shared --enable-unicode --with-cocoa @@ -478,23 +470,23 @@ then --disable-webviewwebkit --disable-webviewie --without-libjpeg" - # wxWidgets configure now defaults to targeting 10.5, if not specified, - # but that conflicts with our flags - if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then - CONF_OPTS="$CONF_OPTS --with-macosx-version-min=$MIN_OSX_VERSION" - fi - (../configure CFLAGS="$ARCHLESS_CFLAGS" \ - CXXFLAGS="$ARCHLESS_CXXFLAGS" \ - CPPFLAGS="-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=1" \ - LDFLAGS="$ARCHLESS_LDFLAGS" $CONF_OPTS \ - && make ${JOBS} && make install) || die "wxWidgets build failed" - popd - popd - echo "$LIB_VERSION" > .already-built + # wxWidgets configure now defaults to targeting 10.5, if not specified, + # but that conflicts with our flags + if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then + CONF_OPTS="$CONF_OPTS --with-macosx-version-min=$MIN_OSX_VERSION" + fi + (../configure CFLAGS="$ARCHLESS_CFLAGS" \ + CXXFLAGS="$ARCHLESS_CXXFLAGS" \ + CPPFLAGS="-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=1" \ + LDFLAGS="$ARCHLESS_LDFLAGS" $CONF_OPTS && + make ${JOBS} && make install) || die "wxWidgets build failed" + popd + popd + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building libpng..." @@ -505,33 +497,32 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://download.sourceforge.net/libpng/" mkdir -p libpng -pushd libpng > /dev/null +pushd libpng >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # libpng has no flags for zlib but the 10.12 version is too old, so link our own. - (./configure CFLAGS="$CFLAGS" CPPFLAGS=" -I $ZLIB_DIR/include "\ - LDFLAGS="$LDFLAGS -L$ZLIB_DIR/lib" \ - --prefix=$INSTALL_DIR \ - --enable-shared=no \ - && make ${JOBS} && make install) || die "libpng build failed" + # libpng has no flags for zlib but the 10.12 version is too old, so link our own. + (./configure CFLAGS="$CFLAGS" CPPFLAGS=" -I $ZLIB_DIR/include " \ + LDFLAGS="$LDFLAGS -L$ZLIB_DIR/lib" \ + --prefix=$INSTALL_DIR \ + --enable-shared=no && + make ${JOBS} && make install) || die "libpng build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building freetype..." @@ -542,34 +533,33 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://download.savannah.gnu.org/releases/freetype/" mkdir -p freetype -pushd freetype > /dev/null +pushd freetype >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ - --prefix=$INSTALL_DIR \ - "$HOST_PLATFORM" \ - --enable-shared=no \ - --with-harfbuzz=no \ - --with-bzip2=no \ - --with-brotli=no \ - && make ${JOBS} && make install) || die "freetype build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + (./configure CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ + --prefix=$INSTALL_DIR \ + "$HOST_PLATFORM" \ + --enable-shared=no \ + --with-harfbuzz=no \ + --with-bzip2=no \ + --with-brotli=no && + make ${JOBS} && make install) || die "freetype build failed" + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- # Dependency of vorbis @@ -581,31 +571,30 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://downloads.xiph.org/releases/ogg/" mkdir -p libogg -pushd libogg > /dev/null +pushd libogg >/dev/null OGG_DIR="$(pwd)" -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --prefix=$OGG_DIR \ - --enable-shared=no \ - && make ${JOBS} && make install) || die "libogg build failed" + (./configure CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --prefix=$OGG_DIR \ + --enable-shared=no && + make ${JOBS} && make install) || die "libogg build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building libvorbis..." @@ -616,33 +605,32 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://downloads.xiph.org/releases/vorbis/" mkdir -p vorbis -pushd vorbis > /dev/null +pushd vorbis >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --prefix="$INSTALL_DIR" \ - --enable-shared=no \ - --with-ogg="$OGG_DIR" \ - && make ${JOBS} && make install) || die "libvorbis build failed" + (./configure CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --prefix="$INSTALL_DIR" \ + --enable-shared=no \ + --with-ogg="$OGG_DIR" && + make ${JOBS} && make install) || die "libvorbis build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building GMP..." @@ -653,40 +641,39 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://gmplib.org/download/gmp/" mkdir -p gmp -pushd gmp > /dev/null +pushd gmp >/dev/null GMP_DIR="$(pwd)" -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # NOTE: enable-fat in this case allows building and running on different CPUS. - # Otherwise CPU-specific instructions will be used with no fallback for older CPUs. - (./configure CFLAGS="$CFLAGS" \ - CXXFLAGS="$CXXFLAGS" \ - LDFLAGS="$LDFLAGS" \ - "$HOST_PLATFORM" \ - --prefix="$INSTALL_DIR" \ - --enable-fat \ - --disable-shared \ - --with-pic \ - && make ${JOBS} && make install) || die "GMP build failed" + # NOTE: enable-fat in this case allows building and running on different CPUS. + # Otherwise CPU-specific instructions will be used with no fallback for older CPUs. + (./configure CFLAGS="$CFLAGS" \ + CXXFLAGS="$CXXFLAGS" \ + LDFLAGS="$LDFLAGS" \ + "$HOST_PLATFORM" \ + --prefix="$INSTALL_DIR" \ + --enable-fat \ + --disable-shared \ + --with-pic && + make ${JOBS} && make install) || die "GMP build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building Nettle..." @@ -698,43 +685,42 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://ftp.gnu.org/gnu/nettle/" mkdir -p nettle -pushd nettle > /dev/null +pushd nettle >/dev/null NETTLE_DIR="$(pwd)" -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # NOTE: enable-fat in this case allows building and running on different CPUS. - # Otherwise CPU-specific instructions will be used with no fallback for older CPUs. - (./configure CFLAGS="$CFLAGS" \ - CXXFLAGS="$CXXFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --with-include-path="${GMP_DIR}/include" \ - --with-lib-path="${GMP_DIR}/lib" \ - --prefix="$INSTALL_DIR" \ - --enable-fat \ - --disable-shared \ - --disable-documentation \ - --disable-openssl \ - --disable-assembler \ - && make ${JOBS} && make install) || die "Nettle build failed" + # NOTE: enable-fat in this case allows building and running on different CPUS. + # Otherwise CPU-specific instructions will be used with no fallback for older CPUs. + (./configure CFLAGS="$CFLAGS" \ + CXXFLAGS="$CXXFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --with-include-path="${GMP_DIR}/include" \ + --with-lib-path="${GMP_DIR}/lib" \ + --prefix="$INSTALL_DIR" \ + --enable-fat \ + --disable-shared \ + --disable-documentation \ + --disable-openssl \ + --disable-assembler && + make ${JOBS} && make install) || die "Nettle build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building GnuTLS..." @@ -745,55 +731,54 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/" mkdir -p gnutls -pushd gnutls > /dev/null +pushd gnutls >/dev/null GNUTLS_DIR="$(pwd)" -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # Patch GNUTLS for a linking issue with isdigit - # Patch by Ross Nicholson: https://gitlab.com/gnutls/gnutls/-/issues/1033#note_379529145 - (patch -Np1 -i ../../../macos-patches/03-undo-libtasn1-cisdigit.patch \ - && ./configure CFLAGS="$CFLAGS" \ - CXXFLAGS="$CXXFLAGS" \ - LDFLAGS="$LDFLAGS" \ - LIBS="-L${GMP_DIR}/lib -lgmp" \ - NETTLE_CFLAGS="-I${NETTLE_DIR}/include" \ - NETTLE_LIBS="-L${NETTLE_DIR}/lib -lnettle" \ - HOGWEED_CFLAGS="-I${NETTLE_DIR}/include" \ - HOGWEED_LIBS="-L${NETTLE_DIR}/lib -lhogweed" \ - GMP_CFLAGS="-I${GMP_DIR}/include" \ - GMP_LIBS="-L${GMP_DIR}/lib -lgmp" \ - --prefix="$INSTALL_DIR" \ - --enable-shared=no \ - --without-idn \ - --with-included-unistring \ - --with-included-libtasn1 \ - --without-p11-kit \ - --without-brotli \ - --disable-tests \ - --disable-guile \ - --disable-doc \ - --disable-tools \ - --disable-nls \ - && make ${JOBS} LDFLAGS= install) || die "GnuTLS build failed" + # Patch GNUTLS for a linking issue with isdigit + # Patch by Ross Nicholson: https://gitlab.com/gnutls/gnutls/-/issues/1033#note_379529145 + (patch -Np1 -i ../../../macos-patches/03-undo-libtasn1-cisdigit.patch && + ./configure CFLAGS="$CFLAGS" \ + CXXFLAGS="$CXXFLAGS" \ + LDFLAGS="$LDFLAGS" \ + LIBS="-L${GMP_DIR}/lib -lgmp" \ + NETTLE_CFLAGS="-I${NETTLE_DIR}/include" \ + NETTLE_LIBS="-L${NETTLE_DIR}/lib -lnettle" \ + HOGWEED_CFLAGS="-I${NETTLE_DIR}/include" \ + HOGWEED_LIBS="-L${NETTLE_DIR}/lib -lhogweed" \ + GMP_CFLAGS="-I${GMP_DIR}/include" \ + GMP_LIBS="-L${GMP_DIR}/lib -lgmp" \ + --prefix="$INSTALL_DIR" \ + --enable-shared=no \ + --without-idn \ + --with-included-unistring \ + --with-included-libtasn1 \ + --without-p11-kit \ + --without-brotli \ + --disable-tests \ + --disable-guile \ + --disable-doc \ + --disable-tools \ + --disable-nls && + make ${JOBS} LDFLAGS= install) || die "GnuTLS build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building gloox..." @@ -804,44 +789,43 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://camaya.net/download/" mkdir -p gloox -pushd gloox > /dev/null +pushd gloox >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # TODO: pulls in libresolv dependency from /usr/lib - (./configure CFLAGS="$CFLAGS" \ - CXXFLAGS="$CXXFLAGS" \ - LDFLAGS="$LDFLAGS" \ - "$HOST_PLATFORM" \ - --prefix="$INSTALL_DIR" \ - GNUTLS_CFLAGS="-I${GNUTLS_DIR}/include" \ - GNUTLS_LIBS="-L${GNUTLS_DIR}/lib -lgnutls" \ - --enable-shared=no \ - --with-zlib="${ZLIB_DIR}" \ - --without-libidn \ - --with-gnutls="yes" \ - --without-openssl \ - --without-tests \ - --without-examples \ - --disable-getaddrinfo \ - && make ${JOBS} && make install) || die "gloox build failed" + # TODO: pulls in libresolv dependency from /usr/lib + (./configure CFLAGS="$CFLAGS" \ + CXXFLAGS="$CXXFLAGS" \ + LDFLAGS="$LDFLAGS" \ + "$HOST_PLATFORM" \ + --prefix="$INSTALL_DIR" \ + GNUTLS_CFLAGS="-I${GNUTLS_DIR}/include" \ + GNUTLS_LIBS="-L${GNUTLS_DIR}/lib -lgnutls" \ + --enable-shared=no \ + --with-zlib="${ZLIB_DIR}" \ + --without-libidn \ + --with-gnutls="yes" \ + --without-openssl \ + --without-tests \ + --without-examples \ + --disable-getaddrinfo && + make ${JOBS} && make install) || die "gloox build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building ICU..." @@ -852,42 +836,41 @@ LIB_DIRECTORY="icu" LIB_URL="https://github.com/unicode-org/icu/releases/download/release-69-1/" mkdir -p icu -pushd icu > /dev/null +pushd icu >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib sbin share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib sbin share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - mkdir -p source/build - pushd source/build + mkdir -p source/build + pushd source/build - (CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" \ - ../runConfigureICU MacOSX \ - "$HOST_PLATFORM" \ - --prefix=$INSTALL_DIR \ - --disable-shared \ - --enable-static \ - --disable-samples \ - --enable-extras \ - --enable-icuio \ - --enable-tools \ - && make ${JOBS} && make install) || die "ICU build failed" + (CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" \ + ../runConfigureICU MacOSX \ + "$HOST_PLATFORM" \ + --prefix=$INSTALL_DIR \ + --disable-shared \ + --enable-static \ + --disable-samples \ + --enable-extras \ + --enable-icuio \ + --enable-tools && + make ${JOBS} && make install) || die "ICU build failed" - popd - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building ENet..." @@ -898,32 +881,31 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://enet.bespin.org/download/" mkdir -p enet -pushd enet > /dev/null +pushd enet >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib sbin share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib sbin share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --prefix=${INSTALL_DIR} \ - --enable-shared=no \ - && make clean && make ${JOBS} && make install) || die "ENet build failed" + (./configure CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --prefix=${INSTALL_DIR} \ + --enable-shared=no && + make clean && make ${JOBS} && make install) || die "ENet build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building MiniUPnPc..." @@ -934,33 +916,33 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://miniupnp.tuxfamily.org/files/download.php?file=" mkdir -p miniupnpc -pushd miniupnpc > /dev/null +pushd miniupnpc >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY bin include lib share + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (make clean \ - && CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS make ${JOBS} \ - && INSTALLPREFIX="$INSTALL_DIR" make install \ - ) || die "MiniUPnPc build failed" + ( + make clean && + CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS make ${JOBS} && + INSTALLPREFIX="$INSTALL_DIR" make install + ) || die "MiniUPnPc build failed" - popd - # TODO: how can we not build the dylibs? - rm -f lib/*.dylib - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + # TODO: how can we not build the dylibs? + rm -f lib/*.dylib + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building libsodium..." @@ -971,36 +953,36 @@ LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://download.libsodium.org/libsodium/releases/" mkdir -p libsodium -pushd libsodium > /dev/null +pushd libsodium >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] -then - INSTALL_DIR="$(pwd)" +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]; then + INSTALL_DIR="$(pwd)" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY include lib - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY include lib + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - (./configure CFLAGS="$CFLAGS" \ - LDFLAGS="$LDFLAGS" \ - --prefix=${INSTALL_DIR} \ - --enable-shared=no \ - && make clean \ - && CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS make ${JOBS} \ - && make check \ - && INSTALLPREFIX="$INSTALL_DIR" make install \ - ) || die "libsodium build failed" + ( + ./configure CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + --prefix=${INSTALL_DIR} \ + --enable-shared=no && + make clean && + CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS make ${JOBS} && + make check && + INSTALLPREFIX="$INSTALL_DIR" make install + ) || die "libsodium build failed" - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$LIB_VERSION" > .already-built + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$LIB_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building fmt..." @@ -1010,40 +992,39 @@ LIB_ARCHIVE="$FMT_VERSION.tar.gz" LIB_URL="https://github.com/fmtlib/fmt/archive/" mkdir -p fmt -pushd fmt > /dev/null +pushd fmt >/dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$FMT_VERSION" ]] -then - INSTALL_DIR="$(pwd)" - rm -f .already-built +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$FMT_VERSION" ]]; then + INSTALL_DIR="$(pwd)" + rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE + download_lib $LIB_URL $LIB_ARCHIVE - rm -rf $LIB_DIRECTORY include lib - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY + rm -rf $LIB_DIRECTORY include lib + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY - # It appears that older versions of Clang require constexpr statements to have a user-set constructor. - patch -Np1 -i ../../../macos-patches/fmt_constexpr.diff + # It appears that older versions of Clang require constexpr statements to have a user-set constructor. + patch -Np1 -i ../../../macos-patches/fmt_constexpr.diff - mkdir -p build - pushd build + mkdir -p build + pushd build - (cmake .. \ - -DFMT_TEST=False \ - -DFMT_DOC=False \ - -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ - $CMAKE_FLAGS \ - && make fmt ${JOBS} && make install) || die "fmt build failed" + (cmake .. \ + -DFMT_TEST=False \ + -DFMT_DOC=False \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ + $CMAKE_FLAGS && + make fmt ${JOBS} && make install) || die "fmt build failed" - popd - popd - cp -f lib/pkgconfig/* $PC_PATH - echo "$FMT_VERSION" > .already-built + popd + popd + cp -f lib/pkgconfig/* $PC_PATH + echo "$FMT_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- echo -e "Building Molten VK..." @@ -1052,25 +1033,24 @@ LIB_ARCHIVE="MoltenVK-$MOLTENVK_VERSION.tar.gz" LIB_URL="https://releases.wildfiregames.com/libs/" mkdir -p "molten-vk" -pushd "molten-vk" > /dev/null -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$MOLTENVK_VERSION" ]] || [[ ! -e ../../../binaries/system/libMoltenVK.dylib ]] -then - INSTALL_DIR="../../../../binaries/system/" - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE - rm -rf "$LIB_DIRECTORY" - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY - # The CI cannot build MoltenVK so we provide prebuild binaries instead. - # Use mv instead of copy to preserve binary signature integrity. See: - # https://developer.apple.com/forums/thread/130313?answerId=410541022#410541022 - mv dylib/libMoltenVK.dylib $INSTALL_DIR - popd > /dev/null - echo "$MOLTENVK_VERSION" > .already-built +pushd "molten-vk" >/dev/null +if [[ $force_rebuild == "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$MOLTENVK_VERSION" ]] || [[ ! -e ../../../binaries/system/libMoltenVK.dylib ]]; then + INSTALL_DIR="../../../../binaries/system/" + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE + rm -rf "$LIB_DIRECTORY" + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY + # The CI cannot build MoltenVK so we provide prebuild binaries instead. + # Use mv instead of copy to preserve binary signature integrity. See: + # https://developer.apple.com/forums/thread/130313?answerId=410541022#410541022 + mv dylib/libMoltenVK.dylib $INSTALL_DIR + popd >/dev/null + echo "$MOLTENVK_VERSION" >.already-built else - already_built + already_built fi -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------------- # The following libraries are shared on different OSes and may @@ -1079,51 +1059,48 @@ popd > /dev/null # -------------------------------------------------------------------- if [ -e ../source/.svn ]; then - pushd ../source > /dev/null - svn cleanup && svn up -r $source_svnrev - popd > /dev/null + pushd ../source >/dev/null + svn cleanup && svn up -r $source_svnrev + popd >/dev/null else - svn co -r $source_svnrev https://svn.wildfiregames.com/public/source-libs/trunk ../source + svn co -r $source_svnrev https://svn.wildfiregames.com/public/source-libs/trunk ../source fi # SpiderMonkey - bundled, no download -pushd ../source/spidermonkey/ > /dev/null +pushd ../source/spidermonkey/ >/dev/null -if [[ "$force_rebuild" = "true" ]] -then - rm -f .already-built +if [[ $force_rebuild == "true" ]]; then + rm -f .already-built fi # Use the regular build script for SM. JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" ARCH="$ARCH" ./build.sh || die "Error building spidermonkey" cp bin/* ../../../binaries/system/ -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- # NVTT - bundled, no download -pushd ../source/nvtt > /dev/null +pushd ../source/nvtt >/dev/null -if [[ "$force_rebuild" = "true" ]] -then - rm -f .already-built +if [[ $force_rebuild == "true" ]]; then + rm -f .already-built fi CXXFLAGS="$CXXFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CMAKE_FLAGS=$CMAKE_FLAGS JOBS="$JOBS" ./build.sh || die "Error building NVTT" cp bin/* ../../../binaries/system/ -popd > /dev/null +popd >/dev/null # -------------------------------------------------------------- # FCollada - bundled, no download -pushd ../source/fcollada/ > /dev/null +pushd ../source/fcollada/ >/dev/null -if [[ "$force_rebuild" = "true" ]] -then - rm -f .already-built +if [[ $force_rebuild == "true" ]]; then + rm -f .already-built fi CXXFLAGS="$CXXFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" JOBS="$JOBS" ./build.sh || die "Error building FCollada" cp bin/* ../../../binaries/system/ -popd > /dev/null +popd >/dev/null diff --git a/libraries/build-source-libs.sh b/libraries/build-source-libs.sh index 881586c700..fe02002b40 100755 --- a/libraries/build-source-libs.sh +++ b/libraries/build-source-libs.sh @@ -2,17 +2,17 @@ die() { - echo ERROR: $* - exit 1 + echo ERROR: $* + exit 1 } # SVN revision to checkout for source-libs # Update this line when you commit an update to source-libs source_svnrev="28207" -if [ "`uname -s`" = "Darwin" ]; then - echo 'This script should not be used on macOS: use build-macos-libs.sh instead.' - exit 1 +if [ "$(uname -s)" = "Darwin" ]; then + echo 'This script should not be used on macOS: use build-macos-libs.sh instead.' + exit 1 fi cd "$(dirname $0)" @@ -21,13 +21,13 @@ cd "$(dirname $0)" # Check for whitespace in absolute path; this will cause problems in the # SpiderMonkey build and maybe elsewhere, so we just forbid it # Use perl as an alternative to readlink -f, which isn't available on BSD -SCRIPTPATH=`perl -MCwd -e 'print Cwd::abs_path shift' "$0"` +SCRIPTPATH=$(perl -MCwd -e 'print Cwd::abs_path shift' "$0") case "$SCRIPTPATH" in - *\ * ) - die "Absolute path contains whitespace, which will break the build - move the game to a path without spaces" ;; + *\ *) + die "Absolute path contains whitespace, which will break the build - move the game to a path without spaces" + ;; esac - # Parse command-line options (download options and build options): source_libs_dir="source" @@ -37,25 +37,24 @@ with_system_mozjs=false JOBS=${JOBS:="-j2"} -for i in "$@" -do - case $i in - --source-libs-dir=* ) source_libs_dir=${1#*=} ;; - --source-libs-dir ) die "correct syntax is --source-libs-dir=/path/to/dir" ;; - --without-nvtt ) without_nvtt=true ;; - --with-system-nvtt ) with_system_nvtt=true ;; - --with-system-mozjs ) with_system_mozjs=true ;; - -j* ) JOBS=$i ;; - esac +for i in "$@"; do + case $i in + --source-libs-dir=*) source_libs_dir=${1#*=} ;; + --source-libs-dir) die "correct syntax is --source-libs-dir=/path/to/dir" ;; + --without-nvtt) without_nvtt=true ;; + --with-system-nvtt) with_system_nvtt=true ;; + --with-system-mozjs) with_system_mozjs=true ;; + -j*) JOBS=$i ;; + esac done # Download source libs echo "Downloading source libs..." echo if [ -e ${source_libs_dir}/.svn ]; then - (cd ${source_libs_dir} && svn cleanup && svn up -r $source_svnrev) + (cd ${source_libs_dir} && svn cleanup && svn up -r $source_svnrev) else - svn co -r $source_svnrev https://svn.wildfiregames.com/public/source-libs/trunk ${source_libs_dir} + svn co -r $source_svnrev https://svn.wildfiregames.com/public/source-libs/trunk ${source_libs_dir} fi # Build/update bundled external libraries @@ -64,23 +63,23 @@ echo # Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE # is not set. -case "`uname -s`" in - "FreeBSD" | "OpenBSD" ) - MAKE=${MAKE:="gmake"} - ;; - * ) - MAKE=${MAKE:="make"} - ;; +case "$(uname -s)" in + "FreeBSD" | "OpenBSD") + MAKE=${MAKE:="gmake"} + ;; + *) + MAKE=${MAKE:="make"} + ;; esac (cd ${source_libs_dir}/fcollada && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "FCollada build failed" echo if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then - (cd ${source_libs_dir}/nvtt && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "NVTT build failed" + (cd ${source_libs_dir}/nvtt && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "NVTT build failed" fi echo if [ "$with_system_mozjs" = "false" ]; then - (cd ${source_libs_dir}/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed" + (cd ${source_libs_dir}/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed" fi echo @@ -88,29 +87,29 @@ echo "Copying built files..." # Copy built binaries to binaries/system/ cp ${source_libs_dir}/fcollada/bin/* ../binaries/system/ if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then - cp ${source_libs_dir}/nvtt/bin/* ../binaries/system/ + cp ${source_libs_dir}/nvtt/bin/* ../binaries/system/ fi if [ "$with_system_mozjs" = "false" ]; then - cp ${source_libs_dir}/spidermonkey/bin/* ../binaries/system/ + cp ${source_libs_dir}/spidermonkey/bin/* ../binaries/system/ fi # If a custom source-libs dir was used, includes and static libs should be copied to libraries/source/ # and all other bundled content should be copied. if [ "$source_libs_dir" != "source" ]; then - rsync -avzq \ - --exclude fcollada \ - --exclude nvtt \ - --exclude spidermonkey \ - ${source_libs_dir}/ source + rsync -avzq \ + --exclude fcollada \ + --exclude nvtt \ + --exclude spidermonkey \ + ${source_libs_dir}/ source - mkdir -p source/fcollada - cp -r ${source_libs_dir}/fcollada/{include,lib} source/fcollada/ - if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then - mkdir -p source/nvtt - cp -r ${source_libs_dir}/nvtt/{include,lib} source/nvtt/ - fi - if [ "$with_system_mozjs" = "false" ]; then - mkdir -p source/spidermonkey - cp -r ${source_libs_dir}/spidermonkey/{include-unix-debug,include-unix-release,lib} source/spidermonkey/ - fi + mkdir -p source/fcollada + cp -r ${source_libs_dir}/fcollada/{include,lib} source/fcollada/ + if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then + mkdir -p source/nvtt + cp -r ${source_libs_dir}/nvtt/{include,lib} source/nvtt/ + fi + if [ "$with_system_mozjs" = "false" ]; then + mkdir -p source/spidermonkey + cp -r ${source_libs_dir}/spidermonkey/{include-unix-debug,include-unix-release,lib} source/spidermonkey/ + fi fi echo "Done." diff --git a/libraries/clean-source-libs.sh b/libraries/clean-source-libs.sh index d1541e5a77..e06a7a9bc4 100755 --- a/libraries/clean-source-libs.sh +++ b/libraries/clean-source-libs.sh @@ -12,9 +12,9 @@ cd "$(dirname $0)" echo "Cleaning bundled third-party dependencies..." if [ -e source/.svn ]; then - (cd source && svn revert -R . && svn st --no-ignore | cut -c 9- | xargs rm -rf) + (cd source && svn revert -R . && svn st --no-ignore | cut -c 9- | xargs rm -rf) else - rm -rf source + rm -rf source fi echo diff --git a/source/tools/dist/build-archives.sh b/source/tools/dist/build-archives.sh index c50204dfb4..20387e2d62 100755 --- a/source/tools/dist/build-archives.sh +++ b/source/tools/dist/build-archives.sh @@ -25,18 +25,17 @@ REGEX=".*/\("${REGEX:2}"\)\.[-A-Za-z0-9_.]\+\.po" find binaries/ -name "*.po" | grep -v "$REGEX" | xargs rm -v || die "Error filtering languages." # Build archive(s) - don't archive the _test.* mods -pushd binaries/data/mods > /dev/null +pushd binaries/data/mods >/dev/null archives="" ONLY_MOD="${ONLY_MOD:=false}" if [ "${ONLY_MOD}" = true ]; then archives="mod" else - for modname in [a-zA-Z0-9]* - do + for modname in [a-zA-Z0-9]*; do archives="${archives} ${modname}" done fi -popd > /dev/null +popd >/dev/null BUILD_SHADERS="${BUILD_SHADERS:=true}" if [ "${BUILD_SHADERS}" = true ]; then @@ -48,35 +47,31 @@ if [ "${BUILD_SHADERS}" = true ]; then [ -n "${GLSLC}" ] || die "Error: glslc is not available. Install it with the Vulkan SDK before proceeding." [ -n "${SPIRV_REFLECT}" ] || die "Error: spirv-reflect is not available. Install it with the Vulkan SDK before proceeding." - pushd "source/tools/spirv" > /dev/null + pushd "source/tools/spirv" >/dev/null ENGINE_VERSION=${ENGINE_VERSION:="0.0.xx"} rulesFile="rules.${ENGINE_VERSION}.json" - if [ ! -e "$rulesFile" ] - then + if [ ! -e "$rulesFile" ]; then # The rules.json file should be present in release tarballs, for # some Linux CIs don't have access to the internet. download="$(command -v wget || echo "curl -sLo ""${rulesFile}""")" $download "https://releases.wildfiregames.com/spir-v/$rulesFile" fi - for modname in $archives - do + for modname in $archives; do modLocation="../../../binaries/data/mods/${modname}" - if [ -e "${modLocation}/shaders/spirv/" ] - then + if [ -e "${modLocation}/shaders/spirv/" ]; then echo "Removing existing spirv shaders for '${modname}'..." rm -rf "${modLocation}/shaders/spirv" fi echo "Building shader for '${modname}'..." $PYTHON compile.py "$modLocation" "$rulesFile" "$modLocation" --dependency "../../../binaries/data/mods/mod/" done - popd > /dev/null + popd >/dev/null fi -for modname in $archives -do +for modname in $archives; do echo "Building archive for '${modname}'..." ARCHIVEBUILD_INPUT="binaries/data/mods/${modname}" ARCHIVEBUILD_OUTPUT="archives/${modname}" @@ -84,5 +79,5 @@ do mkdir -p "${ARCHIVEBUILD_OUTPUT}" (./binaries/system/pyrogenesis -mod=mod -archivebuild="${ARCHIVEBUILD_INPUT}" -archivebuild-output="${ARCHIVEBUILD_OUTPUT}/${modname}.zip") || die "Archive build for '${modname}' failed!" - cp "${ARCHIVEBUILD_INPUT}/mod.json" "${ARCHIVEBUILD_OUTPUT}" &> /dev/null || true + cp "${ARCHIVEBUILD_INPUT}/mod.json" "${ARCHIVEBUILD_OUTPUT}" &>/dev/null || true done diff --git a/source/tools/dist/build-osx-executable.sh b/source/tools/dist/build-osx-executable.sh index d61f79f7bb..1fa84211ae 100755 --- a/source/tools/dist/build-osx-executable.sh +++ b/source/tools/dist/build-osx-executable.sh @@ -13,18 +13,18 @@ export CC=${CC:="clang"} CXX=${CXX:="clang++"} die() { - echo ERROR: $* - exit 1 + echo ERROR: $* + exit 1 } # Check that we're actually on OS X -if [ "`uname -s`" != "Darwin" ]; then - die "This script is intended for OS X only" +if [ "$(uname -s)" != "Darwin" ]; then + die "This script is intended for OS X only" fi # Check SDK exists if [ ! -d "${SYSROOT}" ]; then - die "${SYSROOT} does not exist! You probably need to install Xcode" + die "${SYSROOT} does not exist! You probably need to install Xcode" fi cd "build/workspaces/" @@ -46,10 +46,10 @@ fi # Build libraries against SDK echo "\nBuilding libraries\n" -pushd ../../libraries/osx > /dev/null +pushd ../../libraries/osx >/dev/null SYSROOT="${SYSROOT}" MIN_OSX_VERSION="${MIN_OSX_VERSION}" \ ./build-osx-libs.sh $JOBS "${BUILD_LIBS_ARGS}" || die "Libraries build script failed" -popd > /dev/null +popd >/dev/null # Update workspaces echo "\nGenerating workspaces\n" @@ -58,13 +58,13 @@ echo "\nGenerating workspaces\n" (SYSROOT="${SYSROOT}" MIN_OSX_VERSION="${MIN_OSX_VERSION}" \ ./update-workspaces.sh --sysroot="${SYSROOT}" --macosx-version-min="${MIN_OSX_VERSION}") || die "update-workspaces.sh failed!" -pushd gcc > /dev/null +pushd gcc >/dev/null echo "\nBuilding game\n" (make clean && CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" make ${JOBS}) || die "Game build failed!" -popd > /dev/null +popd >/dev/null # Run test to confirm all is OK -pushd ../../binaries/system > /dev/null +pushd ../../binaries/system >/dev/null echo "\nRunning tests\n" ./test || die "Post-build testing failed!" -popd > /dev/null +popd >/dev/null diff --git a/source/tools/dist/build-unix-win32.sh b/source/tools/dist/build-unix-win32.sh index ff5b67bac8..dfa2eafdcd 100755 --- a/source/tools/dist/build-unix-win32.sh +++ b/source/tools/dist/build-unix-win32.sh @@ -19,9 +19,9 @@ tar cf $PREFIX-unix-build.tar \ tar cf $PREFIX-unix-data.tar \ --exclude='binaries/data/config/dev.cfg' \ - -s "|archives|$PREFIX/binaries/data/mods|" \ - -s "|binaries|$PREFIX/binaries|" \ - binaries/data/{config,tools} archives/ + -s "|archives|$PREFIX/binaries/data/mods|" \ + -s "|binaries|$PREFIX/binaries|" \ + binaries/data/{config,tools} archives/ # TODO: ought to include generated docs in here, perhaps? # Compress diff --git a/source/tools/i18n/get-nightly-translations.sh b/source/tools/i18n/get-nightly-translations.sh index f89ce59e73..0303910cbb 100755 --- a/source/tools/i18n/get-nightly-translations.sh +++ b/source/tools/i18n/get-nightly-translations.sh @@ -9,7 +9,7 @@ cd "$(dirname $0)" svn export --force --depth files https://svn.wildfiregames.com/nightly-build/trunk/binaries/data/l10n ../../../binaries/data/l10n for m in "mod" "public"; do - svn export --force --depth files https://svn.wildfiregames.com/nightly-build/trunk/binaries/data/mods/${m}/l10n ../../../binaries/data/mods/${m}/l10n + svn export --force --depth files https://svn.wildfiregames.com/nightly-build/trunk/binaries/data/mods/${m}/l10n ../../../binaries/data/mods/${m}/l10n done svn export --force https://svn.wildfiregames.com/nightly-build/trunk/binaries/data/mods/public/gui/credits/texts/translators.json ../../../binaries/data/mods/public/gui/credits/texts/translators.json diff --git a/source/tools/spirv/get-nightly-shaders.sh b/source/tools/spirv/get-nightly-shaders.sh index 288ca555e6..f5ef2d23e4 100755 --- a/source/tools/spirv/get-nightly-shaders.sh +++ b/source/tools/spirv/get-nightly-shaders.sh @@ -6,5 +6,5 @@ set -ev cd "$(dirname $0)" for m in "mod" "public"; do - svn export --force https://svn.wildfiregames.com/nightly-build/trunk/binaries/data/mods/${m}/shaders/spirv ../../../binaries/data/mods/${m}/shaders/spirv + svn export --force https://svn.wildfiregames.com/nightly-build/trunk/binaries/data/mods/${m}/shaders/spirv ../../../binaries/data/mods/${m}/shaders/spirv done diff --git a/source/tools/templatessorter/templatessorter.sh b/source/tools/templatessorter/templatessorter.sh index 65f2e8d540..2fd6b8bc38 100755 --- a/source/tools/templatessorter/templatessorter.sh +++ b/source/tools/templatessorter/templatessorter.sh @@ -1,11 +1,10 @@ #!/bin/bash # check arguments count if [ $# -ne 1 ]; then - echo 'usage: '$0' directory' - exit + echo 'usage: '$0' directory' + exit fi # assign arguments to variables with readable names input_directory=$1 # perform work find $input_directory -name \*.xml -exec xsltproc -o {} templatessorter.xsl {} \; - diff --git a/source/tools/tracelogger/tracelogger_options.sh b/source/tools/tracelogger/tracelogger_options.sh index 21613bb45a..94b69cd7b7 100755 --- a/source/tools/tracelogger/tracelogger_options.sh +++ b/source/tools/tracelogger/tracelogger_options.sh @@ -13,11 +13,10 @@ export TLDIR="$(dirname $(realpath $0))" # Use semicolons to separate values on Windows. # If that produces bogus output, you can try with commas instead. -if [ "${OS}" = "Windows_NT" ] -then - export TLLOG="Default;IonCompiler" - export TLOPTIONS="EnableMainThread;EnableOffThread;EnableGraph" +if [ "${OS}" = "Windows_NT" ]; then + export TLLOG="Default;IonCompiler" + export TLOPTIONS="EnableMainThread;EnableOffThread;EnableGraph" else - export TLLOG=Default,IonCompiler - export TLOPTIONS=EnableMainThread,EnableOffThread,EnableGraph + export TLLOG=Default,IonCompiler + export TLOPTIONS=EnableMainThread,EnableOffThread,EnableGraph fi