From 44f3ef7acd92c334ea2b3f9511c45e4b76027f35 Mon Sep 17 00:00:00 2001 From: Koen De Vleeschauwer Date: Thu, 3 Jun 2021 07:45:33 +0200 Subject: [PATCH] build options in source comments --- platform.txt | 4 ++-- system/extras/prebuild.sh | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/platform.txt b/platform.txt index 7dc8afb5fc..034182d4ea 100644 --- a/platform.txt +++ b/platform.txt @@ -111,8 +111,8 @@ build.opt.path={build.path}/sketch/{build.opt.name} extras.path={build.system.path}/extras # Create empty {build.opt} if not exists in the output sketch dir and force include of SrcWrapper library -recipe.hooks.prebuild.1.pattern="{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" -recipe.hooks.prebuild.1.pattern.windows="{runtime.tools.STM32Tools.path}/win/busybox.exe" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" +recipe.hooks.prebuild.1.pattern="{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{build.project_name}" +recipe.hooks.prebuild.1.pattern.windows="{runtime.tools.STM32Tools.path}/win/busybox.exe" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{build.project_name}" # compile patterns # --------------------- diff --git a/system/extras/prebuild.sh b/system/extras/prebuild.sh index 2b5076a8ae..c19c72b359 100755 --- a/system/extras/prebuild.sh +++ b/system/extras/prebuild.sh @@ -2,6 +2,7 @@ BUILD_PATH="$1" BUILD_SOURCE_PATH="$2" +BUILD_PROJECT_NAME="$3" # Create sketch dir if not exists if [ ! -f "$BUILD_PATH/sketch" ]; then @@ -13,5 +14,10 @@ if [ ! -f "$BUILD_SOURCE_PATH/build_opt.h" ]; then touch "$BUILD_PATH/sketch/build_opt.h" fi +# add build options in source comments +if [ -f "$BUILD_SOURCE_PATH/$BUILD_PROJECT_NAME" ]; then + grep '\/\/ build-opt' "$BUILD_SOURCE_PATH/$BUILD_PROJECT_NAME" | sed -e 's/\/\/ build-opt//' >> "$BUILD_PATH/sketch/build_opt.h" +fi + # Force include of SrcWrapper library echo "#include " >"$BUILD_PATH/sketch/SrcWrapper.cpp"