Skip to content

Commit 31e8a27

Browse files
fpistmcparata
authored andcommitted
feat: shorten __FILE__
Append -fmacro-prefix-map option to change __FILE__ absolute path of the board platform folder to a relative path by using '.'. (i.e. the folder containing boards.txt) Signed-off-by: Frederic Pillon <[email protected]>
1 parent 58eea69 commit 31e8a27

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

platform.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ build.opt.path={build.path}/sketch/{build.opt.name}
120120

121121
extras.path={build.system.path}/extras
122122

123-
# Create empty {build.opt} if not exists in the output sketch dir and force include of SrcWrapper library
124-
recipe.hooks.prebuild.1.pattern="{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}"
125-
recipe.hooks.prebuild.1.pattern.windows="{runtime.tools.STM32Tools.path}/win/busybox.exe" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}"
123+
# Create {build.opt} if not exists in the output sketch dir and force include of SrcWrapper library
124+
recipe.hooks.prebuild.1.pattern="{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}"
125+
recipe.hooks.prebuild.1.pattern.windows="{runtime.tools.STM32Tools.path}/win/busybox.exe" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}"
126126

127127
# compile patterns
128128
# ---------------------

system/extras/prebuild.sh

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
BUILD_PATH="$1"
44
BUILD_SOURCE_PATH="$2"
5+
BOARD_PLATFORM_PATH="$3"
56

67
# Create sketch dir if not exists
78
if [ ! -f "$BUILD_PATH/sketch" ]; then
@@ -18,5 +19,10 @@ else
1819
cp "$BUILD_SOURCE_PATH/build_opt.h" "$BUILD_PATH/sketch/build.opt"
1920
fi
2021

22+
# Append -fmacro-prefix-map option to change __FILE__ absolute path of the board
23+
# platform folder to a relative path by using '.'.
24+
# (i.e. the folder containing boards.txt)
25+
printf '\n-fmacro-prefix-map=%s=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" > "$BUILD_PATH/sketch/build.opt"
26+
2127
# Force include of SrcWrapper library
2228
echo "#include <SrcWrapper.h>" > "$BUILD_PATH/sketch/SrcWrapper.cpp"

0 commit comments

Comments
 (0)