Skip to content

Commit

Permalink
ports/psoc6: Makefile system rework to avoid unstaged git changes.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Feb 6, 2024
1 parent 7be59c5 commit 2007ddb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
31 changes: 22 additions & 9 deletions ports/psoc6/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
# get active board from mtb-lib makefile
# mtb-lib makefile set TARGET board by using
# "mtb_set_bsp" target or targets depending on it
# as "mtb_init".
BOARD ?=

# Check if the ModusToolbox setup has been initialized
# If that is the case, get active board
MTB_LIB_DIR = mtb-libs
MTB_LIB_MAKEFILE = $(MTB_LIB_DIR)/Makefile
BOARD ?= $(shell egrep '^ *TARGET' $(MTB_LIB_MAKEFILE) | sed 's/^.*= *//g' | sed 's/APP_//')
MTB_LIBS_APP_INFO = $(MTB_LIB_DIR)/build/get_app_info.txt
ifneq ($(wildcard $(MTB_LIBS_APP_INFO)),)
ACTIVE_BOARD = $(shell egrep '^ *MTB_TARGET' $(MTB_LIBS_APP_INFO) | sed 's/^.*= *//g' | sed 's/APP_//')
endif

# Get active board from mtb-lib previous runs
# The board is set only after make mtb_init
# has been run.
ifeq ($(BOARD),)
ifeq ($(ACTIVE_BOARD),)
$(error ModusToolbox not initialized. Run "make mtb_init BOARD=<target-board>" to configure the environment. )
else
BOARD = $(ACTIVE_BOARD)
endif
endif

BOARD_DIR = boards/$(BOARD)

$(info Active PSoC6 board : $(BOARD))
$(info PSoC6 board : $(BOARD))

ifeq ($(wildcard $(BOARD_DIR)/.),)
$(error Invalid BOARD specified)
Expand Down Expand Up @@ -79,7 +93,6 @@ else
MICROPY_ROM_TEXT_COMPRESSION ?= 1
endif


$(info Compiling in $(CONFIG) mode !)

#ToDo: Post adding af functionality, refactor to minimize dependent variables in py script if possible
Expand Down Expand Up @@ -163,7 +176,7 @@ SRC_C = help.c \
main.c \
mphalport.c \
frozen_content.c \
$(BUILD)/pins_$(BOARD).c
pins_$(BOARD).c

SRC_ASM += shared/runtime/gchelper_thumb1.s

Expand Down
7 changes: 1 addition & 6 deletions ports/psoc6/mtb-libs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ MTB_TYPE=COMBINED
# configurations. If TARGET is manually edited, ensure TARGET_<BSP>.mtb with a
# valid URL exists in the application, run 'make getlibs' to fetch BSP contents
# and update or regenerate launch configurations for your IDE.
TARGET=APP_CY8CPROTO-062-4343W

# # Board dependencies
# ifeq ($(TARGET),APP_CY8CPROTO-062-4343W)
# NETWORK_ENABLE = 1
# endif
TARGET=APP_$(BOARD)

# Name of application (used to derive name of final linked file).
#
Expand Down
15 changes: 7 additions & 8 deletions ports/psoc6/mtb-libs/makefile_mtb.mk
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# get variable definitions from main makefile
MTB_LIBS_DIR = mtb-libs
MTB_MAIN_MAKEFILE := $(MTB_LIBS_DIR)/Makefile
MTB_TARGET := $(shell egrep '^ *TARGET' $(MTB_MAIN_MAKEFILE) | sed 's/^.*= *//g')
MTB_CONFIG ?= $(shell egrep '^ *CONFIG' $(MTB_MAIN_MAKEFILE) | sed 's/^.*= *//g')

MTB_LIBS_BUILD_DIR := $(MTB_LIBS_DIR)/$(BUILD)
MTB_LIBS_BOARD_BUILD_DIR := $(MTB_LIBS_BUILD_DIR)/$(MTB_TARGET)/$(MPY_MTB_CONFIG)
MTB_LIBS_BOARD_BUILD_DIR := $(MTB_LIBS_BUILD_DIR)/APP_$(BOARD)/$(MPY_MTB_CONFIG)

MPY_MTB_LIB_NAME = $(file < $(MTB_LIBS_BOARD_BUILD_DIR)/artifact.rsp)
MTB_STATIC_LIB_NAME = $(file < $(MTB_LIBS_BOARD_BUILD_DIR)/artifact.rsp)

$(info MTB_MAIN_MAKEFILE : $(MTB_MAIN_MAKEFILE))
$(info MTB_TARGET : $(MTB_TARGET))
$(info MTB_TARGET : APP_$(BOARD))
$(info MTB_CONFIG : $(MTB_CONFIG))
$(info MTB_LIB_NAME : $(MPY_MTB_LIB_NAME))
$(info MTB_LIB_NAME : $(MTB_STATIC_LIB_NAME))

$(info MTB_LIBS_BUILD_DIR : $(MTB_LIBS_BUILD_DIR))
$(info MTB_LIBS_BOARD_BUILD_DIR : $(MTB_LIBS_BOARD_BUILD_DIR))
Expand Down Expand Up @@ -77,7 +76,7 @@ mtb_deinit: clean

# Some of the configuration variables are passed to the ModusToolbox
# Makefile to include/exclude certain middleware libraries and components
MPY_MTB_MAKE_VARS = MICROPY_PY_NETWORK=$(MICROPY_PY_NETWORK) MICROPY_PY_SSL=$(MICROPY_PY_SSL)
MPY_MTB_MAKE_VARS = MICROPY_PY_NETWORK=$(MICROPY_PY_NETWORK) MICROPY_PY_SSL=$(MICROPY_PY_SSL) BOARD=$(BOARD)

# build MTB project
mtb_build:
Expand All @@ -96,7 +95,7 @@ mtb_get_build_flags: mtb_build
$(eval INC += $(subst -I,-I$(MTB_LIBS_DIR)/,$(MPY_MTB_INCLUDE_DIRS)))
$(eval INC += -I$(BOARD_DIR))
$(eval MPY_MTB_LIBRARIES = $(file < $(MTB_LIBS_BOARD_BUILD_DIR)/liblist.rsp))
$(eval LIBS += $(MTB_LIBS_BOARD_BUILD_DIR)/$(MPY_MTB_LIB_NAME))
$(eval LIBS += $(MTB_LIBS_BOARD_BUILD_DIR)/$(MTB_STATIC_LIB_NAME))
$(eval CFLAGS += $(shell $(PYTHON) $(MTB_LIBS_DIR)/mtb_build_info.py ccxxflags $(MTB_LIBS_BOARD_BUILD_DIR)/.cycompiler ))
$(eval CXXFLAGS += $(CFLAGS))
$(eval LDFLAGS += $(shell $(PYTHON) $(MTB_LIBS_DIR)/mtb_build_info.py ldflags $(MTB_LIBS_BOARD_BUILD_DIR)/.cylinker $(MTB_LIBS_DIR)))
Expand All @@ -123,7 +122,7 @@ attached_devs:
$(info List of attached targets : $(ATTACHED_TARGET_LIST))

ifndef EXT_HEX_FILE
HEX_FILE = $(MPY_DIR_OF_MAIN_MAKEFILE)/build/firmware.hex
HEX_FILE = $(BUILD)/firmware.hex
PROG_DEPS=build
else
HEX_FILE = $(EXT_HEX_FILE)
Expand Down

0 comments on commit 2007ddb

Please sign in to comment.