Comments in build.sh

This commit is contained in:
Neale Pickett 2023-11-26 13:04:23 -07:00
parent ff142a2d56
commit af7d09336b
1 changed files with 13 additions and 6 deletions

View File

@ -2,13 +2,19 @@
set -e set -e
builddefs=params.json # paramsets contains the location of the OpenSCAD parameter sets.
# see https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Customizer#Saving_Parameters_value_in_JSON_file
paramsets=params.json
# run executes a program after printing the commandline to stdout.
run () { run () {
echo "=== $*" echo "=== $*"
"$@" "$@"
} }
# render turns OpenSCAD echo into 3mf temperature changes.
#
# It does this by kludging together a PrusaSlicer-specific Metadata file.
render () { render () {
basename=$1; shift basename=$1; shift
run openscad -o $basename "$@" temp-tower.scad 2>&1 | tee $basename.log run openscad -o $basename "$@" temp-tower.scad 2>&1 | tee $basename.log
@ -28,19 +34,20 @@ render () {
rmdir Metadata rmdir Metadata
} }
# paramsets lists all defined parameter sets, one per line.
paramsets () { paramsets () {
cat $builddefs | jq -r '.parameterSets | keys[] | select(length > 0)' cat $paramsets | jq -r '.parameterSets | keys[] | select(length > 0)'
} }
case "$1" in case "$1" in
-h|-help|--help) -h|-help|--help)
cat <<EOD cat <<EOD
Usage $0 [-paramsets] [PARAMSET ...] Usage: $0 [-paramsets] [PARAMSET ...]
Generates .3mf files with temperature changes Generates .3mf files with temperature changes
for each given parameter set. for each given parameter set.
Parameter sets are specified in $builddefs. Parameter sets are specified in $paramsets.
-paramsets List all defined parameter sets, and exit. -paramsets List all defined parameter sets, and exit.
EOD EOD
@ -52,12 +59,12 @@ EOD
;; ;;
"") "")
paramsets | while read paramset; do paramsets | while read paramset; do
render $paramset.3mf -P $paramset -p $builddefs render $paramset.3mf -P $paramset -p $paramsets
done done
;; ;;
*) *)
for paramset in "$@"; do for paramset in "$@"; do
render $paramset.3mf -P $paramset -p $builddefs render $paramset.3mf -P $paramset -p $paramsets
done done
;; ;;
esac esac