From 7d288882c5e136a67268843eb7fecbfdfb532785 Mon Sep 17 00:00:00 2001 From: TallTechDude Date: Mon, 7 Feb 2022 03:10:40 +0000 Subject: [PATCH] feat: simplified Makefile build with SDK submodule --- .gitignore | 1 + .gitmodules | 3 +++ Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sdk | 1 + 4 files changed, 57 insertions(+) create mode 100644 .gitmodules create mode 100644 Makefile create mode 160000 sdk diff --git a/.gitignore b/.gitignore index f2b33858b..61e101478 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ output/** **/*.o +/custom.mk diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..878cf9462 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "sdk"] + path = sdk + url = https://github.com/openshwprojects/OpenBK7231T.git diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..de4412f59 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +# HACK - if COMPILE_PREX defined then we are being called running from original build_app.sh script in standard SDK +# Required to not break old build_app.sh script lines 74-77 +ifdef COMPILE_PREX +all: + @echo Calling original build_app.sh script + cd $(PWD)/../../platforms/$(TARGET_PLATFORM)/toolchain/$(TUYA_APPS_BUILD_PATH) && sh $(TUYA_APPS_BUILD_CMD) $(APP_NAME) $(APP_VERSION) $(TARGET_PLATFORM) +else + +######## Continue with custom simplied Makefile ######## + +# Use current folder name as app name +APP_NAME ?= $(shell basename $(CURDIR)) +# Use current timestamp as version number +TIMESTAMP := $(shell date +%Y%m%d_%H%M%S) +APP_VERSION ?= dev_$(TIMESTAMP) + +TARGET_PLATFORM ?= bk7231t +APPS_BUILD_PATH ?= ../bk7231t_os +APPS_BUILD_CMD ?= build.sh + +# Default target is to run build +all: build + +# Full target will clean then build all +.PHONY: full +full: clean build + +# Update/init git submodules +.PHONY: submodules +submodules: + git submodule update --init --recursive + +# Create symlink for App into SDK folder structure +sdk/apps/$(APP_NAME): + @echo Create symlink for $(APP_NAME) into sdk/apps folder + ln -s "$(shell pwd)/" "sdk/apps/$(APP_NAME)" + +# Build main binary +.PHONY: build +build: submodules sdk/apps/$(APP_NAME) + cd sdk/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH) && sh $(APPS_BUILD_CMD) $(APP_NAME) $(APP_VERSION) $(TARGET_PLATFORM) + +# clean .o files +.PHONY: clean +clean: + $(MAKE) -C sdk/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH) APP_BIN_NAME=$(APP_NAME) USER_SW_VER=$(APP_VERSION) clean + rm -rf output/* + +# Add custom Makefile if required +-include custom.mk + +endif \ No newline at end of file diff --git a/sdk b/sdk new file mode 160000 index 000000000..668f41e83 --- /dev/null +++ b/sdk @@ -0,0 +1 @@ +Subproject commit 668f41e83ab2d20253ea575586760a3c4a995825