Make changes to sdk from shell scripts just before start of build (#1381)

* Add possibility to call a shell script to make changes to  sdk just before building the app

* Changes to Makefile

* Changed pre_build.sh to only contain some comments how to use it
This commit is contained in:
MaxineMuster
2024-10-16 13:10:32 +02:00
committed by GitHub
parent 462325fa9b
commit 968ebc1b09
11 changed files with 355 additions and 7 deletions

View File

@ -74,12 +74,73 @@ sdk/OpenLN882H/project/OpenBeken/app:
@mkdir -p "sdk/OpenLN882H/project/OpenBeken"
ln -s "$(shell pwd)/" "sdk/OpenLN882H/project/OpenBeken/app"
.PHONY: prebuild_OpenBK7231N prebuild_OpenBK7231T prebuild_OpenBL602 prebuild_OpenLN882H prebuild_OpenW600 prebuild_OpenW800 prebuild_OpenXR809
prebuild_OpenBK7231N:
@if [ -e platforms/BK7231N/pre_build.sh ]; then \
echo "prebuild found for OpenBK7231N"; \
sh platforms/BK7231N/pre_build.sh; \
else echo "prebuild for OpenBK7231N not found ... "; \
fi
prebuild_OpenBK7231T:
@if [ -e platforms/BK7231T/pre_build.sh ]; then \
echo "prebuild found for OpenBK7231T"; \
sh platforms/BK7231T/pre_build.sh; \
else echo "prebuild for OpenBK7231T not found ... "; \
fi
prebuild_OpenBL602:
@if [ -e platforms/BL602/pre_build.sh ]; then \
echo "prebuild found for OpenBL602"; \
sh platforms/BL602/pre_build.sh; \
else echo "prebuild for OpenBL602 not found ... "; \
fi
prebuild_OpenLN882H:
@if [ -e platforms/LN882H/pre_build.sh ]; then \
echo "prebuild found for OpenLN882H"; \
sh platforms/LN882H/pre_build.sh; \
else echo "prebuild for OpenLN882H not found ... "; \
fi
prebuild_OpenW600:
@if [ -e platforms/W600/pre_build.sh ]; then \
echo "prebuild found for OpenW600"; \
sh platforms/W600/pre_build.sh; \
else echo "prebuild for OpenW600 not found ... "; \
fi
prebuild_OpenW800:
@if [ -e platforms/W800/pre_build.sh ]; then \
echo "prebuild found for OpenW800"; \
sh platforms/W800/pre_build.sh; \
else echo "prebuild for OpenW800 not found ... "; \
fi
prebuild_OpenXR809:
@if [ -e platforms/XR809/pre_build.sh ]; then \
echo "prebuild found for OpenXR809"; \
sh platforms/XR809/pre_build.sh; \
else echo "prebuild for OpenXR809 not found ... "; \
fi
# Build main binaries
OpenBK7231T:
OpenBK7231T: prebuild_OpenBK7231T
$(MAKE) APP_NAME=OpenBK7231T TARGET_PLATFORM=bk7231t SDK_PATH=sdk/OpenBK7231T APPS_BUILD_PATH=../bk7231t_os build-BK7231
OpenBK7231N:
OpenBK7231N: prebuild_OpenBK7231N
$(MAKE) APP_NAME=OpenBK7231N TARGET_PLATFORM=bk7231n SDK_PATH=sdk/OpenBK7231N APPS_BUILD_PATH=../bk7231n_os build-BK7231
sdk/OpenXR809/tools/gcc-arm-none-eabi-4_9-2015q2:
@ -89,7 +150,7 @@ sdk/OpenXR809/tools/gcc-arm-none-eabi-4_9-2015q2:
.PHONY: OpenXR809 build-XR809
# Retry OpenXR809 a few times to account for calibration file issues
RETRY = 3
OpenXR809:
OpenXR809: prebuild_OpenXR809
@for i in `seq 1 ${RETRY}`; do ($(MAKE) -k build-XR809; echo Prebuild attempt $$i/${RETRY}); done
@echo Running build final time to check output
$(MAKE) build-XR809;
@ -108,7 +169,7 @@ build-BK7231: submodules $(SDK_PATH)/apps/$(APP_NAME)
rm $(SDK_PATH)/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH)/tools/generate/$(APP_NAME)_*.rbl || /bin/true
rm $(SDK_PATH)/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH)/tools/generate/$(APP_NAME)_*.bin || /bin/true
OpenBL602: submodules sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
OpenBL602: submodules sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared prebuild_OpenBL602
$(MAKE) -C sdk/OpenBL602/customer_app/bl602_sharedApp USER_SW_VER=$(APP_VERSION) CONFIG_CHIP_NAME=BL602 CONFIG_LINK_ROM=1 -j
$(MAKE) -C sdk/OpenBL602/customer_app/bl602_sharedApp USER_SW_VER=$(APP_VERSION) CONFIG_CHIP_NAME=BL602 bins
mkdir -p output/$(APP_VERSION)
@ -127,21 +188,21 @@ sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin: submodules
cd sdk/OpenW600/tools && tar -xf ../support/*.tar.bz2
.PHONY: OpenW800
OpenW800: sdk/OpenW800/tools/w800/csky/bin sdk/OpenW800/sharedAppContainer/sharedApp
OpenW800: sdk/OpenW800/tools/w800/csky/bin sdk/OpenW800/sharedAppContainer/sharedApp prebuild_OpenW800
$(MAKE) -C sdk/OpenW800 EXTRA_CCFLAGS=-DPLATFORM_W800 CONFIG_W800_USE_LIB=n CONFIG_W800_TOOLCHAIN_PATH="$(shell realpath sdk/OpenW800/tools/w800/csky/bin)/"
mkdir -p output/$(APP_VERSION)
cp sdk/OpenW800/bin/w800/w800.fls output/$(APP_VERSION)/OpenW800_$(APP_VERSION).fls
cp sdk/OpenW800/bin/w800/w800_ota.img output/$(APP_VERSION)/OpenW800_$(APP_VERSION)_ota.img
.PHONY: OpenW600
OpenW600: sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin sdk/OpenW600/sharedAppContainer/sharedApp
OpenW600: sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin sdk/OpenW600/sharedAppContainer/sharedApp prebuild_OpenW600
$(MAKE) -C sdk/OpenW600 TOOL_CHAIN_PATH="$(shell realpath sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin)/" APP_VERSION=$(APP_VERSION)
mkdir -p output/$(APP_VERSION)
cp sdk/OpenW600/bin/w600/w600.fls output/$(APP_VERSION)/OpenW600_$(APP_VERSION).fls
cp sdk/OpenW600/bin/w600/w600_gz.img output/$(APP_VERSION)/OpenW600_$(APP_VERSION)_gz.img
.PHONY: OpenLN882H
OpenLN882H: submodules sdk/OpenLN882H/project/OpenBeken/app
OpenLN882H: submodules sdk/OpenLN882H/project/OpenBeken/app prebuild_OpenLN882H
CROSS_TOOLCHAIN_ROOT="/usr/" cmake sdk/OpenLN882H -B sdk/OpenLN882H/build
CROSS_TOOLCHAIN_ROOT="/usr/" cmake --build ./sdk/OpenLN882H/build
mkdir -p output/$(APP_VERSION)

View File

@ -0,0 +1,41 @@
# This script will be called just before starting build process for BK7231N
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So if your PR requires a changed define in SDK, you can do this here
#
#
# As an example you will find a script below which will copy all content of the "override"
# directory to the corresponding location in the SDK
#
#DIRNAME=$(dirname $0);
#echo "PREBUILD script! Executed from $DIRNAME!"
# allow whitspace in file or path, so take only newline as seperator
#OFS=$IFS
#IFS='
#'
#for X in $(find platforms/BK7231N/override/ -type f);do
# # script is executed from main app directory, so take found file and path as source
# S=${X};
# # destination is path stripped from path to override
# # so inside "override" we have the full path to the file
# # starting with "sdk/OpenBK7231N/..."
# D=${X#platforms/BK7231N/override/};
# # if file is present, we replace it, otherwise file is added ...
# [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
# cp $S $D;
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/file_to_change.c
# or, let's assume you made a local change to your SDK
# and make a diff from that change (inside sdk/OpenBK7231N/)
# git diff > ../../platforms/BK7231N/my_change.diff
# ( or make the diff and copy this file to platforms/BK7231N)
#
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenBK7231N < platforms/BK7231N/my_change.diff

View File

@ -0,0 +1,41 @@
# This script will be called just before starting build process for BK7231T
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So your PR needs a modified define in the SDK, for example ? This script can make this change directly before the build.
#
#
# As an example you will find a script below which will copy all content of the "override"
# directory to the corresponding location in the SDK
#
#DIRNAME=$(dirname $0);
#echo "PREBUILD script! Executed from $DIRNAME!"
# allow whitspace in file or path, so take only newline as seperator
#OFS=$IFS
#IFS='
#'
#for X in $(find platforms/BK7231T/override/ -type f);do
# # script is executed from main app directory, so take found file and path as source
# S=${X};
# # destination is path stripped from path to override
# # so inside "override" we have the full path to the file
# # starting with "sdk/OpenBK7231T/..."
# D=${X#platforms/BK7231T/override/};
# # if file is present, we replace it, otherwise file is added ...
# [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
# cp $S $D;
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenBK7231T/platforms/bk7231t/bk7231t_os/beken378/file_to_change.c
# or, let's assume you made a local change to your SDK
# and make a diff from that change (inside sdk/OpenBK7231T/)
# git diff > ../../platforms/BK7231T/my_change.diff
# ( or make the diff and copy this file to platforms/BK7231T)
#
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenBK7231T < platforms/BK7231T/my_change.diff

View File

@ -0,0 +1,41 @@
# This script will be called just before starting build process for BL602
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So your PR needs a modified define in the SDK, for example ? This script can make this change directly before the build.
#
#
# As an example you will find a script below which will copy all content of the "override"
# directory to the corresponding location in the SDK
#
#DIRNAME=$(dirname $0);
#echo "PREBUILD script! Executed from $DIRNAME!"
# allow whitspace in file or path, so take only newline as seperator
#OFS=$IFS
#IFS='
#'
#for X in $(find platforms/BL602/override/ -type f);do
# # script is executed from main app directory, so take found file and path as source
# S=${X};
# # destination is path stripped from path to override
# # so inside "override" we have the full path to the file
# # starting with "sdk/OpenBL602/..."
# D=${X#platforms/BL602/override/};
# # if file is present, we replace it, otherwise file is added ...
# [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
# cp $S $D;
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenBL602/components/bl602/bl602_std/file_to_change.c
# or, let's assume you made a local change to your SDK
# and make a diff from that change (inside sdk/OpenBL602/)
# git diff > ../../platforms/BL602/my_change.diff
# ( or make the diff and copy this file to platforms/BL602)
#
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenBL602 < platforms/BL602/my_change.diff

View File

@ -0,0 +1,41 @@
# This script will be called just before starting build process for LN882H
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So your PR needs a modified define in the SDK, for example ? This script can make this change directly before the build.
#
#
# As an example you will find a script below which will copy all content of the "override"
# directory to the corresponding location in the SDK
#
#DIRNAME=$(dirname $0);
#echo "PREBUILD script! Executed from $DIRNAME!"
# allow whitspace in file or path, so take only newline as seperator
#OFS=$IFS
#IFS='
#'
#for X in $(find platforms/LN882H/override/ -type f);do
# # script is executed from main app directory, so take found file and path as source
# S=${X};
# # destination is path stripped from path to override
# # so inside "override" we have the full path to the file
# # starting with "sdk/OpenLN882H/..."
# D=${X#platforms/LN882H/override/};
# # if file is present, we replace it, otherwise file is added ...
# [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
# cp $S $D;
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenLN882H/project/OpenBeken/cfg/file_to_change.h
# or, let's assume you made a local change to your SDK
# and make a diff from that change (inside sdk/OpenLN882H/)
# git diff > ../../platforms/LN882H/my_change.diff
# ( or make the diff and copy this file to platforms/LN882H)
#
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenLN882H < platforms/LN882H/my_change.diff

View File

@ -0,0 +1,41 @@
# This script will be called just before starting build process for W600
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So your PR needs a modified define in the SDK, for example ? This script can make this change directly before the build.
#
#
# As an example you will find a script below which will copy all content of the "override"
# directory to the corresponding location in the SDK
#
#DIRNAME=$(dirname $0);
#echo "PREBUILD script! Executed from $DIRNAME!"
# allow whitspace in file or path, so take only newline as seperator
#OFS=$IFS
#IFS='
#'
#for X in $(find platforms/W600/override/ -type f);do
# # script is executed from main app directory, so take found file and path as source
# S=${X};
# # destination is path stripped from path to override
# # so inside "override" we have the full path to the file
# # starting with "sdk/OpenW600/..."
# D=${X#platforms/W600/override/};
# # if file is present, we replace it, otherwise file is added ...
# [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
# cp $S $D;
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenW600/platform/drivers/file_to_change.c
# or, let's assume you made a local change to your SDK
# and make a diff from that change (inside sdk/OpenW600/)
# git diff > ../../platforms/W600/my_change.diff
# ( or make the diff and copy this file to platforms/W600)
#
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenW600 < platforms/W600/my_change.diff

View File

@ -0,0 +1,41 @@
# This script will be called just before starting build process for W800
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So your PR needs a modified define in the SDK, for example ? This script can make this change directly before the build.
#
#
# As an example you will find a script below which will copy all content of the "override"
# directory to the corresponding location in the SDK
#
#DIRNAME=$(dirname $0);
#echo "PREBUILD script! Executed from $DIRNAME!"
# allow whitspace in file or path, so take only newline as seperator
#OFS=$IFS
#IFS='
#'
#for X in $(find platforms/W800/override/ -type f);do
# # script is executed from main app directory, so take found file and path as source
# S=${X};
# # destination is path stripped from path to override
# # so inside "override" we have the full path to the file
# # starting with "sdk/OpenW800/..."
# D=${X#platforms/W800/override/};
# # if file is present, we replace it, otherwise file is added ...
# [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
# cp $S $D;
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenW800/platform/drivers/gpio/file_to_change.c
# or, let's assume you made a local change to your SDK
# and make a diff from that change (inside sdk/OpenW800/)
# git diff > ../../platforms/W800/my_change.diff
# ( or make the diff and copy this file to platforms/W800)
#
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenW800 < platforms/W800/my_change.diff

View File

@ -0,0 +1,41 @@
# This script will be called just before starting build process for XR809
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So your PR needs a modified define in the SDK, for example ? This script can make this change directly before the build.
#
#
# As an example you will find a script below which will copy all content of the "override"
# directory to the corresponding location in the SDK
#
#DIRNAME=$(dirname $0);
#echo "PREBUILD script! Executed from $DIRNAME!"
# allow whitspace in file or path, so take only newline as seperator
#OFS=$IFS
#IFS='
#'
#for X in $(find platforms/XR809/override/ -type f);do
# # script is executed from main app directory, so take found file and path as source
# S=${X};
# # destination is path stripped from path to override
# # so inside "override" we have the full path to the file
# # starting with "sdk/OpenXR809/..."
# D=${X#platforms/XR809/override/};
# # if file is present, we replace it, otherwise file is added ...
# [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
# cp $S $D;
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenXR809/src/driver/chip/file_to_change.c
# or, let's assume you made a local change to your SDK
# and make a diff from that change (inside sdk/OpenXR809/)
# git diff > ../../platforms/XR809/my_change.diff
# ( or make the diff and copy this file to platforms/XR809)
#
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenXR809 < platforms/XR809/my_change.diff