refactor(flash_klipper.sh): select python version of klippy-env
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
@@ -263,25 +263,34 @@ function start_flash_sd(){
|
|||||||
|
|
||||||
function build_fw(){
|
function build_fw(){
|
||||||
local python_version
|
local python_version
|
||||||
if [ ! -d "${KLIPPER_DIR}" ] || [ ! -d "${KLIPPY_ENV}" ]; then
|
|
||||||
|
if [[ ! -d ${KLIPPER_DIR} || ! -d ${KLIPPY_ENV} ]]; then
|
||||||
print_error "Klipper not found!\n Cannot build firmware without Klipper!"
|
print_error "Klipper not found!\n Cannot build firmware without Klipper!"
|
||||||
return
|
return
|
||||||
else
|
|
||||||
cd "${KLIPPER_DIR}"
|
|
||||||
status_msg "Initializing firmware build ..."
|
|
||||||
local dep=(build-essential dpkg-dev make)
|
|
||||||
dependency_check "${dep[@]}"
|
|
||||||
|
|
||||||
make clean
|
|
||||||
[ "${python_version}" == "3" ] && make PYTHON=python3 menuconfig
|
|
||||||
[ "${python_version}" == "2" ] && make menuconfig
|
|
||||||
|
|
||||||
status_msg "Building firmware ..."
|
|
||||||
python_version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1)
|
|
||||||
[ "${python_version}" == "3" ] && make PYTHON=python3
|
|
||||||
[ "${python_version}" == "2" ] && make
|
|
||||||
ok_msg "Firmware built!"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
python_version=$(get_klipper_python_ver)
|
||||||
|
|
||||||
|
cd "${KLIPPER_DIR}"
|
||||||
|
status_msg "Initializing firmware build ..."
|
||||||
|
local dep=(build-essential dpkg-dev make)
|
||||||
|
dependency_check "${dep[@]}"
|
||||||
|
|
||||||
|
make clean
|
||||||
|
|
||||||
|
status_msg "Building firmware ..."
|
||||||
|
if (( python_version == 3 )); then
|
||||||
|
make PYTHON=python3 menuconfig
|
||||||
|
make PYTHON=python3
|
||||||
|
elif (( python_version == 2 )); then
|
||||||
|
make PYTHON=python2 menuconfig
|
||||||
|
make PYTHON=python2
|
||||||
|
else
|
||||||
|
warn_msg "Error reading Python version!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ok_msg "Firmware built!"
|
||||||
}
|
}
|
||||||
|
|
||||||
#================================================#
|
#================================================#
|
||||||
|
|||||||
@@ -512,3 +512,10 @@ function get_klipper_cfg_dir() {
|
|||||||
fi
|
fi
|
||||||
echo "${cfg_dir}"
|
echo "${cfg_dir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### returns the major python version the klippy-env was created with
|
||||||
|
function get_klipper_python_ver() {
|
||||||
|
local version
|
||||||
|
version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1)
|
||||||
|
echo "${version}"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user