Skip to content

Commit

Permalink
feat: shorten __FILE__
Browse files Browse the repository at this point in the history
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 <frederic.pillon@st.com>
  • Loading branch information
fpistm committed Jun 16, 2022
1 parent 4f85088 commit 6a167f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ 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}"
# Create {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}" "{runtime.platform.path}"
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}"

# compile patterns
# ---------------------
Expand Down
6 changes: 6 additions & 0 deletions system/extras/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

BUILD_PATH="$1"
BUILD_SOURCE_PATH="$2"
BOARD_PLATFORM_PATH="$3"

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

# 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)
printf '\n-fmacro-prefix-map=%s=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" > "$BUILD_PATH/sketch/build.opt"

# Force include of SrcWrapper library
echo "#include <SrcWrapper.h>" > "$BUILD_PATH/sketch/SrcWrapper.cpp"

0 comments on commit 6a167f8

Please sign in to comment.