Skip to content

Commit cf97079

Browse files
Add Win32 build to CI system
Build a single INO under a Windows VM on Travis to ensure that the Win32 toolchain works properly.
1 parent 5ca0bde commit cf97079

File tree

5 files changed

+59
-12
lines changed

5 files changed

+59
-12
lines changed

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ jobs:
2929
include:
3030
# Build stage. To save time, run all kinds of builds and tests in parallel.
3131

32+
- name: "Windows can build sketches"
33+
os: windows
34+
stage: build
35+
script: $TRAVIS_BUILD_DIR/tests/build.sh
36+
env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1
37+
3238
- name: "Platformio (1)"
3339
stage: build
3440
script: $TRAVIS_BUILD_DIR/tests/platformio.sh

tests/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
2+
set -x
33
cache_dir=$(mktemp -d)
44

55
source "$TRAVIS_BUILD_DIR"/tests/common.sh

tests/common.sh

+32-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
2+
set -x
33
# return 1 if this test should not be built in CI (for other archs, not needed, etc.)
44
function skip_ino()
55
{
@@ -64,11 +64,18 @@ function build_sketches()
6464
local build_mod=$4
6565
local build_rem=$5
6666
local lwip=$6
67+
export ARDUINO_IDE_PATH=$arduino
6768
mkdir -p $build_dir
6869
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 "
70+
if [ "$WINDOWS" = "1" ]; then
71+
# Paths to the arduino builder need to be c:\ referenced, not our native ones
72+
local pwd_win=$(realpath $PWD | sed 's/\/c/C:/')
73+
local bar_win=$(echo $build_arg | sed 's/\/c\//C:\//g')
74+
export ARDUINO_IDE_PATH=$(realpath $arduino | sed 's/\/c/C:/')
75+
build_cmd="python3 tools/build.py -b generic -v -w all -s 4M1M -v -k -p $pwd_win/$build_dir -n $lwip $bar_win "
76+
fi
6977
local sketches=$(find $srcpath -name *.ino | sort)
7078
print_size_info >size.log
71-
export ARDUINO_IDE_PATH=$arduino
7279
local testcnt=0
7380
for sketch in $sketches; do
7481
testcnt=$(( ($testcnt + 1) % $build_mod ))
@@ -107,6 +114,9 @@ function build_sketches()
107114
fi
108115
echo -e "\n ------------ Building $sketch ------------ \n";
109116
# $arduino --verify $sketch;
117+
if [ "$WINDOWS" == "1" ]; then
118+
sketch=$(echo $sketch | sed 's/\/c/C:/')
119+
fi
110120
echo "$build_cmd $sketch"
111121
time ($build_cmd $sketch >build.log)
112122
local result=$?
@@ -135,7 +145,7 @@ function install_libraries()
135145
pushd $HOME/Arduino/libraries
136146

137147
# 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 ArduinoJson-v6.11.0.zip
148+
{ 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
139149

140150
popd
141151
}
@@ -145,13 +155,28 @@ function install_ide()
145155
local ide_path=$1
146156
local core_path=$2
147157
local debug=$3
148-
test -r arduino.tar.xz || wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
149-
tar xf arduino.tar.xz
158+
if [ "$WINDOWS" = "1" ]; then
159+
# Acquire needed packages from Windows package manager
160+
choco install --no-progress python3
161+
export PATH="/c/Python37:$PATH" # Ensure it's live from now on...
162+
cp /c/Python37/python.exe /c/Python37/python3.exe
163+
choco install --no-progress unzip
164+
choco install --no-progress sed
165+
test -r arduino-nightly-windows.zip || wget -nv -O arduino-nightly-windows.zip https://www.arduino.cc/download.php?f=/arduino-nightly-windows.zip
166+
unzip -q arduino-nightly-windows.zip
167+
else
168+
test -r arduino.tar.xz || wget -nv -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
169+
tar xf arduino.tar.xz
170+
fi
150171
mv arduino-nightly $ide_path
151172
cd $ide_path/hardware
152173
mkdir esp8266com
153174
cd esp8266com
154-
ln -s $core_path esp8266
175+
if [ "$WINDOWS" = "1" ]; then
176+
cp -a $core_path esp8266
177+
else
178+
ln -s $core_path esp8266
179+
fi
155180
local debug_flags=""
156181
if [ "$debug" = "debug" ]; then
157182
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"
@@ -163,7 +188,7 @@ function install_ide()
163188
cat esp8266/platform.local.txt
164189
echo -e "\n----\n"
165190
cd esp8266/tools
166-
python3 get.py
191+
python3 get.py -q
167192
export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH"
168193
}
169194

tools/build.py

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import sys
2525
import os
2626
import argparse
27+
import platform
2728
import subprocess
2829
import tempfile
2930
import shutil
@@ -63,6 +64,10 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args):
6364
cmd += '-verbose '
6465
cmd += sketch
6566

67+
# Normalize slashes on Windows
68+
if platform.system() == "Windows":
69+
cmd = cmd.replace('/', '\\')
70+
6671
if args.verbose:
6772
print('Building: ' + cmd, file=f)
6873

@@ -127,6 +132,7 @@ def main():
127132
hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores'
128133

129134
output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin'
135+
130136
if args.verbose:
131137
print("Sketch: ", sketch_path)
132138
print("Build dir: ", tmp_dir)

tools/get.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import tarfile
1616
import zipfile
1717
import re
18+
19+
verbose = True
20+
1821
if sys.version_info[0] == 3:
1922
from urllib.request import urlretrieve
2023
else:
@@ -38,10 +41,12 @@ def mkdir_p(path):
3841
raise
3942

4043
def report_progress(count, blockSize, totalSize):
41-
percent = int(count*blockSize*100/totalSize)
42-
percent = min(100, percent)
43-
sys.stdout.write("\r%d%%" % percent)
44-
sys.stdout.flush()
44+
global verbose
45+
if verbose:
46+
percent = int(count*blockSize*100/totalSize)
47+
percent = min(100, percent)
48+
sys.stdout.write("\r%d%%" % percent)
49+
sys.stdout.flush()
4550

4651
def unpack(filename, destination):
4752
dirname = ''
@@ -111,6 +116,11 @@ def identify_platform():
111116
return arduino_platform_names[sys_name][bits]
112117

113118
def main():
119+
global verbose
120+
# Support optional "-q" quiet mode simply
121+
if len(sys.argv) == 2:
122+
if sys.argv[1] == "-q":
123+
verbose = False
114124
print('Platform: {0}'.format(identify_platform()))
115125
tools_to_download = load_tools_list('../package/package_esp8266com_index.template.json', identify_platform())
116126
mkdir_p(dist_dir)

0 commit comments

Comments
 (0)