mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-01-22 09:42:34 +00:00
🧑💻 More compatible opt helpers
This commit is contained in:
parent
f2d585ac7f
commit
74ffa0cc3e
13 changed files with 92 additions and 44 deletions
|
@ -41,7 +41,6 @@ env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6
|
|||
TESTPATH=buildroot/tests
|
||||
|
||||
STATE_FILE="./.pio/.mftestrc"
|
||||
SED=$(which gsed sed | head -n1)
|
||||
|
||||
shopt -s extglob nocasematch
|
||||
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
#
|
||||
|
||||
# Check dependencies
|
||||
which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
|
||||
which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
|
||||
which curl &>/dev/null || { echo "curl not found! Please install it."; exit 1 ; }
|
||||
which git &>/dev/null || { echo "git not found! Please install it."; exit 1 ; }
|
||||
which sed &>/dev/null || { echo "sed not found! Please install it."; exit 1 ; }
|
||||
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
|
||||
|
|
|
@ -3,13 +3,34 @@
|
|||
# exit on first failure
|
||||
set -e
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
# Get SED_CMD, SED_I, and the BSDSED flag
|
||||
. $(dirname $0)/opt_sed
|
||||
|
||||
for opt in "$@" ; do
|
||||
DID=0 ; FOUND=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
"${SED}" -i "/^\(\s*\)\(#define\s\+${opt}\b\s\?\)\(\s\s\)\?/{s//\1\/\/\2/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1
|
||||
((DID||FOUND)) || { grep -E "^\s*//\s*#define\s+${opt}\b" Marlin/$FN.h >/dev/null && FOUND=1 ; }
|
||||
for FN in Marlin/Configuration.h Marlin/Configuration_adv.h; do
|
||||
if [[ $BSDSED ]]; then
|
||||
# BSD sed version (macOS)
|
||||
"${SED_CMD}" "${SED_I[@]}" \
|
||||
"/^[[:space:]]*#define[[:space:]]+${opt}\b/{
|
||||
s/^[[:space:]]*\(#define[[:space:]]+${opt}\b.*\)/\/\/\1/
|
||||
h
|
||||
\$b end
|
||||
}
|
||||
\$!b
|
||||
:end
|
||||
x
|
||||
/./{ x; q0; }
|
||||
x
|
||||
q1" \
|
||||
$FN && DID=1
|
||||
else
|
||||
# GNU sed version
|
||||
"${SED_CMD}" "${SED_I[@]}" \
|
||||
"/^\(\s*\)\(#define\s\+${opt}\b\s\?\)\(\s\s\)\?/{s//\1\/\/\2/;h};\${x;/./{x;q0};x;q1}" \
|
||||
$FN && DID=1
|
||||
fi
|
||||
((DID||FOUND)) || { grep -E "^\s*\/\/#define\s+${opt}\b" $FN >/dev/null && FOUND=1 ; }
|
||||
done
|
||||
((DID||FOUND)) || (echo "ERROR: $(basename $0) Can't find ${opt}" >&2 && exit 9)
|
||||
done
|
||||
|
|
|
@ -3,13 +3,34 @@
|
|||
# exit on first failure
|
||||
set -e
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
# Get SED_CMD, SED_I, and the BSDSED flag
|
||||
. $(dirname $0)/opt_sed
|
||||
|
||||
for opt in "$@" ; do
|
||||
DID=0 ; FOUND=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
"${SED}" -i "/^\(\s*\)\/\/\(\s*\)\(#define\s\+${opt}\b\)\( \?\)/{s//\1\2\3\4\4\4/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1
|
||||
((DID||FOUND)) || { grep -E "^\s*#define\s+${opt}\b" Marlin/$FN.h >/dev/null && FOUND=1 ; }
|
||||
for FN in Marlin/Configuration.h Marlin/Configuration_adv.h; do
|
||||
if [[ $BSDSED ]]; then
|
||||
# BSD sed version (macOS)
|
||||
"${SED_CMD}" "${SED_I[@]}" \
|
||||
"/^[[:space:]]*\/\/[[:space:]]*#define[[:space:]]+${opt}\b/{
|
||||
s/^[[:space:]]*\/\/[[:space:]]*\(#define[[:space:]]+${opt}\b\)[[:space:]]*/\1 /
|
||||
h
|
||||
\$b end
|
||||
}
|
||||
\$!b
|
||||
:end
|
||||
x
|
||||
/./{ x; q0; }
|
||||
x
|
||||
q1" \
|
||||
$FN && DID=1
|
||||
else
|
||||
# GNU sed version
|
||||
"${SED_CMD}" "${SED_I[@]}" \
|
||||
"/^\(\s*\)\/\/\(\s*\)\(#define\s\+${opt}\b\)\( \?\)/{s//\1\2\3\4\4\4/;h};\${x;/./{x;q0};x;q1}" \
|
||||
$FN && DID=1
|
||||
fi
|
||||
((DID||FOUND)) || { grep -E "^\s*#define\s+${opt}\b" $FN >/dev/null && FOUND=1 ; }
|
||||
done
|
||||
((DID||FOUND)) || (echo "ERROR: $(basename $0) Can't find ${opt}" >&2 && exit 9)
|
||||
done
|
||||
|
|
|
@ -23,8 +23,8 @@ esac
|
|||
|
||||
while [[ $# > 0 ]]; do
|
||||
DID=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
FOUND=$( grep -HEn "^\s*${COMM}#define\s+[A-Z0-9_]*${1}" "Marlin/$FN.h" 2>/dev/null )
|
||||
for FN in Marlin/Configuration.h Marlin/Configuration_adv.h; do
|
||||
FOUND=$( grep -HEn "^\s*${COMM}#define\s+[A-Z0-9_]*${1}" $FN 2>/dev/null )
|
||||
[[ -n "$FOUND" ]] && { echo "$FOUND" ; DID=1 ; }
|
||||
done
|
||||
((DID)) || { echo "ERROR: ${MYNAME} - No ${TYPE}match for ${1}" ; exit 9; }
|
||||
|
|
9
buildroot/bin/opt_sed
Executable file
9
buildroot/bin/opt_sed
Executable file
|
@ -0,0 +1,9 @@
|
|||
# Detect sed version
|
||||
SED_CMD="sed"
|
||||
SED_I=(-i)
|
||||
if command -v gsed >/dev/null 2>&1; then
|
||||
SED_CMD="gsed"
|
||||
elif [[ "$(uname)" == "Darwin" ]]; then
|
||||
SED_I=(-i '')
|
||||
BSDSED=1
|
||||
fi
|
|
@ -3,12 +3,33 @@
|
|||
# exit on first failure
|
||||
set -e
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
# Get SED_CMD, SED_I, and the BSDSED flag
|
||||
. $(dirname $0)/opt_sed
|
||||
|
||||
while [[ $# > 1 ]]; do
|
||||
DID=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
"${SED}" -i "/^\(\s*\)\/*\s*\(#define\s\+${1}\b\) *\(.*\)$/{s//\1\2 ${2} \/\/ \3/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1
|
||||
for FN in Marlin/Configuration.h Marlin/Configuration_adv.h; do
|
||||
if [[ $BSDSED ]]; then
|
||||
# BSD sed version (macOS)
|
||||
$SED_CMD "${SED_I[@]}" \
|
||||
"/^[[:space:]]*\/\{0,2\}[[:space:]]*#define[[:space:]]+${1}\b/{
|
||||
s/^[[:space:]]*\/\{0,2\}[[:space:]]*\(#define[[:space:]]+${1}\b\)[[:space:]]*.*/\1 ${2} \/\/ &/
|
||||
h
|
||||
\$b end
|
||||
}
|
||||
\$!b
|
||||
:end
|
||||
x
|
||||
/./{ x; q0; }
|
||||
x
|
||||
q1" \
|
||||
$FN && DID=1
|
||||
else
|
||||
# GNU sed version
|
||||
$SED_CMD "${SED_I[@]}" \
|
||||
"/^\(\s*\)\/\{0,2\}\s*\(#define\s\+${1}\b\)\s*\(.*\)$/{s//\1\2 ${2} \/\/ \3/;h};\${x;/./{x;q0};x;q1}" \
|
||||
$FN && DID=1
|
||||
fi
|
||||
done
|
||||
((DID)) ||
|
||||
eval "echo '#define ${1} ${2}' >>Marlin/Configuration.h" ||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
IFS='/' read -r -a PINPATH <<< "$1"
|
||||
DIR=${PINPATH[0]}
|
||||
NAM=${PINPATH[1]}
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
|
||||
shift
|
||||
while [[ $# > 1 ]]; do
|
||||
PIN=$1 ; VAL=$2
|
||||
FOUT="${DIR}/pins_${NAM}.h"
|
||||
eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*[[:blank:]]*\(#define \+${PIN}\b\).*$/{s//\2 ${VAL}/;h};\${x;/./{x;q0};x;q9}' Marlin/src/pins/${FOUT}" ||
|
||||
(echo "ERROR: pins_set Can't find ${PIN} in ${FOUT}" >&2 && exit 9)
|
||||
shift 2
|
||||
done
|
|
@ -40,7 +40,6 @@ Modify Configuration.h / Configuration_adv.h:
|
|||
|
||||
Modify pins files:
|
||||
|
||||
pins_set ............. Set the value of a pin in a pins file
|
||||
pinsformat.py ........ Python script to format pins files
|
||||
|
||||
THIS
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
# so at every release be sure to create a dev- tag and publish it to origin.
|
||||
#
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
SELF=`basename "$0"`
|
||||
DRYRUN=0
|
||||
|
||||
|
|
|
@ -37,11 +37,10 @@ exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options
|
|||
# RADDS with BLTouch, ABL(B), 3 x Z auto-align
|
||||
#
|
||||
restore_configs
|
||||
opt_set MOTHERBOARD BOARD_RADDS Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z3_DRIVER_TYPE A4988
|
||||
opt_set MOTHERBOARD BOARD_RADDS Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z3_DRIVER_TYPE A4988 \
|
||||
X_MAX_PIN -1 Y_MAX_PIN -1
|
||||
opt_enable ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \
|
||||
Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_STEPPER_XY Z_SAFE_HOMING
|
||||
pins_set ramps/RAMPS X_MAX_PIN -1
|
||||
pins_set ramps/RAMPS Y_MAX_PIN -1
|
||||
exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3"
|
||||
|
||||
#
|
||||
|
|
|
@ -106,9 +106,8 @@ exec_test $1 $2 "Teensy 3.5/3.6 COREXZ | BACKLASH" "$3"
|
|||
# Enable Dual Z with Dual Z endstops
|
||||
#
|
||||
restore_configs
|
||||
opt_set MOTHERBOARD BOARD_TEENSY35_36 Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z2_MIN_PIN 2
|
||||
opt_set MOTHERBOARD BOARD_TEENSY35_36 Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z2_MIN_PIN 2 X_MAX_PIN -1
|
||||
opt_enable Z_MULTI_ENDSTOPS
|
||||
pins_set ramps/RAMPS X_MAX_PIN -1
|
||||
exec_test $1 $2 "Dual Z with Dual Z endstops" "$3"
|
||||
|
||||
# Clean up
|
||||
|
|
|
@ -105,9 +105,8 @@ exec_test $1 $2 "Teensy 4.0/4.1 COREXZ" "$3"
|
|||
# Enable Dual Z with Dual Z endstops
|
||||
#
|
||||
restore_configs
|
||||
opt_set MOTHERBOARD BOARD_TEENSY41 Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z2_MIN_PIN 2
|
||||
opt_set MOTHERBOARD BOARD_TEENSY41 Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z2_MIN_PIN 2 X_MAX_PIN -1
|
||||
opt_enable Z_MULTI_ENDSTOPS
|
||||
pins_set ramps/RAMPS X_MAX_PIN -1
|
||||
exec_test $1 $2 "Dual Z with Dual Z endstops" "$3"
|
||||
|
||||
# Clean up
|
||||
|
|
Loading…
Reference in a new issue