Skip to content

Commit 9911ef2

Browse files
committed
test
1 parent 081354f commit 9911ef2

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

system/extras/prebuild.sh

+25-8
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,37 @@ if [ ! -f "$BUILD_PATH/sketch" ]; then
99
mkdir -p "$BUILD_PATH/sketch"
1010
fi
1111

12-
# Create empty build.opt if build_opt.h does not exists in the original sketch dir
13-
# Then add or append -fmacro-prefix-map option to change __FILE__ absolute path of
14-
# the board platform folder to a relative path by using '.'.
15-
# (i.e. the folder containing boards.txt)
12+
# Create empty build.opt or clear it if build_opt.h does not exists in the original sketch dir
1613
if [ ! -f "$BUILD_SOURCE_PATH/build_opt.h" ]; then
17-
printf '\n-fmacro-prefix-map="%s"=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" > "$BUILD_PATH/sketch/build.opt"
14+
true >"$BUILD_PATH/sketch/build.opt"
1815
else
1916
# Else copy the build_opt.h as build.opt
2017
# Workaround to the header file preprocessing done by arduino-cli
2118
# See https://github.com/arduino/arduino-cli/issues/1338
22-
cp "$BUILD_SOURCE_PATH/build_opt.h" "$BUILD_PATH/sketch/build.opt"
23-
printf '\n-fmacro-prefix-map="%s"=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" >> "$BUILD_PATH/sketch/build.opt"
19+
cp -f "$BUILD_SOURCE_PATH/build_opt.h" "$BUILD_PATH/sketch/build.opt"
2420
fi
21+
# Then append -fmacro-prefix-map option to change __FILE__ absolute path of
22+
# the board platform folder to a relative path by using '.'.
23+
# (i.e. the folder containing boards.txt)
24+
UNAME_OS="$(uname -s)"
25+
case "${UNAME_OS}" in
26+
Windows*)
27+
i=0
28+
prefix=""
29+
while [ "$i" -le "${#BOARD_PLATFORM_PATH}" ]; do
30+
prefix=${prefix}${BOARD_PLATFORM_PATH:$i:1}
31+
if [ "${BOARD_PLATFORM_PATH:$i:1}" == "\\" ]; then
32+
prefix=${prefix}"\\"
33+
fi
34+
i="$((i + 1))"
35+
done
36+
;;
37+
*)
38+
prefix=${BOARD_PLATFORM_PATH}
39+
;;
40+
esac
2541

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

2744
# Force include of SrcWrapper library
28-
echo "#include <SrcWrapper.h>" > "$BUILD_PATH/sketch/SrcWrapper.cpp"
45+
echo "#include <SrcWrapper.h>" >"$BUILD_PATH/sketch/SrcWrapper.cpp"

0 commit comments

Comments
 (0)