Skip to content

Commit

Permalink
build script and action updates from upu
Browse files Browse the repository at this point in the history
  • Loading branch information
burner1024 committed Apr 15, 2024
1 parent 0e414c3 commit 7e4e95c
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: ShellCheck
uses: ludeeus/action-shellcheck@master

- name: Run tests
run: ./extra/tests.sh

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: ShellCheck
uses: ludeeus/action-shellcheck@master

- name: Run tests
run: ./extra/tests.sh
62 changes: 35 additions & 27 deletions extra/buildall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,45 @@
set -xeu -o pipefail

# exporting for subshell
export src="$(realpath scripts_src)"
export dst="$(realpath data/scripts)"
export scripts_lst="$dst/scripts.lst"
export compile_exe="$bin_dir/compile.exe"
src="$(realpath scripts_src)"
export src
dst="$(realpath data/scripts)"
export dst
scripts_lst="$dst/scripts.lst"
export scripts_lst
# shellcheck disable=SC2154 # bin_dir defined in env.sh
compile_exe="$bin_dir/compile.exe"
export compile_exe

# wine doesn't return proper error code on missing file
if [[ ! -f $compile_exe ]]; then
echo "compile.exe missing, failed"
exit 1
echo "compile.exe missing, failed"
exit 1
fi

# compile all
for d in $(ls $src); do
if [[ -d "$src/$d" && "$d" != "template" ]]; then # if it's a dir and not a template
cd "$src/$d"
files=""
for f in $(ls | grep -i "\.ssl$"); do # build file list
int="$(echo $f | sed 's|\.ssl$|.int|')"
if grep -qi "^$int " "$scripts_lst" || [[ "$d" == "global" ]]; then # if file is in scripts.lst or a global script
script_name="$(echo "$f" | sed 's|\.ssl$|.int|')"
gcc -E -x c -P -Werror -Wfatal-errors -o "${f}.tmp" "$f" # preprocess
set +e
wine "$compile_exe" -n -l -q -O2 "$f.tmp" -o "$dst/$script_name" # compile
if [[ "$?" != "0" ]]; then # 1 retry on wine connection reset
set -e
sleep 1
wine "$compile_exe" -n -l -q -O2 "$f.tmp" -o "$dst/$script_name" # compile
fi
set -e
fi
done
cd ..
fi
# shellcheck disable=SC2045 # We shouldn't have non-alphanumeric names here.
for d in $(ls "$src"); do
if [[ -d "$src/$d" && "$d" != "template" ]]; then # if it's a dir and not a template
cd "$src/$d"
# build file list
# shellcheck disable=SC2010 # We shouldn't have non-alphanumeric names here.
for f in $(ls | grep -i "\.ssl$"); do
# shellcheck disable=SC2001 # Simple replacement doesn't work, need regex.
int="$(echo "$f" | sed 's|\.ssl$|.int|')"
if grep -qi "^$int " "$scripts_lst" || [[ "$d" == "global" ]]; then # if file is in scripts.lst or a global script
gcc -E -x c -P -Werror -Wfatal-errors -o "${f}.tmp" "$f" # preprocess
set +e
wine "$compile_exe" -n -l -q -O2 "$f.tmp" -o "$dst/$int" # compile
# shellcheck disable=SC2181 # Long commands are unwieldy in if conditions.
if [[ "$?" != "0" ]]; then # 1 retry on wine connection reset
set -e
sleep 1
wine "$compile_exe" -n -l -q -O2 "$f.tmp" -o "$dst/$int" # compile
fi
set -e
fi
done
cd ..
fi
done
9 changes: 6 additions & 3 deletions extra/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

set -xeu -o pipefail

export extra_dir="$(realpath extra)"
extra_dir="$(realpath extra)"
export extra_dir
export bin_dir="$extra_dir/bin"
export release_dir="$(realpath release)"
release_dir="$(realpath release)"
export release_dir
export mods_dir="$release_dir/mods"
export mpack_version=${mpack_version:-4.4}
export mpack_7z="mpack.7z"
export sfall_version=${sfall_version:-4.4.0.1}
export WINEARCH=win32
export WINEDEBUG=-all
export mod_name=rpu
export trans_dir="$(realpath translations)"
trans_dir="$(realpath translations)"
export trans_dir

