Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified Local Build using Permanent Config #12341

Merged
merged 5 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions DEFAULT_LICENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* This file is part of Betaflight.
blckmn marked this conversation as resolved.
Show resolved Hide resolved
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software under the terms of the GNU General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Betaflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
60 changes: 44 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#

# The target to build, see BASE_TARGETS below
TARGET ?= STM32F405
BOARD ?=
DEFAULT_TARGET ?= STM32F405
TARGET ?=
CONFIG ?=

# Compile-time options
OPTIONS ?=
Expand Down Expand Up @@ -80,8 +81,9 @@ include $(ROOT)/make/system-id.mk
include $(ROOT)/make/checks.mk

# configure some directories that are relative to wherever ROOT_DIR is located
TOOLS_DIR ?= $(ROOT)/tools
DL_DIR := $(ROOT)/downloads
TOOLS_DIR ?= $(ROOT)/tools
DL_DIR := $(ROOT)/downloads
CONFIG_DIR ?= $(ROOT)/src/config

export RM := rm

Expand All @@ -94,10 +96,35 @@ include $(ROOT)/make/tools.mk
# default xtal value for F4 targets
HSE_VALUE ?= 8000000

ifneq ($(BOARD),)
# silently ignore if the file is not present. Allows for target defaults.
-include $(ROOT)/src/main/board/$(BOARD)/board.mk
# Search path for sources
VPATH := $(SRC_DIR):$(SRC_DIR)/startup
FATFS_DIR = $(ROOT)/lib/main/FatFS
FATFS_SRC = $(notdir $(wildcard $(FATFS_DIR)/*.c))
CSOURCES := $(shell find $(SRC_DIR) -name '*.c')

ifneq ($(CONFIG),)

ifeq ($(wildcard $(CONFIG_DIR)/$(CONFIG)/config.h),)
$(error Config file not found: $(CONFIG_DIR)/$(CONFIG)/config.h)
endif

ifneq ($(TARGET),)
$(error TARGET or CONFIG should be specified. Not both.)
endif

TARGET := $(shell grep " FC_TARGET_MCU" src/config/$(CONFIG)/config.h | awk '{print $$3}' )
INCLUDE_DIRS += $(CONFIG_DIR)/$(CONFIG)
CONFIG_FILE := $(CONFIG_DIR)/$(CONFIG)/config.h

ifeq ($(TARGET),)
$(error No TARGET identified. Is the config.h valid for $(CONFIG)?)
endif

else
ifeq ($(TARGET),)
TARGET := $(DEFAULT_TARGET)
endif
endif #CONFIG

BASE_TARGETS = $(sort $(notdir $(patsubst %/,%,$(dir $(wildcard $(ROOT)/src/main/target/*/target.mk)))))
CI_TARGETS := $(BASE_TARGETS)
Expand All @@ -114,13 +141,6 @@ FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk

FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH)

