Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
fpistm committed Mar 26, 2024
1 parent 081354f commit 9911ef2
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions system/extras/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,37 @@ if [ ! -f "$BUILD_PATH/sketch" ]; then
mkdir -p "$BUILD_PATH/sketch"
fi

# Create empty build.opt if build_opt.h does not exists in the original sketch dir
# Then add or 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)
# Create empty build.opt or clear it if build_opt.h does not exists in the original sketch dir
if [ ! -f "$BUILD_SOURCE_PATH/build_opt.h" ]; then
printf '\n-fmacro-prefix-map="%s"=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" > "$BUILD_PATH/sketch/build.opt"
true >"$BUILD_PATH/sketch/build.opt"
else
# Else copy the build_opt.h as build.opt
# Workaround to the header file preprocessing done by arduino-cli
# See https://github.com/arduino/arduino-cli/issues/1338
cp "$BUILD_SOURCE_PATH/build_opt.h" "$BUILD_PATH/sketch/build.opt"
printf '\n-fmacro-prefix-map="%s"=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" >> "$BUILD_PATH/sketch/build.opt"
cp -f "$BUILD_SOURCE_PATH/build_opt.h" "$BUILD_PATH/sketch/build.opt"
fi
# Then 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)
UNAME_OS="$(uname -s)"
case "${UNAME_OS}" in
Windows*)
i=0
prefix=""
while [ "$i" -le "${#BOARD_PLATFORM_PATH}" ]; do
prefix=${prefix}${BOARD_PLATFORM_PATH:$i:1}
if [ "${BOARD_PLATFORM_PATH:$i:1}" == "\\" ]; then
prefix=${prefix}"\\"
fi
i="$((i + 1))"
done
;;
*)
prefix=${BOARD_PLATFORM_PATH}
;;
esac

printf '\n-fmacro-prefix-map="%s"=.' "${prefix}" >>"$BUILD_PATH/sketch/build.opt"

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

0 comments on commit 9911ef2

Please sign in to comment.