Sync betaflight to Gitea
This commit is contained in:
+112
@@ -0,0 +1,112 @@
|
||||
|
||||
CONFIGS_REPO_URL ?= https://github.com/betaflight/config
|
||||
# handle only this directory as config submodule
|
||||
CONFIGS_SUBMODULE_DIR := src/config
|
||||
BASE_CONFIGS = $(sort $(notdir $(patsubst %/,%,$(dir $(wildcard $(CONFIG_DIR)/configs/*/config.h)))))
|
||||
|
||||
ifneq ($(words $(CONFIG_DIR)),1)
|
||||
$(error CONFIG_DIR/BETAFLIGHT_CONFIG path contains whitespace; unsupported by GNU make wildcard.)
|
||||
endif
|
||||
|
||||
# Config handling — only active when CONFIG= is set explicitly
|
||||
ifneq ($(CONFIG),)
|
||||
|
||||
ifeq ($(wildcard $(CONFIG_DIR)/configs/),)
|
||||
$(error `$(CONFIG_DIR)` not found. Have you hydrated configuration using: 'make configs'?)
|
||||
endif
|
||||
|
||||
ifneq ($(TARGET),)
|
||||
$(error TARGET or CONFIG should be specified. Not both.)
|
||||
endif
|
||||
|
||||
CONFIG_HEADER_FILE = $(CONFIG_DIR)/configs/$(CONFIG)/config.h
|
||||
CONFIG_SOURCE_FILE = $(CONFIG_DIR)/configs/$(CONFIG)/config.c
|
||||
INCLUDE_DIRS += $(CONFIG_DIR)/configs/$(CONFIG)
|
||||
|
||||
# include $(CONFIG)/config.mk if it exists
|
||||
-include $(CONFIG_DIR)/configs/$(CONFIG)/config.mk
|
||||
|
||||
# OCTOSPI_FLASH_CHIP selects the flash chip wired to the OCTOSPI/XSPI peripheral.
|
||||
# Set in per-config config.mk (e.g. OCTOSPI_FLASH_CHIP := MX66UW1G45G). Emits both
|
||||
# USE_FLASH_<chip> (chip driver gating) and OCTOSPI_FLASH_CHIP_<chip> (build-time
|
||||
# selection marker for chips that cannot be probed via JEDEC RDID, such as those
|
||||
# operating in 8-line OPI mode).
|
||||
ifneq ($(OCTOSPI_FLASH_CHIP),)
|
||||
TARGET_FLAGS += -DUSE_FLASH_$(OCTOSPI_FLASH_CHIP) -DOCTOSPI_FLASH_CHIP_$(OCTOSPI_FLASH_CHIP)
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(CONFIG_HEADER_FILE)),)
|
||||
|
||||
CONFIG_SRC :=
|
||||
ifneq ($(wildcard $(CONFIG_SOURCE_FILE)),)
|
||||
CONFIG_SRC += $(CONFIG_SOURCE_FILE)
|
||||
TARGET_FLAGS += -DUSE_CONFIG_SOURCE
|
||||
endif
|
||||
|
||||
CONFIG_REVISION := norevision
|
||||
ifeq ($(shell git -C "$(CONFIG_DIR)" rev-parse --is-inside-work-tree 2>/dev/null),true)
|
||||
ifeq ($(strip $(shell git -C "$(CONFIG_DIR)" status --porcelain -uno 2>/dev/null)),)
|
||||
CONFIG_REVISION := $(shell git -C "$(CONFIG_DIR)" rev-parse --short=7 HEAD 2>/dev/null)
|
||||
CONFIG_REVISION_DEFINE := -D'__CONFIG_REVISION__="$(CONFIG_REVISION)"'
|
||||
endif
|
||||
endif
|
||||
|
||||
# Extract constants from $(CONFIG_HEADER_FILE) via preprocessor expansion
|
||||
# Oscillator frequency (MHz) -> Hz
|
||||
HSE_VALUE_MHZ := $(call pp_def_value,$(CONFIG_HEADER_FILE),SYSTEM_HSE_MHZ)
|
||||
ifneq ($(strip $(HSE_VALUE_MHZ)),)
|
||||
HSE_VALUE := $(shell echo $$(( $(HSE_VALUE_MHZ) * 1000000 )) )
|
||||
endif
|
||||
|
||||
# MCU target from config header
|
||||
TARGET := $(call pp_def_value,$(CONFIG_HEADER_FILE),FC_TARGET_MCU)
|
||||
ifeq ($(strip $(TARGET)),)
|
||||
$(error No TARGET identified. Is the $(CONFIG_HEADER_FILE) valid for $(CONFIG)?)
|
||||
endif
|
||||
|
||||
# Optional EXST address adjustment
|
||||
EXST_ADJUST_VMA := $(call pp_def_value,$(CONFIG_HEADER_FILE),FC_VMA_ADDRESS)
|
||||
ifneq ($(strip $(EXST_ADJUST_VMA)),)
|
||||
EXST = yes
|
||||
endif
|
||||
|
||||
else #exists
|
||||
$(error `$(CONFIG_HEADER_FILE)` not found. Have you hydrated configuration using: 'make configs'?)
|
||||
endif #CONFIG_HEADER_FILE exists
|
||||
endif #config
|
||||
|
||||
.PHONY: configs
|
||||
configs:
|
||||
ifeq ($(shell realpath "$(CONFIG_DIR)"),$(shell realpath "$(CONFIGS_SUBMODULE_DIR)"))
|
||||
@echo "Updating config submodule: $(CONFIGS_SUBMODULE_DIR)"
|
||||
$(V1) git submodule update --init -- "$(CONFIGS_SUBMODULE_DIR)" || { echo "Config submodule update failed. Please check your git configuration."; exit 1; }
|
||||
@echo "Submodule update succeeded."
|
||||
else
|
||||
ifeq ($(wildcard $(CONFIG_DIR)),)
|
||||
@echo "Hydrating clone for configs: $(CONFIG_DIR)"
|
||||
$(V1) git clone --depth=1 $(CONFIGS_REPO_URL) "$(CONFIG_DIR)"
|
||||
else
|
||||
$(V1) git -C "$(CONFIG_DIR)" pull --ff-only origin
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BASE_CONFIGS):
|
||||
@echo "Building target config $@"
|
||||
$(V0) $(MAKE) fwo CONFIG=$@
|
||||
@echo "Building target config $@ succeeded."
|
||||
|
||||
## <CONFIG>_rev : build configured target and add revision to filename
|
||||
$(addsuffix _rev,$(BASE_CONFIGS)):
|
||||
$(V0) $(MAKE) fwo CONFIG=$(subst _rev,,$@) REV=yes
|
||||
|
||||
# When configs are not hydrated, BASE_CONFIGS is empty so config targets
|
||||
# have no recipe. Override Make's default "No rule" error with a helpful message
|
||||
# but only for targets explicitly requested on the command line.
|
||||
ifeq ($(wildcard $(CONFIG_DIR)/configs/),)
|
||||
.DEFAULT:
|
||||
@if echo " $(MAKECMDGOALS) " | grep -q " $@ "; then \
|
||||
echo "*** No rule to make target '$@'. If this is a configuration target, run 'make configs' first." >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user