Skip to content

Commit

Permalink
Merge pull request tuya#5 from btsimonh/AddCPPSupport
Browse files Browse the repository at this point in the history
Add cpp support
  • Loading branch information
openshwprojects authored Oct 19, 2022
2 parents 760163a + e1d07b9 commit be33768
Show file tree
Hide file tree
Showing 354 changed files with 39 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ platforms/bk7231n/bk7231n_os/tools/generate/*.rbl
!platforms/bk7231n/bk7231n_os/tools/generate/bk7231n_bootloader.bin
!platforms/bk7231n/bk7231n_os/tools/generate/bk7231n_bootloader_enc.bin
!platforms/bk7231n/bk7231n_os/tools/generate/package.bin
!platforms/bk7231n/toolchain/**/*.o


apps/*
!apps/obk*
Expand Down
47 changes: 37 additions & 10 deletions platforms/bk7231n/bk7231n_os/application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ endif
SRC_C =
DRAM_C =
SRC_OS =
SRC_CPP =

#application layer
SRC_C += ./beken378/app/app_bk.c
Expand Down Expand Up @@ -976,13 +977,26 @@ SRC_OS_LIST = $(notdir $(SRC_OS))
OBJ_OS_LIST = $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(SRC_OS_LIST)))
DEPENDENCY_OS_LIST = $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.d,$(SRC_OS_LIST)))

SRC_CPP_O = $(patsubst %.cpp,%.o,$(SRC_CPP))
SRC_CPP_LIST = $(notdir $(SRC_CPP))
OBJ_CPP_LIST = $(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(SRC_CPP_LIST)))
DEPENDENCY_CPP_LIST = $(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.d,$(SRC_CPP_LIST)))

# Compile options
# -------------------------------------------------------------------
CFLAGS =
CFLAGS += -g -mthumb -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -fsigned-char -fdata-sections -Wunknown-pragmas -nostdlib -Wno-unused-function -Wno-unused-but-set-variable
CPPDEFINES =
CPPDEFINES += -DPLATFORM_BK7231N=1
CPPDEFINES += -DPLATFORM_BEKEN=1

CCFLAGS = $(CPPDEFINES)
CCFLAGS += -g -mthumb -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os
CCFLAGS += -ffunction-sections -Wall -fsigned-char -fdata-sections -Wunknown-pragmas -nostdlib -Wno-unused-function -Wno-unused-but-set-variable

CFLAGS += -DPLATFORM_BK7231N=1
CFLAGS += -DPLATFORM_BEKEN=1
CXXFLAGS = $(CCFLAGS)
CXXFLAGS += -std=gnu++11 -MMD -fno-exceptions -fno-rtti -Wno-literal-suffix -Wno-attributes

CFLAGS = $(CCFLAGS)
CFLAGS += -std=c99 -Wunknown-pragmas -nostdlib -Wall

OSFLAGS =
OSFLAGS += -g -marm -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -fsigned-char -fdata-sections -Wunknown-pragmas
Expand All @@ -991,7 +1005,9 @@ ASMFLAGS =
ASMFLAGS += -g -marm -mthumb-interwork -mcpu=arm968e-s -march=armv5te -x assembler-with-cpp

LFLAGS =
LFLAGS += -g -Wl,--gc-sections -marm -mcpu=arm968e-s -mthumb-interwork -nostdlib -Xlinker -Map=tuya.map
LFLAGS += -g -Wl,--gc-sections -marm -mcpu=arm968e-s -mthumb-interwork
# LFLAGS += -nostdlib
LFLAGS += -Xlinker -Map=tuya.map
LFLAGS += -Wl,-wrap,malloc -Wl,-wrap,_malloc_r -Wl,-wrap,free -Wl,-wrap,_free_r -Wl,-wrap,zalloc -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,_realloc_r
LFLAGS += -Wl,-wrap,printf -Wl,-wrap,vsnprintf -Wl,-wrap,snprintf -Wl,-wrap,sprintf -Wl,-wrap,puts

Expand All @@ -1006,6 +1022,8 @@ LIBFLAGS += -L./beken378/lib/ -lrwnx
ifeq ("${CFG_BLE_5X_USE_RWIP_LIB}", "1")
LIBFLAGS += -L./beken378/lib/ -lble
endif
LIBFLAGS += -lstdc++


ifeq ("${CFG_GIT_VERSION}", "")

Expand Down Expand Up @@ -1042,7 +1060,7 @@ COMP_SRC_DIRS += $(foreach n, $(COMPONENTS_LIB), $(shell find $(TOP_DIR)/compone
TY_INC_DIRS += $(foreach n, $(COMPONENTS_LIB), $(shell find $(TOP_DIR)/components/$(n) -type d))

COMP_SRCS += $(foreach dir, $(COMP_SRC_DIRS), $(wildcard $(dir)/*.c))
COMP_SRCS += $(foreach dir, $(COMP_SRC_DIRS), $(wildcard $(dir)/*.cpp))
#COMP_SRCS += $(foreach dir, $(COMP_SRC_DIRS), $(wildcard $(dir)/*.cpp))
COMP_SRCS += $(foreach dir, $(COMP_SRC_DIRS), $(wildcard $(dir)/*.s))
COMP_SRCS += $(foreach dir, $(COMP_SRC_DIRS), $(wildcard $(dir)/*.S))

Expand Down Expand Up @@ -1083,9 +1101,9 @@ TY_SRC_DIRS += $(shell find $(TOP_DIR)/apps/$(APP_BIN_NAME)/src -type d)
TY_SRC_DIRS += $(shell find ../tuya_os_adapter/src -type d)

SRC_C += $(foreach dir, $(TY_SRC_DIRS), $(wildcard $(dir)/*.c)) # need export
SRC_C += $(foreach dir, $(TY_SRC_DIRS), $(wildcard $(dir)/*.cpp))
SRC_C += $(foreach dir, $(TY_SRC_DIRS), $(wildcard $(dir)/*.s))
SRC_C += $(foreach dir, $(TY_SRC_DIRS), $(wildcard $(dir)/*.S))
SRC_CPP += $(foreach dir, $(TY_SRC_DIRS), $(wildcard $(dir)/*.cpp))

TY_INC_DIRS += $(shell find $(TOP_DIR)/sdk/include -type d)
#SDK_INCLUDE_DIRS := $(shell find $(TOP_DIR)/sdk -name include -type d)
Expand All @@ -1108,7 +1126,7 @@ sinclude $(TY_DEPENDENCY_LIST)
CUR_PATH = $(shell pwd)
.PHONY: application

test_target: prerequirement $(SRC_O) $(SRC_S_O) $(SRC_OS_O) $(TY_IOT_LIB)
test_target: prerequirement $(SRC_O) $(SRC_S_O) $(SRC_OS_O) $(SRC_CPP_O) $(TY_IOT_LIB)
ifneq ($(COMPONENTS_LIB),)
ifneq ($(COMP_SRCS),)
@$(MAKE) -f application.mk comp_libs
Expand All @@ -1117,9 +1135,9 @@ endif # COMPONENTS_LIB

application: test_target
ifeq ("${ota_idx}", "1")
$(LD) $(LFLAGS) -o $(TY_OUTPUT)/$(APP_BIN_NAME)_$(APP_VERSION).axf $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(LIBFLAGS) -T./beken378/build/bk7231n_ota.ld
$(LD) $(LFLAGS) -o $(TY_OUTPUT)/$(APP_BIN_NAME)_$(APP_VERSION).axf $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(OBJ_CPP_LIST) $(LIBFLAGS) -T./beken378/build/bk7231n_ota.ld
else ifeq ("${ota_idx}", "2")
$(LD) $(LFLAGS) -o $(TY_OUTPUT)/$(APP_BIN_NAME)_$(APP_VERSION).axf $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(LIBFLAGS) -T./beken378/build/bk7231n_ota2.ld
$(LD) $(LFLAGS) -o $(TY_OUTPUT)/$(APP_BIN_NAME)_$(APP_VERSION).axf $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(OBJ_CPP_LIST) $(LIBFLAGS) -T./beken378/build/bk7231n_ota2.ld
else
@echo ===========================================================
@echo ota_idx must be "1" or "2"
Expand Down Expand Up @@ -1165,9 +1183,17 @@ $(SRC_OS_O): %.o : %.c
@cp $@ $(OBJ_DIR)/$(notdir $@)
@chmod 777 $(OBJ_DIR)/$(notdir $@)

$(SRC_CPP_O): %.o : %.cpp
@ echo "build $@"
@$(CC) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
@$(CC) $(CXXFLAGS) $(INCLUDES) -c $< -MM -MT $@ -MF $(OBJ_DIR)/$(notdir $(patsubst %.o,%.d,$@))
@cp $@ $(OBJ_DIR)/$(notdir $@)
@chmod 777 $(OBJ_DIR)/$(notdir $@)

-include $(DEPENDENCY_LIST)
-include $(DEPENDENCY_S_LIST)
-include $(DEPENDENCY_OS_LIST)
-include $(DEPENDENCY_CPP_LIST)

# -------------------------------------------------------------------
# Generate build info
Expand Down Expand Up @@ -1199,6 +1225,7 @@ endif # COMPONENTS_LIB
rm -f $(SRC_O)
rm -f $(SRC_S_O)
rm -f $(SRC_OS_O)
rm -f $(SRC_CPP_O)
rm -rf $(TY_OBJS)
rm -f $(TY_IOT_LIB)
rm -rf $(TY_OUTPUT)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit be33768

Please sign in to comment.