SummerCart64/build.sh

160 lines
3.7 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
2022-05-15 15:47:12 +02:00
PACKAGE_FILE_NAME="SC64"
FILES=(
2022-05-20 00:31:45 +02:00
"./fw/ft232h_config.xml"
2022-05-15 15:47:12 +02:00
"./fw/project/lcmxo2/impl1/sc64_impl1.bit"
"./fw/project/lcmxo2/impl1/sc64_impl1.jed"
"./sw/bootloader/build/bootloader.bin"
"./sw/controller/build/controller.bin"
"./sw/controller/build/controller.elf"
"./sw/pc/helpers.py"
"./sw/pc/sc64.py"
"./LICENSE"
2022-05-15 15:47:12 +02:00
"./README.md"
)
2022-05-15 15:47:12 +02:00
BUILT_BOOTLOADER=false
BUILT_CONTROLLER=false
BUILT_FPGA=false
BUILT_UPDATE=false
BUILT_RELEASE=false
FORCE_CLEAN=false
2022-05-15 15:47:12 +02:00
build_bootloader () {
if [ "$BUILT_BOOTLOADER" = true ]; then return; fi
2022-05-15 15:47:12 +02:00
pushd sw/bootloader > /dev/null
if [ "$FORCE_CLEAN" = true ]; then
make clean
fi
2022-05-15 15:47:12 +02:00
FLAGS="$USER_FLAGS"
if [ ! -z "${GIT_BRANCH+x}" ]; then FLAGS+=" -DGIT_BRANCH='\"$GIT_BRANCH\"'"; fi
if [ ! -z "${GIT_TAG+x}" ]; then FLAGS+=" -DGIT_TAG='\"$GIT_TAG\"'"; fi
if [ ! -z "${GIT_SHA+x}" ]; then FLAGS+=" -DGIT_SHA='\"$GIT_SHA\"'"; fi
make all -j USER_FLAGS="$FLAGS"
popd > /dev/null
2022-05-15 15:47:12 +02:00
BUILT_BOOTLOADER=true
}
2022-05-15 15:47:12 +02:00
build_controller () {
if [ "$BUILT_CONTROLLER" = true ]; then return; fi
2022-05-15 15:47:12 +02:00
pushd sw/controller > /dev/null
if [ "$FORCE_CLEAN" = true ]; then
make clean
fi
make all -j USER_FLAGS="$USER_FLAGS"
popd > /dev/null
2022-05-15 15:47:12 +02:00
BUILT_CONTROLLER=true
2022-01-18 19:21:49 +01:00
}
build_fpga () {
if [ "$BUILT_FPGA" = true ]; then return; fi
2022-05-15 15:47:12 +02:00
pushd fw/project/lcmxo2 > /dev/null
if [ "$FORCE_CLEAN" = true ]; then
rm -rf ./impl1/
fi
2022-05-15 15:47:12 +02:00
./build.sh
popd > /dev/null
BUILT_FPGA=true
}
build_update () {
if [ "$BUILT_UPDATE" = true ]; then return; fi
2022-05-15 15:47:12 +02:00
build_bootloader
build_controller
build_fpga
BUILT_UPDATE=true
}
build_release () {
if [ "$BUILT_RELEASE" = true ]; then return; fi
build_update
if [ -e "./${PACKAGE_FILE_NAME}.zip" ]; then
rm -f "./${PACKAGE_FILE_NAME}.zip"
fi
zip -j -r "./${PACKAGE_FILE_NAME}.zip" ${FILES[@]}
BUILT_RELEASE=true
}
print_usage () {
echo "builder script for SummerCart64"
2022-05-15 15:47:12 +02:00
echo "usage: ./build.sh [bootloader] [controller] [fpga] [update] [release] [-c] [--help]"
echo "parameters:"
2022-05-15 15:47:12 +02:00
echo " bootloader - compile N64 bootloader software"
echo " controller - compile ARM controller software"
echo " fpga - compile FPGA design"
echo " update - compile all software and designs"
echo " release - collect and zip files for release (triggers 'update' build)"
echo " -c | --force-clean"
2022-05-15 15:47:12 +02:00
echo " - clean compilation result directories before build"
echo " --help - print this guide"
}
if test $# -eq 0; then
echo "error: no parameters provided"
echo " "
print_usage
exit 1
fi
2022-05-15 15:47:12 +02:00
TRIGGER_BOOTLOADER=false
TRIGGER_CONTROLLER=false
TRIGGER_FPGA=false
TRIGGER_UPDATE=false
TRIGGER_RELEASE=false
while test $# -gt 0; do
case "$1" in
2022-05-15 15:47:12 +02:00
bootloader)
TRIGGER_BOOTLOADER=true
;;
2022-05-15 15:47:12 +02:00
controller)
TRIGGER_CONTROLLER=true
2022-01-18 19:21:49 +01:00
;;
fpga)
TRIGGER_FPGA=true
;;
update)
TRIGGER_UPDATE=true
;;
release)
TRIGGER_RELEASE=true
;;
-c|--force-clean)
FORCE_CLEAN=true
;;
--help)
print_usage
exit 0
;;
*)
echo "error: unknown parameter \"$1\""
echo " "
print_usage
exit 1
;;
esac
shift
done
2022-05-15 15:47:12 +02:00
if [ "$TRIGGER_BOOTLOADER" = true ]; then build_bootloader; fi
if [ "$TRIGGER_CONTROLLER" = true ]; then build_controller; fi
if [ "$TRIGGER_FPGA" = true ]; then build_fpga; fi
if [ "$TRIGGER_UPDATE" = true ]; then build_update; fi
if [ "$TRIGGER_RELEASE" = true ]; then build_release; fi