export appearance_repo="BGforgeNet/Fallout2_Hero_Appearance"
export party_orders_repo="BGforgeNet/Fallout2_Party_Orders"
Expand Down
3 changes: 2 additions & 1 deletion extra/full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

set -xeu -o pipefail

rm -f *.7z *.zip *.exe *.list
rm -f ./*.7z ./*.zip ./*.exe ./*.list

# shellcheck source=/dev/null # doesn't matter, no vars used in this script
source ./extra/env.sh
./extra/prepare.sh
./extra/buildall.sh
Expand Down
36 changes: 22 additions & 14 deletions extra/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
set -xeu -o pipefail

export comp_dir="components"
# shellcheck disable=SC2154 # bin_dir from env.sh
export dat2="wine $bin_dir/dat2.exe"
export dat2a="wine $bin_dir/dat2.exe a"
export trans_dir="$(realpath translations)"
export file_list="$(realpath dat2.list)"
trans_dir="$(realpath translations)"
export trans_dir
file_list="$(realpath dat2.list)"
export file_list

short_sha="$(git rev-parse --short HEAD)"
# defaults, local build or github non-tagged
export version="git$short_sha"
export vversion="$version" # in package names
export uversion="$version" # in game

if [[ ! -z "${GITHUB_REF-}" ]]; then # github build
if echo "$GITHUB_REF" | grep "refs/tags"; then # tagged
version="$(echo $GITHUB_REF | sed 's|refs\/tags\/v||')"
export version
export vversion="v$version"
export uversion="u$version" # in game
fi
if [[ -n "${GITHUB_REF-}" ]]; then # github build
if echo "$GITHUB_REF" | grep "refs/tags"; then # tagged
# shellcheck disable=SC2001 # sed is more readable
version="$(echo "$GITHUB_REF" | sed 's|refs\/tags\/v||')"
export version
export vversion="v$version"
export uversion="u$version" # in game
fi
fi

# cleanup for local build
Expand All @@ -29,22 +33,25 @@ git clean -fd release
git clean -fdX release

# wine pollutes the log with "wine: Read access denied for device" if z is linked to /
z="$(readlink -f ~/.wine/dosdevices/z\:)"
z="$(readlink -f ~/.wine/dosdevices/z:)"
if [[ "$z" == "/" ]]; then
rm -f ~/.wine/dosdevices/z\:
ln -s /home ~/.wine/dosdevices/z\:
rm -f ~/.wine/dosdevices/z:
ln -s /home ~/.wine/dosdevices/z:
fi

# translations packaged first, to get extra text out of the way
# shellcheck disable=SC2154 # extra_dir from env.sh
"$extra_dir"/package/translations.sh

# data
# shellcheck disable=SC2154 # from env.sh
dat="$mod_name.dat"
# shellcheck disable=SC2154 # from env.sh
mkdir -p "$mods_dir"

cd data
# I don't know how to pack recursively
find . -type f | sed -e 's|^\.\/||' -e 's|\/|\\|g' | sort > "$file_list" # replace slashes with backslashes
find . -type f | sed -e 's|^\.\/||' -e 's|\/|\\|g' | sort >"$file_list" # replace slashes with backslashes
$dat2a "$mods_dir/$dat" @"$file_list"
cd ..

Expand Down Expand Up @@ -74,8 +81,9 @@ cd ..

# manual package: linux/mac os
pushd .
# shellcheck disable=SC2154 # from env.sh
cd "$release_dir"
zip -r "${mod_name}_${vversion}.zip" * # our package
zip -r "${mod_name}_${vversion}.zip" -- * # our package
popd
mv "$release_dir/${mod_name}_${vversion}.zip" .

Expand Down
2 changes: 2 additions & 0 deletions extra/package/ammo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

set -xeu -o pipefail

# shellcheck disable=SC2154 # from env.sh
scripts_dir="$release_dir/data/scripts"

mkdir -p "$scripts_dir"
# shellcheck disable=SC2154 # from env.sh
7zr e "$mpack_7z" example_mods/AmmoMod/gl_ammomod.int
mv gl_ammomod.int "$release_dir/"

Expand Down
6 changes: 5 additions & 1 deletion extra/package/animation_fixes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ export optional_dir="optional"
mkdir -p "$optional_dir"
cd "$optional_dir"
for f in goris_fast_derobing_low_fps.dat walk_speed_fix_low_fps.dat; do
wget -nv "$(curl -s $api_url | grep browser_download_url | grep $f | awk -F '"' '{print $4}')"
# extra steps for easier debug
url0=$(curl "$api_url")
echo "$url0"
url="$(echo "$url0" | grep browser_download_url | grep $f | awk -F '"' '{print $4}')"
wget -nv "$url"
done
4 changes: 3 additions & 1 deletion extra/package/appearance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

set -xeu -o pipefail

# shellcheck disable=SC2154 # from env.sh
api_url="https://api.github.com/repos/${appearance_repo}/releases/latest"

# shellcheck disable=SC2154 # from env.sh
cd "$release_dir"
wget -nv "$(curl -s $api_url | grep browser_download_url | grep -v non_canon | awk -F '"' '{print $4}')"
wget -nv "$(curl -s "$api_url" | grep browser_download_url | grep -v non_canon | awk -F '"' '{print $4}')"
unzip hero_appearance*.zip
rm -f hero_appearance*.zip
1 change: 1 addition & 0 deletions extra/package/cassidy_head.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -xeu -o pipefail

api_url="https://api.github.com/repos/BGforgeNet/Fallout2_Cassidy_Head/releases/latest"

# shellcheck disable=SC2154 # from env.sh
cd "$release_dir"
for f in cassidy_head.dat cassidy_voice_joey_bracken_hq.dat; do
wget -nv "$(curl -s $api_url | grep browser_download_url | grep $f | awk -F '"' '{print $4}')"
Expand Down
20 changes: 12 additions & 8 deletions extra/package/components.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ comp_dir="components"

# pack components into separate dat files
if [[ -d "$comp_dir" ]]; then
cd "$comp_dir"
for c in $(ls); do
dat="${mod_name}_$c.dat"
cd "$c"
find . -type f | sed -e 's|^\.\/||' -e 's|\/|\\|g' | sort > "$file_list"
$dat2a "$mods_dir/$dat" @"$file_list"
cd "$comp_dir"
# shellcheck disable=SC2045 # let it break on strange names
for c in $(ls); do
# shellcheck disable=SC2154 # from env.sh
dat="${mod_name}_$c.dat"
cd "$c"
# shellcheck disable=SC2154 # from env.sh
find . -type f | sed -e 's|^\.\/||' -e 's|\/|\\|g' | sort >"$file_list"
# shellcheck disable=SC2154 # from env.sh
$dat2a "$mods_dir/$dat" @"$file_list"
cd ..
done
cd ..
done
cd ..
fi
1 change: 1 addition & 0 deletions extra/package/hq_music.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -xeu -o pipefail

# shellcheck disable=SC2154 # from env.sh
sound_dir="$release_dir/data/sound/music"

rm -rf "$sound_dir"
Expand Down
11 changes: 8 additions & 3 deletions extra/package/inno.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ mkdir -p Output
chmod 0777 Output

# delete unnecessary files
# shellcheck disable=SC2154 # from env.sh
rm -f "$release_dir"/{rpu-install.sh,rpu-install.command}
# shellcheck disable=SC2154 # from env.sh
sed -i "s|define uversion .*|define uversion \"${uversion}\"|" "$install_iss"
# shellcheck disable=SC2154 # from env.sh
sed -i "s|define vversion .*|define vversion \"${vversion}\"|" "$install_iss"

rm -rf release translations
cp -r $release_dir ./
cp -r "$release_dir" ./
mkdir translations
mv $trans_dir/*.dat translations/
# shellcheck disable=SC2154 # from env.sh
mv "$trans_dir"/*.dat translations/

# move optional components
mkdir optional
Expand All @@ -31,9 +35,10 @@ mv ./release/mods/cassidy_voice_joey_bracken_hq.dat optional/
mv ./release/mods/rpu_improved_mysterious_stranger.dat optional/

# alternative animations, not included into manual install
# shellcheck disable=SC2154 # from env.sh
"$extra_dir"/package/animation_fixes.sh

docker run --rm -i -v $PWD:/work amake/innosetup "$install_iss"
docker run --rm -i -v "$PWD":/work amake/innosetup "$install_iss"
rm -rf release translations
popd

Expand Down
4 changes: 3 additions & 1 deletion extra/package/npc_armor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -xeu -o pipefail

# shellcheck disable=SC2154 # from env.sh
cd "$release_dir"
wget -nv "$(curl -s https://api.github.com/repos/${npc_armor_repo}/releases/latest | grep browser_download_url | awk -F '"' '{print $4}')"
# shellcheck disable=SC2154 # from env.sh
wget -nv "$(curl -s "https://api.github.com/repos/${npc_armor_repo}/releases/latest" | grep browser_download_url | awk -F '"' '{print $4}')"
unzip npc_armor*.zip "mods/*"
rm -f npc_armor*.zip
4 changes: 3 additions & 1 deletion extra/package/party_orders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -xeu -o pipefail

# shellcheck disable=SC2154 # from env.sh
cd "$release_dir"
wget -nv "$(curl -s https://api.github.com/repos/${party_orders_repo}/releases/latest | grep browser_download_url | awk -F '"' '{print $4}')"
# shellcheck disable=SC2154 # from env.sh
wget -nv "$(curl -s "https://api.github.com/repos/${party_orders_repo}/releases/latest" | grep browser_download_url | awk -F '"' '{print $4}')"
unzip party_orders*.zip mods/party_orders.ini mods/party_orders.dat
rm -f party_orders*.zip
15 changes: 9 additions & 6 deletions extra/package/sfall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

set -xeu -o pipefail

# shellcheck disable=SC2154 # from env.sh
release_ini="$release_dir/ddraw.ini"
# shellcheck disable=SC2154 # from env.sh
custom_ini="$extra_dir/package/ddraw.ini"

# shellcheck disable=SC2154 # from env.sh
sfall_url="https://sourceforge.net/projects/sfall/files/sfall/sfall_$sfall_version.7z/download"

cd "$release_dir"
Expand All @@ -19,21 +21,22 @@ mods/sfall-mods.ini
translations
"
for f in $files; do
rm -rf "$f"
7zr x sfall.7z "$f"
rm -rf "$f"
7zr x sfall.7z "$f"
done
rm -f sfall.7z

# uncomment ini settings to preserve options' placement in ddraw.ini
entries="$(cat $custom_ini | grep '=' | awk -F '=' '{print $1}')"
entries="$(grep '=' "$custom_ini" | awk -F '=' '{print $1}')"
for e in $entries; do
sed -i "s|^;$e=|$e=|" "$release_ini"
sed -i "s|^;$e=|$e=|" "$release_ini"
done

# then merge custom settings
crudini --merge "$release_ini" < "$custom_ini"
crudini --merge "$release_ini" <"$custom_ini"
# set version string
sed -i "s|^;VersionString=|VersionString=|" "$release_ini"
# shellcheck disable=SC2154 # from env.sh
crudini --set "$release_ini" "Misc" "VersionString" "FALLOUT II 1.02d RP 2.3.3${uversion}"
# crudini adds spaces arouns the values, need to remove them
sed -i "s|^\([[:alnum:]]\+\) = |\1=|" "$release_ini"
Expand Down
Loading

0 comments on commit 7e4e95c

Please sign in to comment.