# Search path for sources
VPATH := $(SRC_DIR):$(SRC_DIR)/startup
FATFS_DIR = $(ROOT)/lib/main/FatFS
FATFS_SRC = $(notdir $(wildcard $(FATFS_DIR)/*.c))

CSOURCES := $(shell find $(SRC_DIR) -name '*.c')

LD_FLAGS :=
EXTRA_LD_FLAGS :=

Expand Down Expand Up @@ -157,6 +177,11 @@ $(error No TARGET_MCU_FAMILY specified. Is the target.mk valid for $(TARGET)?)
endif

TARGET_FLAGS := -D$(TARGET) -D$(TARGET_MCU_FAMILY) $(TARGET_FLAGS)

ifneq ($(CONFIG),)
TARGET_FLAGS := $(TARGET_FLAGS) -DUSE_CONFIG
endif

include $(ROOT)/make/mcu/$(TARGET_MCU_FAMILY).mk

# openocd specific includes
Expand Down Expand Up @@ -291,8 +316,11 @@ CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
$(addprefix -I,$(INCLUDE_DIRS)) \
-I/usr/include -I/usr/include/linux

ifneq ($(CONFIG),)
TARGET_BASENAME = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET)_$(CONFIG)
else
TARGET_BASENAME = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET)

endif
#
# Things we will build
#
Expand Down Expand Up @@ -633,7 +661,7 @@ $(TARGET_EF_HASH_FILE):
$(V1) touch $(TARGET_EF_HASH_FILE)

# rebuild everything when makefile changes or the extra flags have changed
$(TARGET_OBJS): $(TARGET_EF_HASH_FILE) Makefile $(TARGET_DIR)/target.mk $(wildcard make/*)
$(TARGET_OBJS): $(TARGET_EF_HASH_FILE) Makefile $(TARGET_DIR)/target.mk $(wildcard make/*) $(CONFIG_FILE)

# include auto-generated dependencies
-include $(TARGET_DEPS)
8 changes: 1 addition & 7 deletions make/source.mk
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ FLASH_SRC += \
drivers/flash_w25q128fv.c \
drivers/flash_w25m.c \
io/flashfs.c

SDCARD_SRC += \
drivers/sdcard.c \
drivers/sdcard_spi.c \
Expand Down Expand Up @@ -459,12 +459,6 @@ SRC += $(VCP_SRC)

# end target specific make file checks

ifneq ($(BOARD),)
SRC += board/$(BOARD)/board.c
INCLUDE_DIRS += $(ROOT)/src/main/board/$(BOARD)
TARGET_FLAGS := -D'__BOARD__="$(BOARD)"' $(TARGET_FLAGS)
endif

# Search path and source files for the ST stdperiph library
VPATH := $(VPATH):$(STDPERIPH_DIR)/src

Expand Down
38 changes: 38 additions & 0 deletions src/config/AG3XF4/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software under the terms of the GNU General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Betaflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/

/*
This file has been auto generated from unified-targets repo.

The auto generation is transitional only.
*/

#define FC_TARGET_MCU STM32F405

#define BOARD_NAME AG3XF4
#define MANUFACTURER_ID AIRB

#define USE_GYRO_SPI_MPU6500
#define USE_GYRO_SPI_MPU6000
#define USE_ACC_SPI_MPU6500
#define USE_ACC_SPI_MPU6000
#define USE_BARO_BMP280
#define USE_MAX7456
38 changes: 38 additions & 0 deletions src/config/AG3XF7/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software under the terms of the GNU General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Betaflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/

/*
This file has been auto generated from unified-targets repo.

The auto generation is transitional only.
*/

#define FC_TARGET_MCU STM32F7X2

#define BOARD_NAME AG3XF7
#define MANUFACTURER_ID AIRB

#define USE_GYRO_SPI_MPU6500
#define USE_GYRO_SPI_MPU6000
#define USE_ACC_SPI_MPU6500
#define USE_ACC_SPI_MPU6000
#define USE_BARO_BMP280
#define USE_MAX7456
41 changes: 41 additions & 0 deletions src/config/AIKONF4/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software under the terms of the GNU General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Betaflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/

/*
This file has been auto generated from unified-targets repo.

The auto generation is transitional only.
*/

#define FC_TARGET_MCU STM32F405

#define BOARD_NAME AIKONF4
#define MANUFACTURER_ID AIKO

#define USE_GYRO_SPI_MPU6000
#define USE_ACC_SPI_MPU6000
#define USE_ACC_SPI_ICM20602
#define USE_GYRO_SPI_ICM20602
#define USE_ACCGYRO_BMI270
#define USE_BARO_BMP280
#define USE_BARO_DPS310
#define USE_FLASH_M25P16
#define USE_MAX7456
39 changes: 39 additions & 0 deletions src/config/AIKONF7/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software under the terms of the GNU General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Betaflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/

/*
This file has been auto generated from unified-targets repo.

The auto generation is transitional only.
*/

#define FC_TARGET_MCU STM32F7X2

#define BOARD_NAME AIKONF7
#define MANUFACTURER_ID AIKO

#define USE_GYRO_SPI_MPU6000
#define USE_ACC_SPI_MPU6000
#define USE_ACCGYRO_BMI270
#define USE_BARO_SPI_BMP280
#define USE_BARO_SPI_DPS310
#define USE_FLASH_M25P16
#define USE_MAX7456
43 changes: 43 additions & 0 deletions src/config/AIRBOTF4/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software under the terms of the GNU General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Betaflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/

/*
This file has been auto generated from unified-targets repo.

The auto generation is transitional only.
*/

#define FC_TARGET_MCU STM32F405

#define BOARD_NAME AIRBOTF4
#define MANUFACTURER_ID AIRB

#define USE_ACC_SPI_MPU6500
#define USE_GYRO_SPI_MPU6500
#define USE_ACC_SPI_MPU6000
#define USE_GYRO_SPI_MPU6000
#define USE_BARO_SPI_BMP280
#define USE_MAX7456
#define USE_FLASH_M25P16
#define USE_BARO_BMP280
#define USE_BARO_BMP280
#define USE_BARO_BMP085
#define USE_BARO_MS5611