@@ -44,8 +44,7 @@ function print_size_info()
4444 segments[$seg ]=$size
4545 fi
4646
47-
48- done < <( xtensa-lx106-elf-size --format=sysv $elf_file )
47+ done < <( xtensa-lx106-elf-size --format=sysv $elf_file | sed ' s/\r//g' )
4948
5049 total_ram=$(( ${segments[data]} + ${segments[rodata]} + ${segments[bss]} ))
5150 total_flash=$(( ${segments[data]} + ${segments[rodata]} + ${segments[text]} + ${segments[irom0text]} ))
@@ -66,6 +65,10 @@ function build_sketches()
6665 local lwip=$6
6766 mkdir -p $build_dir
6867 local build_cmd=" python3 tools/build.py -b generic -v -w all -s 4M1M -v -k --build_cache $cache_dir -p $PWD /$build_dir -n $lwip $build_arg "
68+ if [ " $WINDOWS " = " 1" ]; then
69+ # Paths to the arduino builder need to be / referenced, not our native ones
70+ build_cmd=$( echo $build_cmd --ide_path $arduino | sed ' s/ \/c\// \//g' ) # replace '/c/' with '/'
71+ fi
6972 local sketches=$( find $srcpath -name * .ino | sort)
7073 print_size_info > size.log
7174 export ARDUINO_IDE_PATH=$arduino
@@ -107,6 +110,14 @@ function build_sketches()
107110 fi
108111 echo -e " \n ------------ Building $sketch ------------ \n" ;
109112 # $arduino --verify $sketch;
113+ if [ " $WINDOWS " == " 1" ]; then
114+ sketch=$( echo $sketch | sed ' s/^\/c//' )
115+ # MINGW will try to be helpful and silently convert args that look like paths to point to a spot inside the MinGW dir. This breaks everything.
116+ # http://www.mingw.org/wiki/Posix_path_conversion
117+ # https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line#34386471
118+ export MSYS2_ARG_CONV_EXC=" *"
119+ export MSYS_NO_PATHCONV=1
120+ fi
110121 echo " $build_cmd $sketch "
111122 time ($build_cmd $sketch > build.log)
112123 local result=$?
@@ -135,7 +146,7 @@ function install_libraries()
135146 pushd $HOME /Arduino/libraries
136147
137148 # install ArduinoJson library
138- { test -r ArduinoJson-v6.11.0.zip || wget https://github.com/bblanchon/ArduinoJson/releases/download/v6.11.0/ArduinoJson-v6.11.0.zip; } && unzip -q ArduinoJson-v6.11.0.zip
149+ { test -r ArduinoJson-v6.11.0.zip || wget -nv https://github.com/bblanchon/ArduinoJson/releases/download/v6.11.0/ArduinoJson-v6.11.0.zip; } && unzip -q ArduinoJson-v6.11.0.zip
139150
140151 popd
141152}
@@ -145,17 +156,27 @@ function install_ide()
145156 local ide_path=$1
146157 local core_path=$2
147158 local debug=$3
148- if [ " $MACOSX " = " 1" ]; then
159+ if [ " $WINDOWS " = " 1" ]; then
160+ # Acquire needed packages from Windows package manager
161+ choco install --no-progress python3
162+ export PATH=" /c/Python37:$PATH " # Ensure it's live from now on...
163+ cp /c/Python37/python.exe /c/Python37/python3.exe
164+ choco install --no-progress unzip
165+ choco install --no-progress sed
166+ # choco install --no-progress golang
167+ test -r arduino-nightly-windows.zip || wget -nv -O arduino-nightly-windows.zip https://www.arduino.cc/download.php? f=/arduino-nightly-windows.zip
168+ unzip -q arduino-nightly-windows.zip
169+ elif [ " $MACOSX " = " 1" ]; then
149170 # MACOS only has next-to-obsolete Python2 installed. Install Python 3 from python.org
150171 wget https://www.python.org/ftp/python/3.7.4/python-3.7.4-macosx10.9.pkg
151172 sudo installer -pkg python-3.7.4-macosx10.9.pkg -target /
152173 # Install the Python3 certificates, because SSL connections fail w/o them and of course they aren't installed by default.
153- ( cd " /Applications/Python 3.7/" && sudo " ./Install Certificates.command" )
174+ ( cd " /Applications/Python 3.7/" && sudo " ./Install Certificates.command" )
154175 # Hack to place arduino-builder in the same spot as sane OSes
155176 test -r arduino.zip || wget -O arduino.zip https://downloads.arduino.cc/arduino-nightly-macosx.zip
156177 unzip -q arduino.zip
157- mv Arduino.app arduino-nightly
158- mv arduino-nightly/Contents/Java/* arduino-nightly/.
178+ mv Arduino.app arduino-nightly
179+ mv arduino-nightly/Contents/Java/* arduino-nightly/.
159180 else
160181 test -r arduino.tar.xz || wget -O arduino.tar.xz https://www.arduino.cc/download.php? f=/arduino-nightly-linux64.tar.xz
161182 tar xf arduino.tar.xz
@@ -164,7 +185,11 @@ function install_ide()
164185 cd $ide_path /hardware
165186 mkdir esp8266com
166187 cd esp8266com
167- ln -s $core_path esp8266
188+ if [ " $WINDOWS " = " 1" ]; then
189+ cp -a $core_path esp8266
190+ else
191+ ln -s $core_path esp8266
192+ fi
168193 local debug_flags=" "
169194 if [ " $debug " = " debug" ]; then
170195 debug_flags=" -DDEBUG_ESP_PORT=Serial -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM"
@@ -176,8 +201,14 @@ function install_ide()
176201 cat esp8266/platform.local.txt
177202 echo -e " \n----\n"
178203 cd esp8266/tools
179- python3 get.py
180- export PATH=" $ide_path :$core_path /tools/xtensa-lx106-elf/bin:$PATH "
204+ python3 get.py -q
205+ if [ " $WINDOWS " = " 1" ]; then
206+ # Because the symlinks don't work well under Win32, we need to add the path to this copy, not the original...
207+ relbin=$( realpath $PWD /xtensa-lx106-elf/bin)
208+ export PATH=" $ide_path :$relbin :$PATH "
209+ else
210+ export PATH=" $ide_path :$core_path /tools/xtensa-lx106-elf/bin:$PATH "
211+ fi
181212}
182213
183214function install_arduino()
0 commit comments