2022-01-10 07:00:54 +00:00
#!/bin/bash
2022-02-13 23:20:24 +00:00
# Copyright (C) 2022 GenZmeY
# mailto: genzmey@gmail.com
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2022-01-10 07:00:54 +00:00
# Requirements: git-bash
# https://git-scm.com/download/win
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
2022-02-13 23:57:53 +00:00
function reg_readkey () # $1: path, $2: key
{
2022-02-20 01:24:39 +00:00
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
cygpath -u "$(
reg query "$1" //v "$2" | \
grep -F "$2" | \
awk '{ $1=$2=""; print $0 }' | \
sed -r 's|^\s*(.+)\s*|\1|g')"
fi
2022-02-13 23:57:53 +00:00
}
2022-02-13 17:15:24 +00:00
# Whoami
2022-03-20 03:29:28 +00:00
ScriptFullname="$(readlink -e "$0")"
ScriptName="$(basename "$0")"
ScriptDir="$(dirname "$ScriptFullname")"
2022-01-10 07:00:54 +00:00
# Common
2022-03-20 03:29:28 +00:00
SteamPath="$(reg_readkey "HKCU\Software\Valve\Steam" "SteamPath")"
DocumentsPath="$(reg_readkey "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Personal")"
2022-01-10 07:00:54 +00:00
ThirdPartyBin="$ScriptDir/3rd-party-bin"
2022-02-20 23:50:11 +00:00
DummyPreview="$ScriptDir/dummy_preview.png"
2022-01-10 07:00:54 +00:00
# Usefull KF2 executables / Paths / Configs
KFDoc="$DocumentsPath/My Games/KillingFloor2"
KFPath="$SteamPath/steamapps/common/killingfloor2"
2022-03-20 03:29:28 +00:00
KFDev="$KFPath/Development/Src"
2022-01-10 07:00:54 +00:00
KFWin64="$KFPath/Binaries/Win64"
KFEditor="$KFWin64/KFEditor.exe"
KFEditorPatcher="$KFWin64/kfeditor_patcher.exe"
KFEditorMergePackages="$KFWin64/KFEditor_mergepackages.exe"
KFGame="$KFWin64/KFGame.exe"
KFWorkshop="$KFPath/Binaries/WorkshopUserTool.exe"
KFUnpublish="$KFDoc/KFGame/Unpublished"
KFPublish="$KFDoc/KFGame/Published"
KFEditorConf="$KFDoc/KFGame/Config/KFEditor.ini"
2022-03-20 00:39:31 +00:00
KFLogs="$KFDoc/KFGame/Logs"
2022-01-10 07:00:54 +00:00
# Source filesystem
2022-03-20 03:29:28 +00:00
MutSource="$(readlink -e "$ScriptDir/..")"
2022-01-10 07:00:54 +00:00
MutConfig="$MutSource/Config"
MutLocalization="$MutSource/Localization"
2022-09-01 15:48:41 +00:00
MutBrewedPCAddon="$MutSource/BrewedPC"
2022-02-20 23:50:11 +00:00
MutBuilderConfig="$MutSource/builder.cfg"
MutPubContent="$MutSource/PublicationContent"
MutPubContentDescription="$MutPubContent/description.txt"
MutPubContentTitle="$MutPubContent/title.txt"
2022-06-06 05:39:44 +00:00
MutPubContentPreview="$MutPubContent/preview"
2022-02-20 23:50:11 +00:00
MutPubContentTags="$MutPubContent/tags.txt"
2022-01-10 07:00:54 +00:00
# Steam workshop upload filesystem
KFUnpublishBrewedPC="$KFUnpublish/BrewedPC"
KFUnpublishPackages="$KFUnpublishBrewedPC/Packages"
KFUnpublishScript="$KFUnpublishBrewedPC/Script"
KFUnpublishConfig="$KFUnpublish/Config"
KFUnpublishLocalization="$KFUnpublish/Localization"
KFPublishBrewedPC="$KFPublish/BrewedPC"
KFPublishPackages="$KFPublishBrewedPC/Packages"
KFPublishScript="$KFPublishBrewedPC/Script"
KFPublishConfig="$KFPublish/Config"
KFPublishLocalization="$KFPublish/Localization"
# Tmp files
2022-01-14 22:22:30 +00:00
MutWsInfo="$KFDoc/wsinfo.txt"
2022-01-10 07:00:54 +00:00
KFEditorConfBackup="$KFEditorConf.backup"
2022-02-13 23:11:02 +00:00
# Args
2022-02-20 23:50:11 +00:00
ArgInit="false"
2022-02-13 23:11:02 +00:00
ArgCompile="false"
ArgBrew="false"
ArgUpload="false"
ArgTest="false"
ArgVersion="false"
ArgHelp="false"
ArgDebug="false"
ArgQuiet="false"
2022-03-20 03:39:36 +00:00
ArgHoldEditor="false"
2022-02-13 23:11:02 +00:00
ArgNoColors="false"
2022-02-20 23:50:11 +00:00
ArgForce="false"
2022-02-13 23:11:02 +00:00
2022-02-14 00:47:44 +00:00
# Colors
RED=''
GRN=''
YLW=''
2022-02-14 01:11:24 +00:00
BLU=''
2022-02-14 00:47:44 +00:00
DEF=''
BLD=''
2022-06-06 05:39:44 +00:00
# PNG
DummyPreviewRaw='\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x00\x20\x00\x00\x00\x20\x01\x03\x00\x00\x00\x49\xb4\xe8\xb7\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\x00\x00\x00\x06\x50\x4c\x54\x45\x00\x00\x00\xff\xff\xff\xa5\xd9\x9f\xdd\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95\x2b\x0e\x1b\x00\x00\x00\x14\x49\x44\x41\x54\x18\xd3\x63\x60\x60\xf8\xff\x9f\x9a\x04\x55\x4d\x63\x60\x00\x00\xed\xbd\x3f\xc1\xbb\x2a\xd9\x62\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82'
2022-02-13 17:15:24 +00:00
function is_true () # $1: Bool arg to check
{
echo "$1" | grep -Piq '^true$'
}
function get_latest () # $1: Reponame, $2: filename, $3: output filename
{
local ApiUrl="https://api.github.com/repos/$1/releases/latest"
2022-02-13 23:11:02 +00:00
local LatestTag=""
2022-03-20 03:52:08 +00:00
LatestTag="$(curl --silent "$ApiUrl" | grep -Po '"tag_name": "\K.*?(?=")')"
2022-02-13 17:15:24 +00:00
local DownloadUrl="https://github.com/$1/releases/download/$LatestTag/$2"
2022-02-14 01:11:24 +00:00
msg "download $2 ($LatestTag)"
2022-02-13 17:15:24 +00:00
mkdir -p "$(dirname "$3")/"
curl -LJs "$DownloadUrl" -o "$3"
2022-02-14 01:57:54 +00:00
msg "${GRN}successfully downloaded${DEF}"
2022-02-13 17:15:24 +00:00
}
function get_latest_multini () # $1: file to save
{
get_latest "GenZmeY/multini" "multini-windows-amd64.exe" "$1"
}
function get_latest_kfeditor_patcher () # $1: file to save
{
get_latest "notpeelz/kfeditor-patcher" "kfeditor_patcher.exe" "$1"
}
2022-02-20 23:50:11 +00:00
function repo_url () # $1: remote.origin.url
{
if echo "$1" | grep -qoP '^https?://'; then
echo "$1" | sed -r 's|\.git||'
else
echo "$1" | sed -r 's|^.+:(.+)\.git$|https://github.com/\1|'
fi
}
2022-02-13 23:11:02 +00:00
function setup_colors ()
{
if [[ -t 2 ]] && ! is_true "$ArgNoColors" && [[ "${TERM-}" != "dumb" ]]; then
RED='\e[31m'
GRN='\e[32m'
YLW='\e[33m'
2022-02-14 01:11:24 +00:00
BLU='\e[34m'
2022-02-13 23:11:02 +00:00
DEF='\e[0m'
BLD='\e[1m'
fi
2022-01-10 07:00:54 +00:00
}
2022-02-13 23:11:02 +00:00
function err () # $1: String
2022-01-12 22:04:34 +00:00
{
2022-02-13 23:11:02 +00:00
if ! is_true "$ArgQuiet"; then
echo -e "${RED}${1-}${DEF}" >&2
fi
}
function msg () # $1: String
{
if ! is_true "$ArgQuiet"; then
2022-02-14 01:11:24 +00:00
if is_true "$ArgDebug"; then
echo -e "${BLU}${1-}${DEF}" >&1
else
2022-02-14 01:57:54 +00:00
echo -e "${DEF}${1-}${DEF}" >&1
2022-02-14 01:11:24 +00:00
fi
2022-02-13 23:11:02 +00:00
fi
}
function die () # $1: String, $2: Exit code
{
err "${1-}"
exit "${2-3}"
}
2022-06-06 05:39:44 +00:00
function warn () # $1: String
{
2022-06-15 17:55:42 +00:00
msg "${YLW}${1-}${DEF}"
2022-06-06 05:39:44 +00:00
}
2022-02-13 23:11:02 +00:00
function usage ()
{
2022-02-14 00:08:18 +00:00
local HelpMessage=""
2022-03-20 03:52:08 +00:00
HelpMessage="$(cat <<EOF
2022-02-14 00:08:18 +00:00
${BLD}Usage:${DEF} $0 OPTIONS
2022-02-21 00:06:02 +00:00
Compile, brew, test and upload your kf2 packages to the Steam Workshop.
2022-02-14 00:08:18 +00:00
${BLD}Available options:${DEF}
2022-02-20 23:50:11 +00:00
-i, --init generate $(basename "$MutBuilderConfig") and $(basename "$MutPubContent")
2022-02-21 00:06:02 +00:00
-c, --compile compile package(s)
2022-02-14 00:08:18 +00:00
-b, --brew compress *.upk and place inside *.u
-u, --upload upload package(s) to the Steam Workshop
2022-02-20 23:50:11 +00:00
-t, --test run local single player test
-f, --force overwrites existing files when used with --init
2022-02-14 00:08:18 +00:00
-q, --quiet run without output
2022-03-20 03:39:36 +00:00
-he, --hold-editor do not close kf2editor automatically
2022-02-14 00:08:18 +00:00
-nc, --no-colors do not use color output
-d, --debug print every executed command (script debug)
-v, --version show version
-h, --help show this help
${BLD}Short options can be combined, examples:${DEF}
2022-09-01 09:25:37 +00:00
-if recreate build.cfg and PublicationContent, replace old ones
2022-02-14 00:08:18 +00:00
-cbu compile, brew, upload
2022-03-21 16:11:14 +00:00
-cbhe compile and brew without closing kf2editor
2022-02-14 00:08:18 +00:00
etc...
EOF
2022-03-20 03:52:08 +00:00
)"
2022-02-14 00:08:18 +00:00
msg "$HelpMessage"
2022-02-13 23:11:02 +00:00
}
function version ()
{
2022-06-15 18:01:40 +00:00
local Version=""
Version="$(git describe 2> /dev/null)"
if [[ -z "$Version" ]]; then
Version="(standalone)"
fi
msg "${BLD}$ScriptName $Version${DEF}"
2022-01-12 22:04:34 +00:00
}
2022-01-10 07:00:54 +00:00
function cleanup()
{
trap - SIGINT SIGTERM ERR EXIT
restore_kfeditorconf
}
function backup_kfeditorconf ()
{
2022-09-26 05:38:11 +00:00
if [[ -e "$KFEditorConf" ]]; then
msg "backup $(basename "$KFEditorConf") to $(basename "$KFEditorConfBackup")"
cp -f "$KFEditorConf" "$KFEditorConfBackup"
else
die "$(basename "$KFEditorConf") not found! Run KF2 Editor to generate the config" 2
fi
2022-01-10 07:00:54 +00:00
}
function restore_kfeditorconf ()
{
if [[ -f "$KFEditorConfBackup" ]]; then
2022-02-14 01:57:54 +00:00
msg "restore $(basename "$KFEditorConf") from backup"
2022-01-10 07:00:54 +00:00
mv -f "$KFEditorConfBackup" "$KFEditorConf"
fi
}
2022-09-02 08:52:07 +00:00
function print_list () # $1: List with spaces, $2: New separator
{
echo "${1// /$2}"
}
2022-02-20 23:50:11 +00:00
function init ()
2022-01-10 07:00:54 +00:00
{
local PackageList=""
2022-02-20 23:50:11 +00:00
local AviableMutators=""
local AviableGamemodes=""
2022-09-02 08:52:07 +00:00
local AviableMaps=""
2022-02-20 23:50:11 +00:00
local ProjectName=""
local GitUsername=""
local GitRemoteUrl=""
local PublicationTags=""
2022-09-02 08:52:07 +00:00
local DefGamemode=""
local DefMap=""
local BaseList=""
local BaseListNext=""
2022-02-20 23:50:11 +00:00
if [[ -e "$MutBuilderConfig" ]]; then
if is_true "$ArgForce"; then
msg "rewriting $(basename "$MutBuilderConfig")"
fi
else
msg "creating new $(basename "$MutBuilderConfig")"
fi
2022-09-02 08:52:07 +00:00
2022-09-02 09:56:32 +00:00
if [[ -d "$MutBrewedPCAddon" ]]; then
while read -r Map
do
if [[ -z "$AviableMaps" ]]; then
DefMap="$Map"
AviableMaps="$Map"
else
AviableMaps="$AviableMaps $Map"
fi
done < <(find "$MutBrewedPCAddon" -type f -iname '*.kfm' -printf "%f\n" | sort)
fi
2022-02-20 23:50:11 +00:00
2022-01-14 22:22:30 +00:00
while read -r Package
2022-01-10 07:00:54 +00:00
do
if [[ -z "$PackageList" ]]; then
PackageList="$Package"
else
PackageList="$PackageList $Package"
fi
done < <(find "$MutSource" -mindepth 2 -maxdepth 2 -type d -ipath '*/Classes' | sed -r 's|.+/([^/]+)/[^/]+|\1|' | sort)
2022-09-02 08:52:07 +00:00
if [[ -n "$PackageList" ]]; then
msg "packages found: $(print_list "$PackageList" ", ")"
2022-03-24 02:42:57 +00:00
fi
2022-09-02 08:52:07 +00:00
# DISCLAMER: BigO nightmare (*)
# Remove seniors with a weak psyche from the screen
#
# (*) As planned though:
# Initialized once and quickly even on large projects,
# There is no point in optimizing this
if [[ -n "$PackageList" ]]; then
2022-02-20 23:50:11 +00:00
# find available mutators
2022-09-02 08:52:07 +00:00
BaseList='(KF)?Mutator'
BaseListNext=''
while [[ -n "$BaseList" ]]
2022-02-20 23:50:11 +00:00
do
2022-09-02 08:52:07 +00:00
for Base in $BaseList
do
for Package in $PackageList
do
while read -r Class
do
if [[ -z "$AviableMutators" ]]; then
AviableMutators="$Package.$Class"
else
AviableMutators="$AviableMutators $Package.$Class"
fi
if [[ -z "$BaseListNext" ]]; then
BaseListNext="$Class"
else
BaseListNext="$BaseListNext $Class"
fi
2022-09-02 13:06:41 +00:00
done < <(grep -rihPo "\s.+extends\s${Base}(\W|$)" "${MutSource}/${Package}" | awk '{ print $1 }')
2022-09-02 08:52:07 +00:00
done
done
BaseList="$BaseListNext"
BaseListNext=""
done
2022-02-20 23:50:11 +00:00
# find available gamemodes
2022-09-02 08:52:07 +00:00
BaseList='KFGameInfo_'
BaseListNext=''
while [[ -n "$BaseList" ]]
2022-02-20 23:50:11 +00:00
do
2022-09-02 08:52:07 +00:00
for Base in $BaseList
do
for Package in $PackageList
do
while read -r Class
do
if [[ -z "$AviableGamemodes" ]]; then
AviableGamemodes="$Package.$Class"
if [[ -z "$DefGamemode" ]]; then
DefGamemode="$Package.$Class"
fi
else
AviableGamemodes="$AviableGamemodes $Package.$Class"
fi
if [[ -z "$BaseListNext" ]]; then
BaseListNext="$Class"
else
BaseListNext="$BaseListNext $Class"
fi
2022-09-02 13:06:41 +00:00
done < <(grep -rihPo "\s.+extends\s${Base}(\W|$)" "${MutSource}/${Package}" | awk '{ print $1 }')
2022-09-02 08:52:07 +00:00
done
done
BaseList="$BaseListNext"
BaseListNext=""
done
fi
2022-02-20 23:50:11 +00:00
if [[ -n "$AviableMutators" ]]; then
2022-09-02 08:52:07 +00:00
msg "mutators found: $(print_list "$AviableMutators" ", ")"
2022-02-20 23:50:11 +00:00
fi
if [[ -z "$AviableGamemodes" ]]; then
2022-09-02 08:52:07 +00:00
DefGamemode="KFGameContent.KFGameInfo_Survival"
2022-02-20 23:50:11 +00:00
else
2022-09-02 08:52:07 +00:00
msg "custom gamemodes found: $(print_list "$AviableGamemodes" ", ")"
fi
if [[ -z "$AviableMaps" ]]; then
DefMap="KF-Nuked"
else
msg "maps found: $(print_list "$AviableMaps" ", ")"
2022-02-20 23:50:11 +00:00
fi
if is_true "$ArgForce" || ! [[ -e "$MutBuilderConfig" ]]; then
cat > "$MutBuilderConfig" <<EOF
### Build parameters ###
2022-01-16 02:07:46 +00:00
# If True - compresses the mutator when compiling
# Scripts will be stored in binary form
# (reduces the size of the output file)
StripSource="True"
# Mutators to be compiled
# Specify them with a space as a separator,
# Mutators will be compiled in the specified order
PackageBuildOrder="$PackageList"
2022-02-20 23:50:11 +00:00
2022-09-01 09:25:37 +00:00
### Brew parameters ###
# Packages you want to brew using @peelz's patched KFEditor.
# Useful for cases where regular brew doesn't put *.upk inside the package.
# Specify them with a space as a separator,
# The order doesn't matter
PackagePeelzBrew=""
2022-02-20 23:50:11 +00:00
### Steam Workshop upload parameters ###
2022-01-16 02:07:46 +00:00
# Mutators that will be uploaded to the workshop
# Specify them with a space as a separator,
# The order doesn't matter
PackageUpload="$PackageList"
2022-02-14 01:57:54 +00:00
2022-01-10 07:00:54 +00:00
2022-02-20 23:50:11 +00:00
### Test parameters ###
# Map:
2022-09-02 08:52:07 +00:00
Map="$DefMap"
2022-02-20 23:50:11 +00:00
# Game:
# Survival: KFGameContent.KFGameInfo_Survival
# WeeklyOutbreak: KFGameContent.KFGameInfo_WeeklySurvival
# Endless: KFGameContent.KFGameInfo_Endless
# Objective: KFGameContent.KFGameInfo_Objective
# Versus: KFGameContent.KFGameInfo_VersusSurvival
2022-09-02 08:52:07 +00:00
Game="$DefGamemode"
2022-02-20 23:50:11 +00:00
# Difficulty:
# Normal: 0
# Hard: 1
# Suicide: 2
# Hell: 3
Difficulty="0"
# GameLength:
# 4 waves: 0
# 7 waves: 1
# 10 waves: 2
GameLength="0"
# Mutators
2022-09-02 08:52:07 +00:00
Mutators="$(print_list "$AviableMutators" ",")"
2022-02-20 23:50:11 +00:00
# Additional parameters
Args=""
EOF
msg "${GRN}$(basename "$MutBuilderConfig") created${DEF}"
fi
2022-01-10 07:00:54 +00:00
2022-02-20 23:50:11 +00:00
if ! [[ -d "$MutPubContent" ]]; then mkdir -p "$MutPubContent"; fi
2022-03-20 03:52:08 +00:00
ProjectName="$(basename "$(readlink -e "$MutSource")")"
2022-02-20 23:50:11 +00:00
if is_true "$ArgForce" || ! [[ -e "$MutPubContentTitle" ]]; then
echo "$ProjectName" > "$MutPubContentTitle"
msg "${GRN}$(basename "$MutPubContentTitle") created${DEF}"
fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentDescription" ]]; then
:> "$MutPubContentDescription"
2022-09-02 08:52:07 +00:00
if [[ -n "$AviableGamemodes" ]] || [[ -n "$AviableMutators" ]] || [[ -n "$AviableMaps" ]]; then
2022-02-20 23:50:11 +00:00
echo "[h1]Description[/h1]" >> "$MutPubContentDescription"
2022-09-02 08:52:07 +00:00
if [[ -n "$AviableMaps" ]]; then
echo "[b]Maps:[/b][list][*]$(print_list "$AviableMaps" '[*]')[/list]" >> "$MutPubContentDescription"
fi
2022-02-20 23:50:11 +00:00
if [[ -n "$AviableGamemodes" ]]; then
2022-09-02 08:52:07 +00:00
echo "[b]Gamemodes:[/b][list][*]$(print_list "$AviableGamemodes" '[*]')[/list]" >> "$MutPubContentDescription"
2022-02-20 23:50:11 +00:00
fi
if [[ -n "$AviableMutators" ]]; then
2022-09-02 08:52:07 +00:00
echo "[b]Mutators:[/b][list][*]$(print_list "$AviableMutators" '[*]')[/list]" >> "$MutPubContentDescription"
2022-02-20 23:50:11 +00:00
fi
echo "" >> "$MutPubContentDescription"
fi
2022-03-20 03:52:08 +00:00
GitRemoteUrl="$(repo_url "$(git config --get remote.origin.url)")"
2022-02-20 23:50:11 +00:00
if [[ -n "$GitRemoteUrl" ]]; then
{
echo "[h1]Sources[/h1]"
echo "[url=${GitRemoteUrl}]${GitRemoteUrl}[/url]"
echo ""
} >> "$MutPubContentDescription"
fi
2022-03-20 03:52:08 +00:00
GitUsername="$(git config --get user.name)"
2022-02-20 23:50:11 +00:00
if [[ -n "$GitUsername" ]]; then
{
echo "[h1]Author[/h1]"
echo "[url=https://github.com/${GitUsername}]${GitUsername}[/url]"
echo ""
} >> "$MutPubContentDescription"
fi
msg "${GRN}$(basename "$MutPubContentDescription") created${DEF}"
fi
2022-06-06 05:39:44 +00:00
if is_true "$ArgForce" || [[ "$(preview_extension)" == "None" ]]; then
if [[ -e "$DummyPreview" ]]; then
cp -f "$DummyPreview" "${MutPubContentPreview}.png"
else
printf '%b' "$DummyPreviewRaw" > "${MutPubContentPreview}.png"
fi
msg "${GRN}$(basename "${MutPubContentPreview}.png") created${DEF}"
2022-02-20 23:50:11 +00:00
fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentTags" ]]; then
:> "$MutPubContentTags"
if [[ -n "$AviableGamemodes" ]]; then
PublicationTags="Gamemodes"
fi
if [[ -n "$AviableMutators" ]]; then
if [[ -n "$PublicationTags" ]]; then
PublicationTags="$PublicationTags,Mutators"
else
PublicationTags="Mutators"
fi
echo "$PublicationTags" >> "$MutPubContentTags"
fi
msg "${GRN}$(basename "$MutPubContentTags") created${DEF}"
2022-01-10 07:00:54 +00:00
fi
}
2022-06-06 05:39:44 +00:00
function preview_extension ()
{
for Ext in gif png jpg jpeg
do
if [[ -e "${MutPubContentPreview}.${Ext}" ]]; then
echo "$Ext"
return 0
fi
done
echo "None"
}
2022-02-20 23:50:11 +00:00
function read_settings ()
2022-01-10 07:00:54 +00:00
{
2022-02-20 23:50:11 +00:00
if ! [[ -f "$MutBuilderConfig" ]]; then init; fi
2022-01-10 07:00:54 +00:00
2022-02-20 23:50:11 +00:00
if bash -n "$MutBuilderConfig"; then
# shellcheck source=./.shellcheck/builder.cfg
source "$MutBuilderConfig"
2022-01-10 07:00:54 +00:00
else
2022-02-20 23:50:11 +00:00
die "$MutBuilderConfig broken! Check this file before continue or create new one using --force --init" 2
2022-01-10 07:00:54 +00:00
fi
}
2022-01-24 00:20:41 +00:00
function merge_package () # $1: What, $2: Where
2022-01-10 07:00:54 +00:00
{
2022-01-14 22:22:30 +00:00
local ModificationTime=""
2022-01-24 00:20:41 +00:00
local ModificationTimeNew=""
2022-01-14 22:22:30 +00:00
local PID=""
2022-01-10 07:00:54 +00:00
2022-02-14 01:11:24 +00:00
msg "merge $1 into $2"
2022-02-13 23:11:02 +00:00
2022-03-20 03:39:36 +00:00
if is_true "$ArgHoldEditor"; then
2022-02-13 23:11:02 +00:00
CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditorMergePackages") make $1 $2"
else
2022-03-20 03:52:08 +00:00
ModificationTime="$(stat -c %y "$KFWin64/$2")"
2022-02-13 23:11:02 +00:00
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
fi
2022-01-24 00:20:41 +00:00
rm -f "$KFWin64/$1" # cleanup (manual)
}
function merge_packages () # $1: Mutator name
{
2022-02-13 23:11:02 +00:00
msg "merge packages for $1.u"
2022-01-10 07:00:54 +00:00
cp -f "$KFUnpublishScript/$1.u" "$KFWin64"
2022-01-14 22:22:30 +00:00
while read -r Upk
2022-01-10 07:00:54 +00:00
do
2022-06-22 18:26:58 +00:00
cp -f "$Upk" "$KFWin64"
merge_package "$(basename "$Upk")" "$1.u"
2022-10-01 21:11:34 +00:00
done < <(find "$MutSource/$1" -type f -iname '*.upk' -not -ipath "*/Weapons/*")
2022-01-10 07:00:54 +00:00
}
2022-03-20 03:29:28 +00:00
function parse_log () # $1: Logfile
{
local File=''
local FileUnix=''
local FileCompact=''
local Line=''
local Message=''
2022-03-24 02:42:57 +00:00
local I=1
if grep -qP ' Error:(.+:)? Error, ' "$1"; then # check to prevent a very strange crash
2022-03-20 03:29:28 +00:00
while read -r Error
do
if [[ -z "$Error" ]]; then break; fi
2022-03-24 02:42:57 +00:00
Message="$(echo "$Error" | sed -r 's|^.+Error:.+Error, (.+)$|\1|')"
File="$(echo "$Error" | sed -r 's|^.+Error: ((.+)\(([0-9]+)\) : )?Error,(.+)$|\2|')"
if [[ -n "$File" ]]; then
FileUnix="$(cygpath -u "$File")"
FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")"
Line="$(echo "$Error" | sed -r 's|^.+Error: ((.+)\(([0-9]+)\) : )?Error,(.+)$|\3|')"
2022-06-06 05:39:44 +00:00
err "[$I] $FileCompact($Line): $Message"
2022-03-24 02:42:57 +00:00
else
2022-06-06 05:39:44 +00:00
err "[$I] $Message"
2022-03-24 02:42:57 +00:00
fi
((I+=1))
done < <(grep -P ' Error:(.+:)? Error, ' "$1")
2022-03-20 03:29:28 +00:00
fi
2022-03-24 02:42:57 +00:00
if grep -qP ' Warning:(.+:)? Warning, ' "$1"; then # and here too
2022-03-20 03:29:28 +00:00
while read -r Warning
do
if [[ -z "$Warning" ]]; then break; fi
2022-03-24 02:42:57 +00:00
Message="$(echo "$Warning" | sed -r 's|^.+Warning:.+Warning, (.+)$|\1|')"
if echo "$Message" | grep -qF 'Unknown language extension . Defaulting to INT'; then continue; fi
File="$(echo "$Warning" | sed -r 's|^.+Warning: ((.+)\(([0-9]+)\) : )?Warning,(.+)$|\2|')"
if [[ -n "$File" ]]; then
FileUnix="$(cygpath -u "$File")"
FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")"
Line="$(echo "$Warning" | sed -r 's|^.+Warning: ((.+)\(([0-9]+)\) : )?Warning,(.+)$|\3|')"
2022-06-06 05:39:44 +00:00
warn "[$I] $FileCompact($Line): $Message"
2022-03-24 02:42:57 +00:00
else
2022-06-06 05:39:44 +00:00
warn "[$I] $Message"
2022-03-24 02:42:57 +00:00
fi
((I+=1))
done < <(grep -P ' Warning:(.+:)? Warning, ' "$1")
2022-03-20 03:29:28 +00:00
fi
}
2022-01-10 07:00:54 +00:00
function compiled ()
{
for Package in $PackageBuildOrder
do
if ! test -f "$KFUnpublishScript/$Package.u"; then
return 1
fi
done
}
2022-03-25 08:14:48 +00:00
function find_log ()
{
2022-10-01 21:11:34 +00:00
find "$KFLogs" -type f -iname '*.log' -printf '%T+ %p\n' | sort -r | head -n1 | cut -f2- -d" "
2022-03-25 08:14:48 +00:00
}
2022-01-10 07:00:54 +00:00
function compile ()
{
2022-01-16 02:07:46 +00:00
local StripSourceArg=""
2022-01-14 22:22:30 +00:00
local PID=""
2022-03-20 03:29:28 +00:00
local Logfile=""
2022-01-14 22:22:30 +00:00
2022-02-20 23:50:11 +00:00
read_settings
2022-01-15 02:48:16 +00:00
2022-01-10 07:00:54 +00:00
if ! command -v multini &> /dev/null; then
2022-01-15 02:48:16 +00:00
get_latest_multini "$ThirdPartyBin/multini.exe"
2022-01-10 07:00:54 +00:00
fi
2022-03-24 02:42:57 +00:00
if [[ -z "$PackageBuildOrder" ]]; then
die "No packages found! Check project filesystem, fix config and try again"
fi
2022-01-10 07:00:54 +00:00
multini --del "$KFEditorConf" 'ModPackages' 'ModPackages'
for Package in $PackageBuildOrder
do
multini --add "$KFEditorConf" 'ModPackages' 'ModPackages' "$Package"
done
multini --set "$KFEditorConf" 'ModPackages' 'ModPackagesInPath' "$(cygpath -w "$MutSource")"
rm -rf "$KFUnpublish" "$KFPublish"
mkdir -p "$KFUnpublishPackages" "$KFUnpublishScript"
2022-01-12 22:04:34 +00:00
2022-01-14 22:22:30 +00:00
for Package in $PackageBuildOrder
do
2022-10-01 21:11:34 +00:00
find "$MutSource/$Package" -type f -iname '*.upk' -not -ipath "*/Weapons/*" -exec cp -f {} "$KFUnpublishPackages" \;
find "$MutSource/$Package" -type d -iname 'WwiseAudio' -exec cp -rf {} "$KFUnpublishBrewedPC" \;
find "$MutSource/$Package" -type d -iname 'Weapons' -exec cp -rf {} "$KFUnpublishPackages" \;
2022-01-14 22:22:30 +00:00
done
2022-01-10 07:00:54 +00:00
if [[ -d "$MutLocalization" ]]; then
mkdir -p "$KFUnpublishLocalization"
cp -rf "$MutLocalization"/* "$KFUnpublishLocalization"
fi
if [[ -d "$MutConfig" ]]; then
mkdir -p "$KFUnpublishConfig"
cp -rf "$MutConfig"/* "$KFUnpublishConfig"
fi
2022-01-16 02:07:46 +00:00
if is_true "$StripSource"; then StripSourceArg="-stripsource"; fi
2022-02-14 00:35:07 +00:00
msg "compilation"
2022-03-20 03:39:36 +00:00
if is_true "$ArgHoldEditor"; then
2023-03-30 01:20:37 +00:00
CMD //C "$(cygpath -w "$KFEditor")" make $StripSourceArg -useunpublished
2022-03-25 08:14:48 +00:00
parse_log "$(find_log)"
2022-02-13 23:11:02 +00:00
if ! compiled; then
2022-02-14 00:47:44 +00:00
die "compilation failed"
2022-02-13 23:11:02 +00:00
fi
2022-02-14 01:57:54 +00:00
msg "${GRN}successfully compiled${DEF}"
2022-02-13 23:11:02 +00:00
else
2023-03-30 01:20:37 +00:00
CMD //C "$(cygpath -w "$KFEditor")" make $StripSourceArg -useunpublished &
2022-02-13 23:11:02 +00:00
PID="$!"
while ps -p "$PID" &> /dev/null
do
2022-03-20 03:29:28 +00:00
sleep 1
2022-03-25 08:14:48 +00:00
Logfile="$(find_log)"
2022-02-14 00:35:07 +00:00
if compiled; then
2022-02-14 01:57:54 +00:00
msg "${GRN}successfully compiled${DEF}"
2022-03-20 03:29:28 +00:00
msg "wait for the log"
while ! grep -qF 'Log file closed' "$Logfile"
do
sleep 1
done
kill "$PID"
parse_log "$Logfile"
2022-02-14 00:35:07 +00:00
break
2022-03-20 03:29:28 +00:00
elif grep -qF 'Log file closed' "$Logfile"; then
kill "$PID"
parse_log "$Logfile"
die "compilation failed"
2022-02-14 00:35:07 +00:00
fi
2022-02-13 23:11:02 +00:00
done
fi
2022-01-24 04:17:19 +00:00
find "$KFUnpublish" -type d -empty -delete
2022-01-10 07:00:54 +00:00
}
function publish_common ()
{
if [[ -d "$MutLocalization" ]]; then
mkdir -p "$KFPublishLocalization"
cp -rf "$MutLocalization"/* "$KFPublishLocalization"
fi
if [[ -d "$MutConfig" ]]; then
mkdir -p "$KFPublishConfig"
cp -rf "$MutConfig"/* "$KFPublishConfig"
fi
2022-09-01 15:48:41 +00:00
if [[ -d "$MutBrewedPCAddon" ]]; then
mkdir -p "$KFPublishBrewedPC"
cp -rf "$MutBrewedPCAddon"/* "$KFPublishBrewedPC"
fi
2022-01-10 07:00:54 +00:00
}
2022-09-01 09:25:37 +00:00
function brewed () # $1: Wait for packages
2022-01-10 07:00:54 +00:00
{
2022-09-01 09:25:37 +00:00
for Package in $1
2022-01-10 07:00:54 +00:00
do
if ! test -f "$KFPublishBrewedPC/$Package.u"; then
return 1
fi
done
}
2022-01-24 02:26:49 +00:00
function brew_cleanup ()
{
for Package in $PackageBuildOrder
do
if ! echo "$PackageUpload" | grep -Pq "(^|\s+)$Package(\s+|$)"; then
2022-10-01 21:11:34 +00:00
find "$KFPublishBrewedPC" -type f -iname "$Package.u" -delete
find "$MutSource/$Package" -type f -iname '*.upk' -printf "%f\n" | xargs -I{} find "$KFPublishBrewedPC" -type f -iname {} -delete
2022-01-24 02:26:49 +00:00
fi
done
}
2022-01-10 07:00:54 +00:00
function brew ()
{
2022-09-01 09:25:37 +00:00
local PackageBrew=""
2022-01-14 22:22:30 +00:00
local PID=""
2022-02-14 00:35:07 +00:00
msg "brewing"
2022-02-13 23:11:02 +00:00
2022-02-20 23:50:11 +00:00
read_settings
2022-01-10 07:00:54 +00:00
2022-06-06 05:39:44 +00:00
if ! compiled; then
2022-02-13 23:11:02 +00:00
die "You must compile packages before brewing. Use --compile option for this." 2
2022-01-10 07:00:54 +00:00
fi
2022-09-01 09:25:37 +00:00
if [[ -z "$PackagePeelzBrew" ]]; then
PackageBrew="$PackageBuildOrder"
else
for Package in $PackageBuildOrder
do
if ! echo "$PackagePeelzBrew" | grep -Pq "(^|\s+)$Package(\s+|$)"; then
PackageBrew="$Package "
fi
done
fi
2022-01-10 07:00:54 +00:00
rm -rf "$KFPublish"
2022-10-01 21:11:34 +00:00
mkdir -p "$KFPublishBrewedPC" "$KFPublishPackages"
for Package in $PackageBuildOrder
do
find "$MutSource/$Package" -type d -iname 'WwiseAudio' -exec cp -rf {} "$KFPublishBrewedPC" \;
find "$MutSource/$Package" -type d -iname 'Weapons' -exec cp -rf {} "$KFPublishPackages" \;
done
2022-01-10 07:00:54 +00:00
2022-09-08 14:21:06 +00:00
if [[ -n "$PackageBrew" ]]; then
if is_true "$ArgHoldEditor"; then
CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditor") brewcontent -platform=PC $PackageBrew -useunpublished"
if ! brewed "$PackageBrew"; then
brew_cleanup
die "brewing failed"
fi
else
CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditor") brewcontent -platform=PC $PackageBrew -useunpublished" &
PID="$!"
while ps -p "$PID" &> /dev/null
do
if brewed "$PackageBrew"; then
kill "$PID"
break
fi
sleep 1
done
if ! brewed "$PackageBrew"; then
brew_cleanup
die "brewing failed"
2022-02-14 00:35:07 +00:00
fi
2022-03-19 23:29:27 +00:00
fi
2022-02-13 23:11:02 +00:00
fi
2022-01-10 07:00:54 +00:00
2022-09-01 09:25:37 +00:00
if [[ -n "$PackagePeelzBrew" ]]; then
msg "peelz brewing"
if ! [[ -x "$KFEditorPatcher" ]]; then
get_latest_kfeditor_patcher "$KFEditorPatcher"
fi
msg "patching $(basename "$KFEditor")"
CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditorPatcher")"
msg "${GRN}successfully patched${DEF}"
for Package in $PackagePeelzBrew
do
merge_packages "$Package"
mv "$KFWin64/$Package.u" "$KFPublishBrewedPC"
2022-10-01 21:11:34 +00:00
find "$MutSource/$Package" -type f -iname '*.upk' -not -ipath '*/Weapons/*' -printf "%f\n" | xargs -I{} find "$KFPublishBrewedPC" -type f -iname {} -delete
2022-09-01 09:25:37 +00:00
done
2022-01-10 07:00:54 +00:00
fi
2022-02-14 01:57:54 +00:00
msg "${GRN}successfully brewed${DEF}"
2022-02-14 01:11:24 +00:00
2022-09-01 09:25:37 +00:00
rm -f "$KFPublishBrewedPC"/*.tmp
2022-01-24 03:22:17 +00:00
2022-01-24 04:17:19 +00:00
find "$KFPublish" -type d -empty -delete
2022-01-24 03:22:17 +00:00
}
function publish_unpublished ()
{
2022-06-06 05:39:44 +00:00
warn "uploading without brewing${DEF}"
2022-02-14 01:57:54 +00:00
2022-01-24 03:22:17 +00:00
mkdir -p "$KFPublishBrewedPC" "$KFPublishScript" "$KFPublishPackages"
for Package in $PackageUpload
do
cp -f "$KFUnpublishScript/$Package.u" "$KFPublishScript"
2022-10-01 21:11:34 +00:00
find "$MutSource/$Package" -type f -iname '*.upk' -not -ipath '*/Weapons/*' -exec cp -f {} "$KFPublishPackages" \;
find "$MutSource/$Package" -type d -iname 'WwiseAudio' -exec cp -rf {} "$KFPublishBrewedPC" \;
find "$MutSource/$Package" -type d -iname 'Weapons' -exec cp -rf {} "$KFPublishPackages" \;
2022-01-24 03:22:17 +00:00
done
2022-01-24 04:17:19 +00:00
find "$KFPublish" -type d -empty -delete
2022-01-10 07:00:54 +00:00
}
function upload ()
{
2022-01-14 22:22:30 +00:00
local PreparedWsDir=""
2022-06-06 05:39:44 +00:00
local Preview=""
local Success="False"
2022-01-14 22:22:30 +00:00
2022-02-20 23:50:11 +00:00
read_settings
2022-01-10 07:00:54 +00:00
2022-09-01 15:48:41 +00:00
if ! compiled && ! test -d "$MutBrewedPCAddon"; then
2022-02-13 23:11:02 +00:00
die "You must compile packages before uploading. Use --compile option for this." 2
2022-01-10 07:00:54 +00:00
fi
2022-09-01 09:25:37 +00:00
if [[ -d "$KFPublish" ]]; then
brew_cleanup
2022-09-01 15:48:41 +00:00
elif [[ -d "$KFUnpublish" ]]; then
2022-01-24 03:22:17 +00:00
publish_unpublished
2022-01-10 07:00:54 +00:00
fi
2022-09-01 15:48:41 +00:00
publish_common
2022-06-06 05:39:44 +00:00
Preview="${MutPubContentPreview}.$(preview_extension)"
if ! [[ -e "$Preview" ]]; then
die "No preview image in PublicationContent" 2
elif [[ $(stat --printf="%s" "$Preview") -ge 1048576 ]]; then
warn "The size of $(basename "$Preview") is greater than 1mb. Steam may prevent you from loading content with this image. if you get an error while loading - try using a smaller preview."
fi
2022-01-24 04:17:19 +00:00
find "$KFPublish" -type d -empty -delete
2022-01-10 07:00:54 +00:00
2022-09-01 15:48:41 +00:00
# it's a bad idea to use the $KFPublish folder for upload
# because in that case some files won't get uploaded to the workshop for some reason
# so create a temporary folder to get around this
2022-03-20 03:52:08 +00:00
PreparedWsDir="$(mktemp -d -u -p "$KFDoc")"
2022-01-24 03:22:17 +00:00
2022-01-10 07:00:54 +00:00
cat > "$MutWsInfo" <<EOF
2022-02-20 23:50:11 +00:00
\$Description "$(cat "$MutPubContentDescription")"
\$Title "$(cat "$MutPubContentTitle")"
2022-06-06 05:39:44 +00:00
\$PreviewFile "$(cygpath -w "$Preview")"
2022-02-20 23:50:11 +00:00
\$Tags "$(cat "$MutPubContentTags")"
2022-01-16 04:18:08 +00:00
\$MicroTxItem "false"
\$PackageDirectory "$(cygpath -w "$PreparedWsDir")"
2022-01-10 07:00:54 +00:00
EOF
2022-01-15 02:48:16 +00:00
cp -rf "$KFPublish" "$PreparedWsDir"
2022-01-10 07:00:54 +00:00
2022-02-14 01:57:54 +00:00
msg "upload to steam workshop"
2022-06-06 05:39:44 +00:00
while read -r Output
do
if echo "$Output" | grep -qiF 'Successfully uploaded workshop file to Steam'; then
Success="True"
break
elif echo "$Output" | grep -qiF 'error'; then
err "UploadTool: $Output"
fi
done < <("$KFWorkshop" "$(basename "$MutWsInfo")" 2>&1)
2022-01-10 07:00:54 +00:00
rm -rf "$PreparedWsDir"
rm -f "$MutWsInfo"
2022-06-06 05:39:44 +00:00
if is_true "$Success"; then
msg "${GRN}successfully uploaded to steam workshop${DEF}"
else
die "upload to steam workshop failed" 2
fi
2022-01-10 07:00:54 +00:00
}
function run_test ()
{
local UseUnpublished=""
2022-02-20 23:50:11 +00:00
read_settings
2022-01-10 07:00:54 +00:00
2022-09-01 09:25:37 +00:00
if brewed "$PackageBuildOrder"; then
2022-03-25 08:14:48 +00:00
msg "run test (brewed)"
else
2022-02-14 01:57:54 +00:00
UseUnpublished="-useunpublished"
msg "run test (unpublished)"
fi
2022-01-10 07:00:54 +00:00
2022-01-15 02:48:16 +00:00
CMD //C "$(cygpath -w "$KFGame") $Map?Difficulty=$Difficulty?GameLength=$GameLength?Game=$Game?Mutator=$Mutators?$Args $UseUnpublished" -log
2022-01-10 07:00:54 +00:00
}
2022-02-13 23:11:02 +00:00
function parse_combined_params () # $1: Combined short parameters
{
local Param="${1}"
local Length="${#Param}"
local Position=1
while true
do
2022-02-14 02:10:22 +00:00
if [[ "$Position" -ge "$Length" ]]; then break; fi
2022-02-13 23:11:02 +00:00
case "${Param:$Position:2}" in
2022-06-06 05:39:44 +00:00
he ) ((Position+=2)); ArgHoldEditor="true" ;;
nc ) ((Position+=2)); ArgNoColors="true" ;;
2022-02-13 23:11:02 +00:00
esac
2022-02-14 01:11:24 +00:00
if [[ "$Position" -ge "$Length" ]]; then break; fi
2022-02-13 23:11:02 +00:00
case "${Param:$Position:1}" in
2022-06-06 05:39:44 +00:00
h ) ((Position+=1)); ArgHelp="true" ;;
v ) ((Position+=1)); ArgVersion="true" ;;
i ) ((Position+=1)); ArgInit="true" ;;
c ) ((Position+=1)); ArgCompile="true" ;;
b ) ((Position+=1)); ArgBrew="true" ;;
u ) ((Position+=1)); ArgUpload="true" ;;
t ) ((Position+=1)); ArgTest="true" ;;
d ) ((Position+=1)); ArgDebug="true" ;;
q ) ((Position+=1)); ArgQuiet="true" ;;
f ) ((Position+=1)); ArgForce="true" ;;
* ) die "Unknown short option: -${Param:$Position:1}" 1 ;;
2022-02-13 23:11:02 +00:00
esac
done
}
function parse_params () # $@: Args
{
while true
do
case "${1-}" in
2022-06-06 05:39:44 +00:00
-h | --help ) ArgHelp="true" ;;
-v | --version ) ArgVersion="true" ;;
-i | --init ) ArgInit="true" ;;
-c | --compile ) ArgCompile="true" ;;
-b | --brew ) ArgBrew="true" ;;
-u | --upload ) ArgUpload="true" ;;
-t | --test ) ArgTest="true" ;;
-d | --debug ) ArgDebug="true" ;;
-q | --quiet ) ArgQuiet="true" ;;
-he | --hold-editor ) ArgHoldEditor="true" ;;
-nc | --no-color ) ArgNoColors="true" ;;
-f | --force ) ArgForce="true" ;;
--* ) die "Unknown option: ${1}" 1 ;;
-* ) parse_combined_params "${1}" ;;
2022-02-13 23:11:02 +00:00
* ) if [[ -n "${1-}" ]]; then die "Unknown option: ${1-}" 1; fi; break ;;
esac
shift
done
}
function main ()
{
if [[ $# -eq 0 ]]; then usage; die "" 0; fi
parse_params "$@"
setup_colors
export PATH="$PATH:$ThirdPartyBin"
# Modifiers
2022-03-25 08:14:48 +00:00
if is_true "$ArgDebug"; then set -o xtrace; fi
2022-02-13 23:11:02 +00:00
2022-03-20 00:39:31 +00:00
# Help
2022-02-21 00:06:02 +00:00
if is_true "$ArgVersion" && is_true "$ArgHelp"; then version; usage; die "" 0; fi
if is_true "$ArgVersion"; then version; die "" 0; fi
if is_true "$ArgHelp"; then usage; die "" 0; fi
2022-03-20 00:39:31 +00:00
# Backup
2022-03-25 08:14:48 +00:00
if is_true "$ArgCompile" || is_true "$ArgBrew"; then backup_kfeditorconf; fi
2022-03-20 00:39:31 +00:00
# Actions
2022-02-21 00:06:02 +00:00
if is_true "$ArgInit"; then init; fi
if is_true "$ArgCompile"; then compile; fi
if is_true "$ArgBrew"; then brew; fi
if is_true "$ArgUpload"; then upload; fi
if is_true "$ArgTest"; then run_test; fi
2022-03-20 00:39:31 +00:00
# Restore
2022-03-25 08:14:48 +00:00
if is_true "$ArgCompile" || is_true "$ArgBrew"; then restore_kfeditorconf; fi
2022-02-13 23:11:02 +00:00
}
main "$@"