eowyn.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. #
  3. # "I will be a shieldmaiden no longer,
  4. # nor vie with the great Riders, nor
  5. # take joy only in the songs of slaying.
  6. # I will be a healer, and love all things
  7. # that grow and are not barren."
  8. # Éowyn, The Return of the King
  9. #
  10. #
  11. # This script shall heal the little broken programs
  12. # using the patches in this directory and convey them
  13. # to convalesce in the healed directory.
  14. #
  15. set -e
  16. # We check ourselves before we wreck ourselves.
  17. if [ ! -f patches/eowyn.sh ]
  18. then
  19. echo "But I must be run from the project root directory."
  20. exit 1
  21. fi
  22. # Which version we have?
  23. echo "Zig version" $(zig version)
  24. echo "Eowyn version 23.10.5.1, let's try our magic power."
  25. echo ""
  26. # Remove progress file
  27. progress_file=".progress.txt"
  28. if [ -f $progress_file ]; then
  29. rm $progress_file
  30. fi
  31. # Create directory of healing if it doesn't already exist.
  32. mkdir -p patches/healed
  33. # Cycle through all the little broken Zig applications.
  34. for broken in exercises/*.zig
  35. do
  36. # Remove the dir and extension, rendering the True Name.
  37. true_name=$(basename "$broken" .zig)
  38. patch_name="patches/patches/$true_name.patch"
  39. if [ -f "$patch_name" ]
  40. then
  41. # Apply the bandages to the wounds, grow new limbs, let
  42. # new life spring into the broken bodies of the fallen.
  43. echo Healing "$true_name"...
  44. cp "$broken" "patches/healed/$true_name.zig"
  45. patch -i "$patch_name" "patches/healed/$true_name.zig"
  46. else
  47. echo Cannot heal "$true_name". No patch found.
  48. fi
  49. done
  50. echo "Looking for non-conforming code formatting..."
  51. zig fmt --check patches/healed
  52. # Test the healed exercises. May the compiler have mercy upon us.
  53. zig build -Dhealed