mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
118 lines
2.8 KiB
Bash
Executable File
118 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
usage() {
|
|
echo "Downloads source code of Game Boy programs used as RGBDS test cases."
|
|
echo "Options:"
|
|
echo " -h, --help show this help message"
|
|
echo " --only-free download only freely licensed codebases"
|
|
echo " --only-internal do not download any codebases"
|
|
echo " --get-deps install programs' own dependencies instead of themselves"
|
|
echo " --get-hash print programs' commit hashes instead of downloading them"
|
|
echo " --get-paths print programs' GitHub paths instead of downloading them"
|
|
}
|
|
|
|
# Parse options in pure Bash because macOS `getopt` is stuck
|
|
# in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode
|
|
nonfree=true
|
|
external=true
|
|
actionname=
|
|
osname=
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
--only-free)
|
|
nonfree=false
|
|
;;
|
|
--only-internal)
|
|
external=false
|
|
;;
|
|
--get-deps)
|
|
actionname="$1"
|
|
shift
|
|
osname="$1"
|
|
;;
|
|
--get-hash|--get-paths)
|
|
actionname="$1"
|
|
;;
|
|
--)
|
|
break
|
|
;;
|
|
*)
|
|
echo "$(basename "$0"): unknown option '$1'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
case "$actionname" in
|
|
--get-deps)
|
|
action() { # _ repo _ _
|
|
# libbet depends on PIL to build
|
|
if [ "$2" = "libbet" ]; then
|
|
case "${osname%-*}" in
|
|
ubuntu | debian)
|
|
sudo apt-get install python3-pil
|
|
;;
|
|
macos)
|
|
python3 -m pip install --break-system-packages pillow
|
|
;;
|
|
windows)
|
|
py -3 -m pip install pillow
|
|
;;
|
|
*)
|
|
echo "WARNING: Cannot install Pillow for OS '$osname'"
|
|
;;
|
|
esac
|
|
fi
|
|
}
|
|
;;
|
|
|
|
--get-hash)
|
|
action() { # _ repo _ commit
|
|
printf "%s@%s-" "$2" "$4"
|
|
}
|
|
;;
|
|
|
|
--get-paths)
|
|
action() { # _ repo
|
|
printf "test/%s," "$2"
|
|
}
|
|
;;
|
|
|
|
*)
|
|
echo "Fetching test dependency repositories"
|
|
|
|
action() { # owner repo shallow-since commit
|
|
if [ ! -d "$2" ]; then
|
|
git clone "https://github.com/$1/$2.git" --recursive --shallow-since="$3" --single-branch
|
|
fi
|
|
pushd "$2"
|
|
git checkout -f "$4"
|
|
if [ -f "../patches/$2.patch" ]; then
|
|
git apply --ignore-whitespace "../patches/$2.patch"
|
|
fi
|
|
popd
|
|
}
|
|
esac
|
|
|
|
if ! "$external"; then
|
|
exit
|
|
fi
|
|
|
|
if "$nonfree"; then
|
|
action pret pokecrystal 2025-06-29 de396249e10eb294f41afd0e82245a4a68a3c8e8
|
|
action pret pokered 2025-06-29 1e997474be15950eb3176864b346b96504760e67
|
|
action zladx LADX-Disassembly 2025-05-30 f685f6aaff2f2e0e36d1856d4ed8fd58f833a1f2
|
|
fi
|
|
action AntonioND ucity 2025-05-30 83e5c697cbd9e10a0bc72b02bcb6146c35e2c328
|
|
action pinobatch libbet 2025-05-20 bb6cfc026644aa1034eee6d9c49bb4705601c9f6
|
|
action LIJI32 SameBoy 2025-06-28 33d237706e18d92fb79e3fd7313d5181d8a806cd
|
|
action ISSOtm gb-starter-kit 2025-06-13 3cce3215b0bcb559a5cf4ca5916e2d817d53ff29
|