diff --git a/scripts/gha/build_android.sh b/scripts/gha/build_android.sh index 79a8a71d..d9aff990 100755 --- a/scripts/gha/build_android.sh +++ b/scripts/gha/build_android.sh @@ -5,21 +5,21 @@ export JAVA_HOME=$GITHUB_WORKSPACE/java export ANDROID_HOME=$GITHUB_WORKSPACE/sdk export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/tools/bin -pushd android +pushd android || exit 1 ./gradlew assembleContinuous --no-daemon || exit 1 -pushd app/build/outputs/apk/continuous +pushd app/build/outputs/apk/continuous || exit 1 -$ANDROID_HOME/build-tools/36.0.0/apksigner sign \ - --ks $GITHUB_WORKSPACE/android/debug.keystore \ +"$ANDROID_HOME/build-tools/36.0.0/apksigner" sign \ + --ks "$GITHUB_WORKSPACE/android/debug.keystore" \ --ks-key-alias androiddebugkey \ --ks-pass pass:android \ --key-pass pass:android \ --out app-continuous-signed.apk app-continuous-unsigned.apk || exit 1 -popd -popd +popd || exit 1 +popd || exit 1 mkdir -p artifacts/ diff --git a/scripts/gha/build_apple.sh b/scripts/gha/build_apple.sh index 2b1521f9..aeedb54c 100755 --- a/scripts/gha/build_apple.sh +++ b/scripts/gha/build_apple.sh @@ -2,15 +2,15 @@ . scripts/lib.sh -cd $GITHUB_WORKSPACE || die +cd "$GITHUB_WORKSPACE" || die pushd hlsdk || die ./waf configure build install --destdir=../bin || die -popd +popd || die ./waf configure --enable-utils --enable-tests --enable-lto --enable-tui build install --destdir=bin || die_configure cp -vr /Library/Frameworks/SDL2.framework bin mkdir -p artifacts/ -tar -cJvf artifacts/xash3d-fwgs-apple-$ARCH.tar.xz -C bin . # skip the bin directory from resulting tar archive +tar -cJvf "artifacts/xash3d-fwgs-apple-$ARCH.tar.xz" -C bin . # skip the bin directory from resulting tar archive diff --git a/scripts/gha/build_ios.sh b/scripts/gha/build_ios.sh index ea4ed194..efdfced1 100755 --- a/scripts/gha/build_ios.sh +++ b/scripts/gha/build_ios.sh @@ -2,7 +2,7 @@ . scripts/lib.sh -cd $GITHUB_WORKSPACE || die +cd "$GITHUB_WORKSPACE" || die ./waf configure --enable-lto --ios build install --destdir=build/ios || die_configure @@ -11,7 +11,7 @@ cp -vr /Library/Frameworks/SDL2.framework ./build pushd hlsdk || die cmake -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DGAMEDIR=$(realpath ../build/ios) -DCMAKE_BUILD_TYPE=Debug -B build -S . cmake --build build --target install || die -popd +popd || die ./scripts/ios/createipa.sh diff --git a/scripts/gha/build_linux.sh b/scripts/gha/build_linux.sh index 97540580..1b0ce9ad 100755 --- a/scripts/gha/build_linux.sh +++ b/scripts/gha/build_linux.sh @@ -70,6 +70,7 @@ build_engine() WAF_EXTRA_ARGS+=" --enable-tests" fi + # shellcheck disable=SC2086 ./waf configure $WAF_EXTRA_ARGS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stbtt --enable-utils --enable-tui --enable-dedicated || die_configure ./waf build || die_configure diff --git a/scripts/gha/build_motomagx.sh b/scripts/gha/build_motomagx.sh index e38aadbe..ef8fa3ac 100755 --- a/scripts/gha/build_motomagx.sh +++ b/scripts/gha/build_motomagx.sh @@ -3,14 +3,14 @@ . scripts/lib.sh . /opt/toolchains/motomagx/setenv-z6.sh -cd $GITHUB_WORKSPACE || die +cd "$GITHUB_WORKSPACE" || die mkdir -p Xash/valve/cl_dlls mkdir -p Xash/valve/dlls pushd hlsdk || die ./waf configure -T fast --enable-magx --enable-simple-mod-hacks build install --destdir=../Xash || die -popd +popd || die ./waf configure -T fast --enable-magx build install --destdir=Xash/ || die diff --git a/scripts/gha/build_nswitch.sh b/scripts/gha/build_nswitch.sh index 1f841354..1cfbe4cc 100644 --- a/scripts/gha/build_nswitch.sh +++ b/scripts/gha/build_nswitch.sh @@ -11,10 +11,10 @@ mkdir -p artifacts/ || die echo "Running build script in Docker container..." -docker run --name xash-build --rm -v `pwd`:`pwd` -w `pwd` devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die +docker run --name xash-build --rm -v "$(pwd):$(pwd)" -w "$(pwd)" devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die echo "Packaging artifacts..." pushd pkgtemp || die 7z a -t7z ../artifacts/xash3d-fwgs-nswitch.7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -r xash3d/ -popd +popd || die diff --git a/scripts/gha/build_nswitch_docker.sh b/scripts/gha/build_nswitch_docker.sh index 00e76a6b..493d01aa 100644 --- a/scripts/gha/build_nswitch_docker.sh +++ b/scripts/gha/build_nswitch_docker.sh @@ -5,7 +5,7 @@ build_hlsdk() { echo "Building HLSDK: $1 branch..." - git checkout $1 + git checkout "$1" || die # This is not our bug if HLSDK doesn't build with -Werrors enabled ./waf configure -T release --nswitch --disable-werror || die_configure @@ -50,9 +50,9 @@ echo "Building HLSDK..." pushd hlsdk-portable || die build_hlsdk mobile_hacks valve build_hlsdk opfor gearbox -popd +popd || die # bshift can be used from mobile_hacks branch -pushd pkgtemp/xash3d +pushd pkgtemp/xash3d || die cp -v valve/dlls/hl_nswitch_arm64.so bshift/dlls/bshift_nswitch_arm64.so -popd +popd || die diff --git a/scripts/gha/build_psvita.sh b/scripts/gha/build_psvita.sh index 2afb0108..8997f4a4 100644 --- a/scripts/gha/build_psvita.sh +++ b/scripts/gha/build_psvita.sh @@ -5,7 +5,7 @@ build_hlsdk() { echo "Building HLSDK: $1 branch..." - git checkout $1 + git checkout "$1" || die # This is not our bug if HLSDK doesn't build with -Werrors enabled ./waf configure -T release --psvita --disable-werror || die_configure @@ -34,7 +34,7 @@ pushd vita-rtld || die cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release || die_configure cmake --build build -- -j$JOBS || die cmake --install build || die -popd +popd || die echo "Building SDL..." @@ -42,7 +42,7 @@ pushd SDL || die cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DVIDEO_VITA_VGL=ON -DSDL_RENDER=OFF || die_configure cmake --build build -- -j$JOBS || die cmake --install build || die -popd +popd || die echo "Building engine..." @@ -55,16 +55,16 @@ echo "Building HLSDK..." pushd hlsdk-portable || die build_hlsdk mobile_hacks valve build_hlsdk opfor gearbox -popd +popd || die # bshift can be used from mobile_hacks branch -pushd pkgtemp/data/xash3d +pushd pkgtemp/data/xash3d || die cp -v valve/dlls/hl_psvita_armv7hf.so bshift/dlls/bshift_psvita_armv7hf.so -popd +popd || die echo "Generating default config files..." -pushd pkgtemp/data/xash3d/valve +pushd pkgtemp/data/xash3d/valve || die touch config.cfg echo 'unbindall' >> config.cfg @@ -91,13 +91,13 @@ echo 'r_refdll "gl"' >> video.cfg touch opengl.cfg echo 'gl_nosort "1"' >> opengl.cfg -cp *.cfg ../gearbox/ -cp *.cfg ../bshift/ +cp ./*.cfg ../gearbox/ +cp ./*.cfg ../bshift/ -popd +popd || die echo "Packaging artifacts..." pushd pkgtemp || die 7z a -t7z ../artifacts/xash3d-fwgs-psvita.7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -r xash.vpk data/ -popd +popd || die diff --git a/scripts/gha/build_win32.sh b/scripts/gha/build_win32.sh index fd380a67..25f82d35 100755 --- a/scripts/gha/build_win32.sh +++ b/scripts/gha/build_win32.sh @@ -3,7 +3,7 @@ . scripts/lib.sh # Build engine -cd $BUILDDIR +cd "$BUILDDIR" || die WAF_EXTRA_ARGS="" @@ -20,6 +20,7 @@ fi # NOTE: to build with other version use --msvc_version during configuration # NOTE: sometimes you may need to add WinSDK to %PATH% # NOTE: --enable-msvcdeps only used for CI builds, enabling it non-English versions of MSVC causes useless console spam +# shellcheck disable=SC2086 ./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto --enable-msvcdeps --enable-tui $WAF_EXTRA_ARGS || die_configure ./waf.bat build || die ./waf.bat install --destdir=. || die @@ -42,13 +43,13 @@ WINSDK_LATEST=$(ls -1 "C:/Program Files (x86)/Windows Kits/10/bin" | grep -E '^1 echo "Latest installed Windows SDK is $WINSDK_LATEST" "C:/Program Files (x86)/Windows Kits/10/bin/$WINSDK_LATEST/x64/signtool.exe" \ - sign //f scripts/fwgs.pfx //fd SHA256 //p "$FWGS_PFX_PASSWORD" *.dll *.exe + sign //f scripts/fwgs.pfx //fd SHA256 //p "$FWGS_PFX_PASSWORD" ./*.dll ./*.exe if [ "$ARCH" = "i386" ]; then # VGUI is already signed cp 3rdparty/vgui_support/vgui-dev/lib/win32_vc6/vgui.dll . fi mkdir -p artifacts/ -7z a -t7z artifacts/xash3d-fwgs-win32-$ARCH.7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \ - *.dll *.exe *.pdb activities.txt \ +7z a -t7z "artifacts/xash3d-fwgs-win32-$ARCH.7z" -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \ + ./*.dll ./*.exe ./*.pdb activities.txt \ valve/ diff --git a/scripts/ios/buildallmods.sh b/scripts/ios/buildallmods.sh index acbf9380..10c2764c 100755 --- a/scripts/ios/buildallmods.sh +++ b/scripts/ios/buildallmods.sh @@ -1,6 +1,8 @@ +#!/bin/bash + #cd into script directory SCRIPTDIR=${0%/*} -cd $SCRIPTDIR +cd "$SCRIPTDIR" || exit 1 #shouldn't build any mods that are supported by mobile_hacks ./buildhlsdk.sh aghl _ag @@ -40,4 +42,4 @@ export XENWARRIOR=ON cd ../../ -./createipa.sh \ No newline at end of file +./createipa.sh diff --git a/scripts/ios/buildhlsdk.sh b/scripts/ios/buildhlsdk.sh index 7d2e74fc..7bb6a7e2 100755 --- a/scripts/ios/buildhlsdk.sh +++ b/scripts/ios/buildhlsdk.sh @@ -2,33 +2,33 @@ #cd into script directory SCRIPTDIR=${0%/*} -cd $SCRIPTDIR +cd "$SCRIPTDIR" || exit 1 MODPATH=mod-build/$1 -if [ -z $1 ]; then +if [ -z "$1" ]; then MODPATH=mod-build/hlsdk - git clone --recursive https://github.com/FWGS/hlsdk-portable -b mobile_hacks $MODPATH + git clone --recursive https://github.com/FWGS/hlsdk-portable -b mobile_hacks "$MODPATH" else - git clone --recursive https://github.com/FWGS/hlsdk-portable -b $1 $MODPATH + git clone --recursive https://github.com/FWGS/hlsdk-portable -b "$1" "$MODPATH" fi -mkdir ../../build/ios +mkdir ../../build/ios || exit 1 IOSDIR=$(realpath ../../build/ios) -cd $MODPATH +cd "$MODPATH" || exit 1 #compiling hlsdk for ios release is broken, so just build for debug -cmake -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DGAMEDIR=$IOSDIR -DCMAKE_BUILD_TYPE=Debug -B build -S . +cmake -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DGAMEDIR="$IOSDIR" -DCMAKE_BUILD_TYPE=Debug -B build -S . cmake --build build --target install -if [ ! -z $2 ]; then - mv $IOSDIR/cl_dlls/client_arm64.dylib $IOSDIR/cl_dlls/client_arm64$2.dylib +if [ ! -z "$2" ]; then + mv "$IOSDIR/cl_dlls/client_arm64.dylib" "$IOSDIR/cl_dlls/client_arm64$2.dylib" else -cd ../../ -./createipa.sh + cd ../../ + ./createipa.sh fi if [ -d mod-build ]; then rm -rf mod-build/ fi -exit 0 \ No newline at end of file +exit 0 diff --git a/scripts/ios/createipa.sh b/scripts/ios/createipa.sh index eb522602..5b29eeae 100755 --- a/scripts/ios/createipa.sh +++ b/scripts/ios/createipa.sh @@ -1,45 +1,48 @@ #!/bin/bash #cd into script directory -cd "${0%/*}" -BUILDDIR=$(realpath ../../build) -cd "../../engine/platform/ios/bundle" +cd "${0%/*}" || exit 1 -if [ -d $BUILDDIR ]; then +BUILDDIR=$(realpath ../../build) + +cd "../../engine/platform/ios/bundle" || exit 1 + +if [ -d "$BUILDDIR" ]; then mkdir -p "$BUILDDIR/ios/xash3d.app" cp -r "$BUILDDIR/ios/dlls" "$BUILDDIR/ios/xash3d.app" cp -r "$BUILDDIR/ios/cl_dlls" "$BUILDDIR/ios/xash3d.app" cp Info.plist "$BUILDDIR/ios/xash3d.app" cp ftp_commands.plist "$BUILDDIR/ios/xash3d.app" - if [ ! -d $BUILDDIR/SDL2.framework ]; then + if [ ! -d "$BUILDDIR/SDL2.framework" ]; then echo "Couldn't find SDL2.framework, place it in the build directory" exit 1 fi - cp -r $BUILDDIR/SDL2.framework "$BUILDDIR/ios/xash3d.app" + cp -r "$BUILDDIR/SDL2.framework" "$BUILDDIR/ios/xash3d.app" - cd ../../../../ + cd ../../../../ || exit 1 ./waf build install --destdir="$BUILDDIR/ios/xash3d.app" #echo "Generating dSYMs" #find "$BUILDDIR/ios/xash3d.app" -name "*.dylib" -type f -exec dsymutil {} \; #dsymutil "$BUILDDIR/ios/xash3d.app/xash" - cd $BUILDDIR + cd "$BUILDDIR" || exit 1 rm -r "$BUILDDIR/ios/Payload/" mkdir "$BUILDDIR/ios/Payload" cp -r "$BUILDDIR/ios/xash3d.app" ios/Payload/ rm -r "$BUILDDIR/ios/xash3d.app" - cd ios - codesign --entitlements $(realpath ../../engine/platform/ios/bundle/entitlements.plist) --sign "-" --force Payload/xash3d.app + cd ios || exit 1 + codesign --entitlements "$(realpath ../../engine/platform/ios/bundle/entitlements.plist)" --sign "-" --force Payload/xash3d.app if [ -e ../xash3d.ipa ]; then - rm ../xash3d.ipa + rm ../xash3d.ipa fi zip -q -r ../xash3d.ipa Payload - else +else echo "Couldn't find the build directory, compile the engine before running this script!" exit 1 fi + exit 0