mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-07-08 07:27:27 -06:00
🔨 Improve build scripts
This commit is contained in:
parent
af05b6e482
commit
a9f44e37a9
2 changed files with 33 additions and 23 deletions
|
@ -159,11 +159,12 @@ ENAME=("-name" "marlin_config.json" \
|
|||
"-o" "-name" "schema.yml")
|
||||
|
||||
# Possible built firmware names (in the build folder)
|
||||
BNAME=("-name" 'firmware*.hex' \
|
||||
BNAME=("-name" "firmware*.hex" \
|
||||
"-o" "-name" "firmware*.bin" \
|
||||
"-o" "-name" "project*.bin" \
|
||||
"-o" "-name" "Robin*.bin" \
|
||||
"-o" "-name" "main_*.bin")
|
||||
"-o" "-name" "main_*.bin" \
|
||||
"-o" "-name" "MarlinSimulator*")
|
||||
|
||||
mkdir -p "$BUILD"
|
||||
|
||||
|
@ -171,10 +172,10 @@ mkdir -p "$BUILD"
|
|||
if [[ $EXPNUM ]]; then
|
||||
opt_set CONFIG_EXPORT $EXPNUM
|
||||
# Clean up old exports
|
||||
find "$BUILD" \( "${ENAME[@]}" \) -exec rm "{}" \;
|
||||
find "$BUILD" -type f \( "${ENAME[@]}" \) -exec rm "{}" \;
|
||||
fi
|
||||
|
||||
((ARCHIVE)) && find "$BUILD" \( "${BNAME[@]}" \) -exec rm "{}" \;
|
||||
((ARCHIVE)) && find "$BUILD" -type f \( "${BNAME[@]}" \) -exec rm "{}" \;
|
||||
|
||||
set +e
|
||||
|
||||
|
@ -200,7 +201,7 @@ else
|
|||
if [[ -n $EXPNUM ]]; then
|
||||
annc "Exporting $EXPNUM"
|
||||
[[ -f Marlin/Config-export.h ]] && { cp Marlin/Config-export.h "$ARCSUB"/Config.h ; }
|
||||
find "$BUILD" \( "${ENAME[@]}" \) -exec cp "{}" "$ARCSUB" \;
|
||||
find "$BUILD" -type f \( "${ENAME[@]}" \) -exec cp "{}" "$ARCSUB" \;
|
||||
fi
|
||||
|
||||
# Copy potential firmware files into the config folder
|
||||
|
@ -208,21 +209,30 @@ else
|
|||
# Currently only BOARD_CREALITY_F401RE env:STM32F401RE_creality
|
||||
if ((ARCHIVE)); then
|
||||
annc "Archiving"
|
||||
rm -f "$ARCSUB"/*.tar.gz "$ARCSUB"/*.sha256.txt
|
||||
find "$BUILD" \( "${BNAME[@]}" \) -exec sh -c '
|
||||
ARCSUB="$1"
|
||||
CONFIG="$2"
|
||||
shift 2
|
||||
for FILE in "$@"; do
|
||||
cd "${FILE%/*}"
|
||||
NAME=${FILE##*/}
|
||||
SHRT=${NAME%.*}
|
||||
SHASUM=$(sha256sum "$NAME" | cut -d" " -f1)
|
||||
tar -czf "$ARCSUB/$SHRT.tar.gz" "$NAME"
|
||||
echo "$CONFIG\n$SHASUM" > "$ARCSUB/$NAME.sha256.txt"
|
||||
rm "$NAME"
|
||||
cd - >/dev/null
|
||||
done
|
||||
find "$BUILD" -type f \( "${BNAME[@]}" \) -exec sh -c '
|
||||
ARCSUB="$1" ; CONFIG="$2" ; FILE="$3" ; shift 3
|
||||
NAME=${FILE##*/} ; SHRT=${NAME%.*} ; DIR=${FILE%/*}
|
||||
ZIPX=
|
||||
if [[ $CONFIG == *Simulator* ]]; then
|
||||
case $(uname | tr '[:upper:]' '[:lower:]') in
|
||||
darwin) SUB="macOS" ; ZIPX="-X" ;;
|
||||
*linux) SUB="Linux" ;;
|
||||
win*) SUB="Windows" ;;
|
||||
msys*) SUB="Windows" ;;
|
||||
cygwin*) SUB="Windows" ;;
|
||||
mingw*) SUB="Windows" ;;
|
||||
*) SUB='Unix' ;;
|
||||
esac
|
||||
ARCH=$(uname -m | tr '[:lower:]' '[:upper:]')
|
||||
ARCSUB="$ARCSUB/$SUB-$ARCH"
|
||||
fi
|
||||
mkdir -p "$ARCSUB"
|
||||
rm -f "$ARCSUB"/*.zip "$ARCSUB"/*.sha256.txt
|
||||
cd "$DIR"
|
||||
SHASUM=$(sha256sum "$NAME" | cut -d" " -f1)
|
||||
echo "$CONFIG\n$SHASUM" > "$ARCSUB/$NAME.sha256.txt"
|
||||
zip $ZIPX "$ARCSUB/$SHRT.zip" "$NAME" && rm "$NAME"
|
||||
cd - >/dev/null
|
||||
' sh "$ARCSUB" "$CONFIG" {} +
|
||||
fi
|
||||
|
||||
|
|
|
@ -343,14 +343,14 @@ def extract_files(filekey):
|
|||
# Type is based on the value
|
||||
value_type = \
|
||||
'switch' if val == '' \
|
||||
else 'bool' if re.match(r'^(true|false)$', val) \
|
||||
else 'int' if re.match(r'^[-+]?\s*\d+$', val) \
|
||||
else 'ints' if re.match(r'^([-+]?\s*\d+)(\s*,\s*[-+]?\s*\d+)+$', val) \
|
||||
else 'floats' if re.match(rf'({flt}(\s*,\s*{flt})+)', val) \
|
||||
else 'float' if re.match(f'^({flt})$', val) \
|
||||
else 'string' if val[0] == '"' \
|
||||
else 'char' if val[0] == "'" \
|
||||
else 'state' if re.match(r'^(LOW|HIGH)$', val) \
|
||||
else 'bool' if val in ('true', 'false') \
|
||||
else 'state' if val in ('HIGH', 'LOW') \
|
||||
else 'enum' if re.match(r'^[A-Za-z0-9_]{3,}$', val) \
|
||||
else 'int[]' if re.match(r'^{\s*[-+]?\s*\d+(\s*,\s*[-+]?\s*\d+)*\s*}$', val) \
|
||||
else 'float[]' if re.match(r'^{{\s*{flt}(\s*,\s*{flt})*\s*}}$', val) \
|
||||
|
@ -385,7 +385,7 @@ def extract_files(filekey):
|
|||
units = re.match(r'^\(([^)]+)\)', full_comment)
|
||||
if units:
|
||||
units = units[1]
|
||||
if units == 's' or units == 'sec': units = 'seconds'
|
||||
if units in ('s', 'sec'): units = 'seconds'
|
||||
define_info['units'] = units
|
||||
|
||||
if 'comment' not in define_info or define_info['comment'] == '':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue