50 lines
951 B
Bash
Executable File
50 lines
951 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -ueo pipefail
|
|
|
|
if (( $# != 1 )); then
|
|
echo "Invalid CLI args."
|
|
echo "Usage:"
|
|
echo "./build.sh path/to/printer.env"
|
|
exit 1
|
|
fi
|
|
|
|
if ! [ -f "$1" ]; then
|
|
echo "Printer env file not found."
|
|
echo "Path: $1"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Printer env file found: $1"
|
|
|
|
echo -n "Loading config variables... "
|
|
source "$1"
|
|
echo "OK"
|
|
|
|
filename="fw-${name// /_}-${board// /_}-ver$config_version.$fw_ext"
|
|
echo "Artifact name will be: ""$filename"""
|
|
|
|
if ! [ -d Marlin ]; then
|
|
git clone https://github.com/MarlinFirmware/Marlin --depth 1
|
|
cd Marlin
|
|
else
|
|
cd Marlin
|
|
git pull
|
|
fi
|
|
|
|
echo "Working directory: $PWD"
|
|
|
|
echo -n "Copying custom config files... "
|
|
cp "../$(dirname "$1")"/*.h Marlin/
|
|
echo "OK"
|
|
|
|
echo "Running PlatformIO build!"
|
|
pio run -e "$pio_env"
|
|
echo -n "Finished building. Copying firmware."$fw_ext"... "
|
|
mkdir -p ../output
|
|
cp .pio/build/"$pio_env"/firmware.$fw_ext ../output/"$filename"
|
|
echo "OK"
|
|
cd ..
|
|
|
|
|