@@ -9,20 +9,37 @@ if [ ! -f "$BUILD_PATH/sketch" ]; then
9
9
mkdir -p " $BUILD_PATH /sketch"
10
10
fi
11
11
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
16
13
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"
18
15
else
19
16
# Else copy the build_opt.h as build.opt
20
17
# Workaround to the header file preprocessing done by arduino-cli
21
18
# 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"
24
20
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
25
41
42
+ printf ' \n-fmacro-prefix-map="%s"=.' " ${prefix} " >> " $BUILD_PATH /sketch/build.opt"
26
43
27
44
# 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