2021-03-06 18:21:18 -05:00
|
|
|
#!/bin/bash
|
2021-02-14 18:36:09 -05:00
|
|
|
#
|
|
|
|
# "I will be a shieldmaiden no longer,
|
|
|
|
# nor vie with the great Riders, nor
|
|
|
|
# take joy only in the songs of slaying.
|
|
|
|
# I will be a healer, and love all things
|
|
|
|
# that grow and are not barren."
|
|
|
|
# Éowyn, The Return of the King
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This script shall heal the little broken programs
|
|
|
|
# using the patches in this directory and convey them
|
|
|
|
# to convalesce in the healed directory.
|
|
|
|
#
|
2023-04-24 12:09:47 -04:00
|
|
|
set -e
|
2021-02-14 18:36:09 -05:00
|
|
|
|
2021-03-12 19:59:17 -05:00
|
|
|
# We check ourselves before we wreck ourselves.
|
2023-04-07 10:22:52 -04:00
|
|
|
if [ ! -f patches/eowyn.sh ]
|
2021-03-12 19:59:17 -05:00
|
|
|
then
|
|
|
|
echo "But I must be run from the project root directory."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-02-14 18:36:09 -05:00
|
|
|
|
2023-04-25 17:34:56 -04:00
|
|
|
# Which version we have?
|
2023-10-05 14:18:04 -04:00
|
|
|
echo "Zig version" $(zig version)
|
|
|
|
echo "Eowyn version 23.10.5.1, let's try our magic power."
|
|
|
|
echo ""
|
2023-04-25 17:34:56 -04:00
|
|
|
|
2021-03-12 19:59:17 -05:00
|
|
|
# Create directory of healing if it doesn't already exist.
|
|
|
|
mkdir -p patches/healed
|
2021-02-14 18:36:09 -05:00
|
|
|
|
|
|
|
# Cycle through all the little broken Zig applications.
|
2021-03-12 19:59:17 -05:00
|
|
|
for broken in exercises/*.zig
|
2021-02-14 18:36:09 -05:00
|
|
|
do
|
|
|
|
# Remove the dir and extension, rendering the True Name.
|
2023-04-07 10:22:52 -04:00
|
|
|
true_name=$(basename "$broken" .zig)
|
2021-03-12 19:59:17 -05:00
|
|
|
patch_name="patches/patches/$true_name.patch"
|
2021-02-14 18:36:09 -05:00
|
|
|
|
2023-04-07 10:22:52 -04:00
|
|
|
if [ -f "$patch_name" ]
|
2021-02-14 18:36:09 -05:00
|
|
|
then
|
|
|
|
# Apply the bandages to the wounds, grow new limbs, let
|
|
|
|
# new life spring into the broken bodies of the fallen.
|
2023-04-07 10:22:52 -04:00
|
|
|
echo Healing "$true_name"...
|
2023-10-05 14:18:04 -04:00
|
|
|
cp "$broken" "patches/healed/$true_name.zig"
|
|
|
|
patch -i "$patch_name" "patches/healed/$true_name.zig"
|
|
|
|
|
2021-02-14 18:36:09 -05:00
|
|
|
else
|
2023-04-07 10:22:52 -04:00
|
|
|
echo Cannot heal "$true_name". No patch found.
|
2021-02-14 18:36:09 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2023-04-24 12:09:47 -04:00
|
|
|
echo "Looking for non-conforming code formatting..."
|
2023-04-29 10:58:10 -04:00
|
|
|
zig fmt --check patches/healed
|
2023-04-16 12:07:51 -04:00
|
|
|
|
2021-02-14 18:36:09 -05:00
|
|
|
# Test the healed exercises. May the compiler have mercy upon us.
|
|
|
|
zig build -Dhealed
|