1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +03:00

Suggestions from coderabbitai

This commit is contained in:
blckmn 2025-05-23 19:19:15 +10:00
parent 1cda28e8d7
commit 404ebeeb33
2 changed files with 20 additions and 12 deletions

View file

@ -57,8 +57,11 @@ CFLAGS_DISABLED :=
FORKNAME = betaflight
# Working directories
# ROOT_DIR is the full path to the directory containing this Makefile
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# ROOT is the relative path to the directory containing this Makefile
ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
PLATFORM_DIR := $(ROOT)/src/platform
SRC_DIR := $(ROOT)/src/main
LIB_MAIN_DIR := $(ROOT)/lib/main
@ -432,7 +435,7 @@ $(TARGET_HEX): $(TARGET_ELF)
$(TARGET_UF2): $(TARGET_ELF)
@echo "Creating UF2 $(TARGET_UF2)" "$(STDOUT)"
$(V1) $(PICOTOOL) uf2 convert $< $@
$(V1) $(PICOTOOL) uf2 convert $< $@ || { echo "Failed to convert ELF to UF2 format"; exit 1; }
$(TARGET_DFU): $(TARGET_HEX)
@echo "Creating DFU $(TARGET_DFU)" "$(STDOUT)"
@ -693,7 +696,7 @@ version:
submodules:
@echo "Updating submodules"
$(V1) git submodule update --init --recursive
$(V1) git submodule update --init --recursive || { echo "Failed to update submodules"; exit 1; }
@echo "Submodules updated"
## help : print this help message and exit

View file

@ -337,16 +337,21 @@ PICOTOOL_REPO := https://github.com/raspberrypi/picotool.git
PICOTOOL_DL_DIR := $(DL_DIR)/picotool
PICOTOOL_BUILD_DIR := $(PICOTOOL_DL_DIR)/build
PICOTOOL_DIR := $(TOOLS_DIR)/picotool
PICO_SDK_PATH := $(ROOT_DIR)/lib/main/pico-sdk
PICOTOOL := $(PICOTOOL_DIR)/picotool
PICO_SDK_PATH ?= $(ROOT_DIR)/lib/main/pico-sdk
PICOTOOL ?= $(PICOTOOL_DIR)/picotool
ifeq ($(filter picotool_install,$(MAKECMDGOALS)), picotool_install)
ifneq ($(wildcard $(PICO_SDK_PATH)/CMakeLists.txt),$(PICO_SDK_PATH)/CMakeLists.txt)
$(error "PICO_SDK_PATH ($(PICO_SDK_PATH)) does not point to a valid Pico SDK. Please 'make submodules' to hydrate the Pico SDK.")
endif
endif
ifeq ($(filter uf2,$(MAKECMDGOALS)), uf2)
ifeq (,$(wildcard $(PICOTOOL)))
PICOTOOL_VERSION := $(shell picotool version)
ifneq ($(PICOTOOL_VERSION),)
PICOTOOL := picotool
ifeq (,$(shell which picotool 2>/dev/null))
$(error "picotool not in the PATH or setup in tools. Run 'make picotool_install' to install in the tools folder.")
else
$(error **ERROR** picotool not in the PATH or setup in tools. Run 'make picotool_install' to install automatically in the tools folder)
PICOTOOL := picotool
endif
endif
endif
@ -355,13 +360,13 @@ endif
picotool_install: | $(DL_DIR) $(TOOLS_DIR)
picotool_install: picotool_clean
@echo "\n CLONE $(PICOTOOL_REPO)"
$(V1) git clone --depth 1 $(PICOTOOL_REPO) "$(PICOTOOL_DL_DIR)"
$(V1) git clone --depth 1 $(PICOTOOL_REPO) "$(PICOTOOL_DL_DIR)" || { echo "Failed to clone picotool repository"; exit 1; }
@echo "\n BUILD $(PICOTOOL_BUILD_DIR)"
$(V1) [ -d "$(PICOTOOL_DIR)" ] || mkdir -p $(PICOTOOL_DIR)
$(V1) [ -d "$(PICOTOOL_BUILD_DIR)" ] || mkdir -p $(PICOTOOL_BUILD_DIR)
$(V1) cmake -S $(PICOTOOL_DL_DIR) -B $(PICOTOOL_BUILD_DIR) -D PICO_SDK_PATH=$(PICO_SDK_PATH)
$(V1) $(MAKE) -C $(PICOTOOL_BUILD_DIR)
$(V1) cp $(PICOTOOL_BUILD_DIR)/picotool $(PICOTOOL_DIR)/picotool
$(V1) cmake -S $(PICOTOOL_DL_DIR) -B $(PICOTOOL_BUILD_DIR) -D PICO_SDK_PATH=$(PICO_SDK_PATH) || { echo "CMake configuration failed"; exit 1; }
$(V1) $(MAKE) -C $(PICOTOOL_BUILD_DIR) || { echo "picotool build failed"; exit 1; }
$(V1) cp $(PICOTOOL_BUILD_DIR)/picotool $(PICOTOOL_DIR)/picotool || { echo "Failed to install picotool binary"; exit 1; }
@echo "\n VERSION:"
$(V1) $(PICOTOOL_DIR)/picotool version