From bd98047ff9824cb93cfc8dcd8d724253f5a138f8 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 16 Jan 2021 19:29:27 +0100 Subject: [PATCH] build_engine/editor: Support for systems without nproc amongst other things --- build_editor.sh | 24 +++++++++++++++++++++--- build_engine.sh | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/build_editor.sh b/build_editor.sh index 9c21289f..99a54886 100755 --- a/build_editor.sh +++ b/build_editor.sh @@ -2,12 +2,30 @@ mv_wsfile() { - cp -v "./build/$1" "../../bin/$1" + if [ -f "./build/$1" ]; then + cp -v "./build/$1" "../../bin/$1" + fi } set -e WS_MAKEFILE=./src/worldspawn/CMakeLists.txt +COMPILE_SYS=$(uname) + +# Check how many cores/processors we should use for building +if ! [ -x "$(command -v nproc)" ]; then + # nproc doesn't exist, so make a safe assumption of having at least 1 + BUILD_PROC=1 +else + BUILD_PROC=$(nproc) +fi + +# OpenBSD currently doesn't build vmap, so disable it for now +if [[ "$COMPILE_SYS" == "OpenBSD" ]]; then + CM_OPTION=-DBUILD_VMAP=OFF +else + CM_OPTION=-DBUILD_VMAP=ON +fi mkdir -p ./bin @@ -22,7 +40,7 @@ else cd ./worldspawn fi -cmake -G "Unix Makefiles" -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build -- -j$(nproc) +cmake -G "Unix Makefiles" -H. -Bbuild -DCMAKE_BUILD_TYPE=Release "$CM_OPTION" && cmake --build build -- -j $BUILD_PROC mkdir -p ../../bin/bitmaps mv_wsfile bitmaps/black.xpm @@ -151,8 +169,8 @@ mv_wsfile platform.game/platform/entities.def mv_wsfile WorldSpawn_MAJOR mv_wsfile WorldSpawn_MINOR mv_wsfile WorldSpawn_PATCH -mv_wsfile vmap mv_wsfile worldspawn +mv_wsfile vmap cd ../../src ./mk_mapdef.sh diff --git a/build_engine.sh b/build_engine.sh index c32ec83b..7e98bb12 100755 --- a/build_engine.sh +++ b/build_engine.sh @@ -4,7 +4,16 @@ set -e FTE_MAKEFILE=./src/engine/engine/Makefile BUILD_SDL2=0 BUILD_DEBUG=1 -COMPILE_SYS=$(uname -o) +COMPILE_SYS=$(uname) +PLUGINS="bullet" + +# Check how many cores/processors we should use for building +if ! [ -x "$(command -v nproc)" ]; then + # nproc doesn't exist, so make a safe assumption of having at least 1 + BUILD_PROC=1 +else + BUILD_PROC=$(nproc) +fi if [ "$BUILD_DEBUG" -eq 1 ]; then MAKETARGET=gl-dbg @@ -21,9 +30,22 @@ else if [[ "$COMPILE_SYS" == "Cygwin" ]]; then PLATFORM=win64 OUTPUT=$OUTPUT/fteglqw64.exe - else + elif [[ "$COMPILE_SYS" == "OpenBSD" ]]; then + PLATFORM=bsd + OUTPUT=$OUTPUT/fteqw-gl + PLUGINS="" + elif [[ "$COMPILE_SYS" == "FreeBSD" ]]; then + PLATFORM=bsd + OUTPUT=$OUTPUT/fteqw-gl + elif [[ "$COMPILE_SYS" == "NetBSD" ]]; then + PLATFORM=bsd + OUTPUT=$OUTPUT/fteqw-gl + elif [[ "$COMPILE_SYS" == "Linux" ]]; then PLATFORM=linux64 OUTPUT=$OUTPUT/fteqw-gl64 + else + printf "Unsupported platform.\n" + exit fi fi @@ -41,21 +63,21 @@ else cd ./engine/engine fi -make -j $(nproc) makelibs NATIVE_PLUGINS="bullet" FTE_TARGET=$PLATFORM -make -j $(nproc) $MAKETARGET FTE_TARGET=$PLATFORM +gmake -j $BUILD_PROC makelibs NATIVE_PLUGINS=$PLUGINS FTE_TARGET=$PLATFORM +gmake -j $BUILD_PROC $MAKETARGET FTE_TARGET=$PLATFORM cp -v "$OUTPUT" ../../../bin/fteqw -make -j $(nproc) sv-dbg +gmake -j $BUILD_PROC sv-dbg cp -v ./debug/fteqw-sv ../../../bin/fteqw-sv -make -j $(nproc) qcc-rel +gmake -j $BUILD_PROC qcc-rel cp -v ./release/fteqcc ../../../bin/fteqcc -make -j $(nproc) iqm-rel +gmake -j $BUILD_PROC iqm-rel cp -v ./release/iqm ../../../bin/iqm -make -j $(nproc) imgtool-rel +gmake -j $BUILD_PROC imgtool-rel cp -v ./release/imgtool ../../../bin/imgtool -make -j $(nproc) plugins-rel NATIVE_PLUGINS="bullet" +gmake -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="bullet" find ./release/ -name 'fteplug_bullet_*.so' -exec cp -prv '{}' '../../../bin/' ';' -make -j $(nproc) plugins-rel NATIVE_PLUGINS="ffmpeg" +gmake -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="ffmpeg" find ./release/ -name 'fteplug_ffmpeg_*.so' -exec cp -prv '{}' '../../../bin/' ';'