1
0

merge fixes, debug mode

This commit is contained in:
GenZmeY 2022-01-24 03:20:41 +03:00
parent 48b3a87401
commit abce563023

120
builder
View File

@ -4,7 +4,6 @@
# https://git-scm.com/download/win
set -Eeuo pipefail
# set -o xtrace
trap cleanup SIGINT SIGTERM ERR EXIT
@ -174,35 +173,46 @@ function read_test_settings ()
fi
}
function merge_packages () # $1: Mutator name
function merge_package () # $1: What, $2: Where
{
local ModificationTime=""
local UpkList=""
local ModificationTimeNew=""
local PID=""
ModificationTime=$(stat -c %y "$KFWin64/$2")
CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditorMergePackages") make $1 $2" &
PID="$!"
while ps -p "$PID" &> /dev/null
do
ModificationTimeNew="$(stat -c %y "$KFWin64/$2")"
if [[ "$ModificationTime" != "$ModificationTimeNew" ]]; then # wait for write
while ps -p "$PID" &> /dev/null
do
ModificationTime="$ModificationTimeNew"
sleep 1
ModificationTimeNew="$(stat -c %y "$KFWin64/$2")"
if [[ "$ModificationTime" == "$ModificationTimeNew" ]]; then # wait for write finish
kill "$PID"
rm -f "$KFWin64/$1" # cleanup (auto)
return 0
fi
done
fi
sleep 1
done
rm -f "$KFWin64/$1" # cleanup (manual)
}
function merge_packages () # $1: Mutator name
{
cp -f "$KFUnpublishScript/$1.u" "$KFWin64"
while read -r Upk
do
cp -f "$MutSource/$1/$Upk" "$KFWin64"
UpkList="$UpkList $Upk"
merge_package "$Upk" "$1.u"
done < <(find "$MutSource/$1" -type f -name '*.upk' -printf "%f\n")
if [[ -n "$UpkList" ]]; then
ModificationTime=$(stat -c %y "$KFWin64/$1.u")
CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditorMergePackages") make $UpkList $1.u" &
PID="$!"
while ps -p "$PID" &> /dev/null
do
if [[ "$ModificationTime" != "$(stat -c %y "$KFWin64/$1.u")" ]]; then # file changed
sleep 2 # wait a bit in case the file hasn't been written to the end yet
kill "$PID"; break
fi
sleep 2
done
fi
for Upk in $UpkList; do rm -f "$KFWin64/$Upk"; done # cleanup
}
function compiled ()
@ -261,7 +271,7 @@ function compile ()
while ps -p "$PID" &> /dev/null
do
if compiled; then kill "$PID"; break; fi
sleep 2
sleep 1
done
restore_kfeditorconf
@ -310,7 +320,7 @@ function brew ()
while ps -p "$PID" &> /dev/null
do
if brewed; then kill "$PID"; break; fi
sleep 2
sleep 1
done
publish_common
@ -329,18 +339,18 @@ function brew_manual ()
rm -rf "$KFPublish"
mkdir -p "$KFPublishBrewedPC" "$KFPublishScript"
mkdir -p "$KFPublishBrewedPC"
if ! [[ -x "$KFEditorPatcher" ]]; then
get_latest_kfeditor_patcher "$KFEditorPatcher"
fi
pushd "$KFWin64" && "$KFEditorPatcher"; popd
CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditorPatcher")"
for Package in $PackageUpload
do
merge_packages "$Package"
mv "$KFWin64/$Package.u" "$KFPublishScript"
mv "$KFWin64/$Package.u" "$KFPublishBrewedPC"
done
publish_common
@ -473,30 +483,54 @@ function run_test ()
CMD //C "$(cygpath -w "$KFGame") $Map?Difficulty=$Difficulty?GameLength=$GameLength?Game=$Game?Mutator=$Mutators?$Args $UseUnpublished" -log
}
function debug ()
{
set -o xtrace
}
export PATH="$PATH:$ThirdPartyBin"
if [[ $# -eq 0 ]]; then show_help; exit 0; fi
case $1 in
# Options
-h|--help ) show_help ;;
-v|--version ) show_version ;;
-ib|--init-build ) init_build ;;
-it|--init-test ) init_test ;;
-i|--init ) init_build; init_test ;;
-c|--compile ) compile ;;
-b|--brew ) brew ;;
-bm|--brew-manual ) brew_manual ;;
-u|--upload ) upload ;;
-t|--test ) run_test ;;
-h|--help ) show_help ;;
-v|--version ) show_version ;;
-ib|--init-build ) init_build ;;
-it|--init-test ) init_test ;;
-i|--init ) init_build; init_test ;;
-c|--compile ) compile ;;
-b|--brew ) brew ;;
-bm|--brew-manual ) brew_manual ;;
-u|--upload ) upload ;;
-t|--test ) run_test ;;
# Shortcuts
-cb ) compile; brew ;;
-cu ) compile; upload ;;
-cbm ) compile; brew_manual ;;
-cbu ) compile; brew; upload ;;
-cbmu ) compile; brew_manual; upload ;;
-ct ) compile; run_test ;;
-cbt ) compile; brew; run_test ;;
-cbmt ) compile; brew_manual; run_test ;;
-cb ) compile; brew ;;
-cu ) compile; upload ;;
-cbm ) compile; brew_manual ;;
-cbu ) compile; brew; upload ;;
-cbmu ) compile; brew_manual; upload ;;
-ct ) compile; run_test ;;
-cbt ) compile; brew; run_test ;;
-cbmt ) compile; brew_manual; run_test ;;
# Debug
-dh ) debug; show_help ;;
-dv ) debug; show_version ;;
-dib ) debug; init_build ;;
-dit ) debug; init_test ;;
-di ) debug; init_build; init_test ;;
-dc ) debug; compile ;;
-db ) debug; brew ;;
-dbm ) debug; brew_manual ;;
-du ) debug; upload ;;
-dt ) debug; run_test ;;
-dcb ) debug; compile; brew ;;
-dcu ) debug; compile; upload ;;
-dcbm ) debug; compile; brew_manual ;;
-dcbu ) debug; compile; brew; upload ;;
-dcbmu ) debug; compile; brew_manual; upload ;;
-dct ) debug; compile; run_test ;;
-dcbt ) debug; compile; brew; run_test ;;
-dcbmt ) debug; compile; brew_manual; run_test ;;
# Other
* ) echo "Command not recognized: $1"; exit 1 ;;
esac