#!/usr/bin/env bash

source ./buildroot/bin/buildFunctions;
exitcode=0;

printf "\e[33;1mBuilding mm-orangerx-aetr-green-inv-v$MULTI_VERSION.bin\e[0m\n";
opt_enable $ALL_PROTOCOLS;
opt_disable ORANGE_TX_BLUE;
buildMulti;
exitcode=$((exitcode+$?));
mv build/Multiprotocol.ino.bin ./binaries/mm-orangerx-aetr-green-inv-v$MULTI_VERSION.bin;

printf "\e[33;1mBuilding mm-orangerx-aetr-blue-inv-v$MULTI_VERSION.bin\e[0m\n";
opt_enable ORANGE_TX_BLUE;
buildMulti;
exitcode=$((exitcode+$?));
mv build/Multiprotocol.ino.bin ./binaries/mm-orangerx-aetr-blue-inv-v$MULTI_VERSION.bin;

printf "\e[33;1mPackaging ancilliary files for v$MULTI_VERSION\e[0m\n";
cp Multiprotocol/Multi.txt ./binaries/Multi.txt;
mkdir -p SCRIPTS/TOOLS;
cp Lua_scripts/*.lua SCRIPTS/TOOLS/;
cp Lua_scripts/*.txt SCRIPTS/TOOLS/;
zip -q ./binaries/MultiLuaScripts.zip SCRIPTS/TOOLS/*;

exit $exitcode;
