aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/build-all.sh25
-rwxr-xr-xbin/build.sh14
-rwxr-xr-xmake79
3 files changed, 103 insertions, 15 deletions
diff --git a/bin/build-all.sh b/bin/build-all.sh
index e91280a..e3888fb 100755
--- a/bin/build-all.sh
+++ b/bin/build-all.sh
@@ -4,14 +4,17 @@
# If pattern given, only build targets which match.
if [ ! -z "$1" ]; then
- SEARCH="$1"
+ # multiple search terms with "AND"
+ SEARCH=$@
fi
-# TODO: detect UI from $0
+# TODO: detect UI from $0 and/or $*
UI=anduril
mkdir -p hex
+# TODO: use a git tag for the version, instead of build date
+# TODO: use build/version.h instead of $UI/version.h ?
date '+#define VERSION_NUMBER "%Y-%m-%d"' > ui/$UI/version.h
PASS=0
@@ -19,17 +22,22 @@ FAIL=0
PASSED=''
FAILED=''
-for TARGET in $(find hw/*/* -name "$UI".h) ; do
+# build targets are hw/*/**/$UI.h
+for TARGET in $( find hw/*/*/ -name "$UI".h ) ; do
- # maybe limit builds to a specific pattern
+ # limit builds to searched patterns, if given
+ SKIP=0
if [ ! -z "$SEARCH" ]; then
- echo "$TARGET" | grep -i "$SEARCH" > /dev/null
- if [ 0 != $? ]; then continue ; fi
+ for text in $SEARCH ; do
+ echo "$TARGET" | grep -i "$text" > /dev/null
+ if [ 0 != $? ]; then SKIP=1 ; fi
+ done
fi
+ if [ 1 = $SKIP ]; then continue ; fi
# friendly name for this build
NAME=$(echo "$TARGET" | perl -ne 's|/|-|g; /hw-(.*)-'"$UI"'.h/ && print "$1\n";')
- echo "===== $NAME ====="
+ echo "===== $UI : $NAME ====="
# figure out MCU type
#ATTINY=$(grep 'ATTINY:' $TARGET | awk '{ print $3 }')
@@ -37,11 +45,12 @@ for TARGET in $(find hw/*/* -name "$UI".h) ; do
# try to compile
#echo bin/build.sh "$UI" "$TARGET"
- bin/build.sh "$UI" "$TARGET"
+ bin/build.sh "$TARGET"
# track result, and rename compiled files
if [ 0 = $? ] ; then
mv -f "ui/$UI/$UI".hex hex/"$UI".$NAME.hex
+ echo " > hex/$UI.$NAME.hex"
PASS=$(($PASS + 1))
PASSED="$PASSED $NAME"
else
diff --git a/bin/build.sh b/bin/build.sh
index 0c4fc17..41abfc7 100755
--- a/bin/build.sh
+++ b/bin/build.sh
@@ -4,16 +4,16 @@
# same exact way, here's a script to do the same thing
if [ -z "$1" ]; then
- echo "Usage: build.sh UI CFG USER"
- echo "Example: build.sh ui/anduril hw/hank/emisar-d4 users/myuser"
+ echo "Usage: build.sh TARGET USER"
+ echo "Example: build.sh hw/hank/emisar-d4/anduril.h users/myuser"
echo "(but USER isn't implemented yet)"
exit
fi
-UI=$1 ; shift
-CFG=$1 ; shift
+TARGET=$1 ; shift
+UI=$(basename $TARGET .h)
-ATTINY=$(grep 'ATTINY:' $CFG | awk '{ print $3 }')
+ATTINY=$(grep 'ATTINY:' $TARGET | awk '{ print $3 }')
if [ -z "$ATTINY" ]; then ATTINY=85 ; fi
PROGRAM="ui/$UI/$UI"
@@ -45,7 +45,7 @@ export LDFLAGS="-fgnu89-inline"
export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex --remove-section .fuse'
export OBJS=$PROGRAM.o
-OTHERFLAGS="-DCFG_H=$CFG"
+OTHERFLAGS="-DCFG_H=$TARGET"
for arg in "$*" ; do
OTHERFLAGS="$OTHERFLAGS $arg"
done
@@ -64,4 +64,4 @@ run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o
run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex
# deprecated
#run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full
-run avr-objdump -Pmem-usage $PROGRAM.elf | grep Full
+run avr-objdump -Pmem-usage $PROGRAM.elf | grep -E 'Full|Device' | sed 's/^/ /;'
diff --git a/make b/make
new file mode 100755
index 0000000..79a6d96
--- /dev/null
+++ b/make
@@ -0,0 +1,79 @@
+#!/bin/bash
+# Anduril / FSM "make" script
+# Copyright (C) 2023 Selene ToyKeeper
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# replaces system "make" command,
+# because this project doesn't need make's features;
+# it just needs a little wrapper script for common tasks
+
+# enable "**" for recursive glob (requires bash)
+shopt -s globstar
+
+# figure out which operation was requested
+MODE="$1"
+
+function help() {
+ cat << ENDOFHELP
+Anduril make: a build helper tool for Anduril flashlight firmware
+Usage: ./make TASK
+... where TASK is:
+
+ help Show this help text
+ (nothing) Compile all build targets
+ flash FILE Flash firmare FILE to a hardware device
+ clean Delete generated files
+ todo Show tasks noted in source code files
+ models Generate the MODELS file
+ release Zip up all .hex files to prep for publishing a release
+
+... or TASK can be the partial name of a build target.
+
+Examples:
+
+ # get rid of old clutter files
+ ./make clean
+ # compile all anduril build targets
+ ./make anduril
+ # compile all builds matching "emisar" AND "nofet"
+ ./make emisar nofet
+ # compile all builds matching "q8" (i.e. Sofirn BLF Q8)
+ ./make q8
+ # Flash the Q8 firmware built in the previous command
+ # (copy/paste the file path printed by the build script)
+ ./make flash hex/sofirn-blf-q8.hex
+ENDOFHELP
+}
+
+# sub-command parser / dispatcher
+function main() {
+ case "$MODE" in
+ -h|--help|help|/?|/h|/help)
+ help
+ ;;
+ clean)
+ echo 'rm -vf **/*.hex **/*~ **/*.elf **/*.o'
+ rm -vf **/*.hex **/*~ **/*.elf **/*.o
+ ;;
+ flash)
+ echo "Not implemented yet."
+ #./bin/flash.sh "$@"
+ ;;
+ models)
+ ./bin/models.py > MODELS
+ cat MODELS
+ ;;
+ release)
+ echo "Not implemented yet."
+ ;;
+ todo)
+ grep -E 'TODO:|FIXME:' **/*.[ch]
+ ;;
+ *)
+ ./bin/build-all.sh "$@"
+ ;;
+ esac
+}
+
+main "$@"
+