From cf970796e90611161ff35cbdfc06c48efcf7ab43 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sat, 7 Sep 2019 11:58:17 -0700 Subject: [PATCH 1/9] Add Win32 build to CI system Build a single INO under a Windows VM on Travis to ensure that the Win32 toolchain works properly. --- .travis.yml | 6 ++++++ tests/build.sh | 2 +- tests/common.sh | 39 ++++++++++++++++++++++++++++++++------- tools/build.py | 6 ++++++ tools/get.py | 18 ++++++++++++++---- 5 files changed, 59 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36bab4ecf1..ac34c403aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,12 @@ jobs: include: # Build stage. To save time, run all kinds of builds and tests in parallel. + - name: "Windows can build sketches" + os: windows + stage: build + script: $TRAVIS_BUILD_DIR/tests/build.sh + env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1 + - name: "Platformio (1)" stage: build script: $TRAVIS_BUILD_DIR/tests/platformio.sh diff --git a/tests/build.sh b/tests/build.sh index 45f88e7ef2..e04b02c1a0 100755 --- a/tests/build.sh +++ b/tests/build.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash - +set -x cache_dir=$(mktemp -d) source "$TRAVIS_BUILD_DIR"/tests/common.sh diff --git a/tests/common.sh b/tests/common.sh index ca99bee7ab..f9f4c1586f 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash - +set -x # return 1 if this test should not be built in CI (for other archs, not needed, etc.) function skip_ino() { @@ -64,11 +64,18 @@ function build_sketches() local build_mod=$4 local build_rem=$5 local lwip=$6 + export ARDUINO_IDE_PATH=$arduino mkdir -p $build_dir 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 " + if [ "$WINDOWS" = "1" ]; then + # Paths to the arduino builder need to be c:\ referenced, not our native ones + local pwd_win=$(realpath $PWD | sed 's/\/c/C:/') + local bar_win=$(echo $build_arg | sed 's/\/c\//C:\//g') + export ARDUINO_IDE_PATH=$(realpath $arduino | sed 's/\/c/C:/') + build_cmd="python3 tools/build.py -b generic -v -w all -s 4M1M -v -k -p $pwd_win/$build_dir -n $lwip $bar_win " + fi local sketches=$(find $srcpath -name *.ino | sort) print_size_info >size.log - export ARDUINO_IDE_PATH=$arduino local testcnt=0 for sketch in $sketches; do testcnt=$(( ($testcnt + 1) % $build_mod )) @@ -107,6 +114,9 @@ function build_sketches() fi echo -e "\n ------------ Building $sketch ------------ \n"; # $arduino --verify $sketch; + if [ "$WINDOWS" == "1" ]; then + sketch=$(echo $sketch | sed 's/\/c/C:/') + fi echo "$build_cmd $sketch" time ($build_cmd $sketch >build.log) local result=$? @@ -135,7 +145,7 @@ function install_libraries() pushd $HOME/Arduino/libraries # install ArduinoJson library - { 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 + { 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 popd } @@ -145,13 +155,28 @@ function install_ide() local ide_path=$1 local core_path=$2 local debug=$3 - test -r arduino.tar.xz || wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz - tar xf arduino.tar.xz + if [ "$WINDOWS" = "1" ]; then + # Acquire needed packages from Windows package manager + choco install --no-progress python3 + export PATH="/c/Python37:$PATH" # Ensure it's live from now on... + cp /c/Python37/python.exe /c/Python37/python3.exe + choco install --no-progress unzip + choco install --no-progress sed + test -r arduino-nightly-windows.zip || wget -nv -O arduino-nightly-windows.zip https://www.arduino.cc/download.php?f=/arduino-nightly-windows.zip + unzip -q arduino-nightly-windows.zip + else + test -r arduino.tar.xz || wget -nv -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz + tar xf arduino.tar.xz + fi mv arduino-nightly $ide_path cd $ide_path/hardware mkdir esp8266com cd esp8266com - ln -s $core_path esp8266 + if [ "$WINDOWS" = "1" ]; then + cp -a $core_path esp8266 + else + ln -s $core_path esp8266 + fi local debug_flags="" if [ "$debug" = "debug" ]; then 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() cat esp8266/platform.local.txt echo -e "\n----\n" cd esp8266/tools - python3 get.py + python3 get.py -q export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH" } diff --git a/tools/build.py b/tools/build.py index 8859bbdfce..4225547f63 100755 --- a/tools/build.py +++ b/tools/build.py @@ -24,6 +24,7 @@ import sys import os import argparse +import platform import subprocess import tempfile import shutil @@ -63,6 +64,10 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): cmd += '-verbose ' cmd += sketch + # Normalize slashes on Windows + if platform.system() == "Windows": + cmd = cmd.replace('/', '\\') + if args.verbose: print('Building: ' + cmd, file=f) @@ -127,6 +132,7 @@ def main(): hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores' output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin' + if args.verbose: print("Sketch: ", sketch_path) print("Build dir: ", tmp_dir) diff --git a/tools/get.py b/tools/get.py index 9a85ae84b4..74b6b510d9 100755 --- a/tools/get.py +++ b/tools/get.py @@ -15,6 +15,9 @@ import tarfile import zipfile import re + +verbose = True + if sys.version_info[0] == 3: from urllib.request import urlretrieve else: @@ -38,10 +41,12 @@ def mkdir_p(path): raise def report_progress(count, blockSize, totalSize): - percent = int(count*blockSize*100/totalSize) - percent = min(100, percent) - sys.stdout.write("\r%d%%" % percent) - sys.stdout.flush() + global verbose + if verbose: + percent = int(count*blockSize*100/totalSize) + percent = min(100, percent) + sys.stdout.write("\r%d%%" % percent) + sys.stdout.flush() def unpack(filename, destination): dirname = '' @@ -111,6 +116,11 @@ def identify_platform(): return arduino_platform_names[sys_name][bits] def main(): + global verbose + # Support optional "-q" quiet mode simply + if len(sys.argv) == 2: + if sys.argv[1] == "-q": + verbose = False print('Platform: {0}'.format(identify_platform())) tools_to_download = load_tools_list('../package/package_esp8266com_index.template.json', identify_platform()) mkdir_p(dist_dir) From 34429db7fbcdd7282ebf74baf9251edb12cd3dfb Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 9 Sep 2019 10:50:12 -0700 Subject: [PATCH 2/9] Fix merge issue --- tests/common.sh | 8 -------- tools/build.py | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index 9266ab22e9..d672018223 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -74,7 +74,6 @@ function build_sketches() # Make ARDUINO_IDE_PATH to Windows slashies export ARDUINO_IDE_PATH=$(realpath $arduino | sed 's/\/c/C:/' | tr / '\\' ) build_cmd="python3 tools/build.py -b generic -v -w all -s 4M1M -v -k -p $pwd_win/$build_dir -n $lwip $bar_win " - build_cmd=$(echo $build_cmd | tr '"' ' ') # Remove quotes to see if Win Go works better fi local sketches=$(find $srcpath -name *.ino | sort) print_size_info >size.log @@ -161,17 +160,10 @@ function install_ide() # Acquire needed packages from Windows package manager choco install --no-progress python3 export PATH="/c/Python37:$PATH" # Ensure it's live from now on... -<<<<<<< HEAD cp /c/Python37/python.exe /c/Python37/python3.exe choco install --no-progress unzip choco install --no-progress sed #choco install --no-progress golang -======= - cp /c/Python37/python.exe /c/Python37/python3.exe - choco install --no-progress unzip - choco install --no-progress sed - choco install --no-progress golang ->>>>>>> edfc77b0c247efe7afa70461ff9c32fda27c3274 test -r arduino-nightly-windows.zip || wget -nv -O arduino-nightly-windows.zip https://www.arduino.cc/download.php?f=/arduino-nightly-windows.zip unzip -q arduino-nightly-windows.zip elif [ "$MACOSX" = "1" ]; then diff --git a/tools/build.py b/tools/build.py index 9dd9705796..02af4419fc 100755 --- a/tools/build.py +++ b/tools/build.py @@ -64,9 +64,9 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): cmd += '-verbose ' cmd += sketch - # Normalize slashes on Windows + # Try removing quotes to make arduino-cli sork if platform.system() == "Windows": - cmd = cmd.replace('/', '\\').replace('"', '') + cmd = cmd.replace('/', '\\') if args.verbose: print('Building: ' + cmd, file=f) From 908537e602faf5b8091e3bc91d0952beb2510316 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 10 Sep 2019 08:08:05 -0700 Subject: [PATCH 3/9] Use fwd slashes and drop quotes in paths --- tests/common.sh | 6 +++--- tools/build.py | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index d672018223..f04823d9b4 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -68,9 +68,9 @@ function build_sketches() mkdir -p $build_dir 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 " if [ "$WINDOWS" = "1" ]; then - # Paths to the arduino builder need to be c:\ referenced, not our native ones - local pwd_win=$(realpath $PWD | sed 's/\/c/C:/') - local bar_win=$(echo $build_arg | sed 's/\/c\//C:\//g') + # Paths to the arduino builder need to be / referenced, not our native ones + local pwd_win=$(realpath $PWD | sed 's/^\/c//') + local bar_win=$(echo $build_arg | sed 's/^\/c\//') # Make ARDUINO_IDE_PATH to Windows slashies export ARDUINO_IDE_PATH=$(realpath $arduino | sed 's/\/c/C:/' | tr / '\\' ) build_cmd="python3 tools/build.py -b generic -v -w all -s 4M1M -v -k -p $pwd_win/$build_dir -n $lwip $bar_win " diff --git a/tools/build.py b/tools/build.py index 02af4419fc..9b63abfdec 100755 --- a/tools/build.py +++ b/tools/build.py @@ -32,19 +32,19 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): cmd = ide_path + '/arduino-builder ' cmd += '-compile -logger=human ' - cmd += '-build-path "' + tmp_dir + '" ' - cmd += '-tools "' + ide_path + '/tools-builder" ' + cmd += '-build-path ' + tmp_dir + ' ' + cmd += '-tools ' + ide_path + '/tools-builder ' if cache != "": - cmd += '-build-cache "' + cache + '" ' + cmd += '-build-cache ' + cache + ' ' if args.library_path: for lib_dir in args.library_path: - cmd += '-libraries "' + lib_dir + '" ' - cmd += '-hardware "' + ide_path + '/hardware" ' + cmd += '-libraries ' + lib_dir + ' ' + cmd += '-hardware ' + ide_path + '/hardware ' if args.hardware_dir: for hw_dir in args.hardware_dir: - cmd += '-hardware "' + hw_dir + '" ' + cmd += '-hardware ' + hw_dir + ' ' else: - cmd += '-hardware "' + hardware_dir + '" ' + cmd += '-hardware ' + hardware_dir + ' ' # Debug=Serial,DebugLevel=Core____ cmd += '-fqbn=esp8266com:esp8266:{board_name}:' \ 'xtal={cpu_freq},' \ @@ -57,16 +57,16 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): if args.debug_port and args.debug_level: cmd += 'dbg={debug_port},lvl={debug_level}'.format(**vars(args)) cmd += ' ' - cmd += '-built-in-libraries "' + ide_path + '/libraries" ' + cmd += '-built-in-libraries ' + ide_path + '/libraries ' cmd += '-ide-version=10607 ' cmd += '-warnings={warnings} '.format(**vars(args)) if args.verbose: cmd += '-verbose ' cmd += sketch - # Try removing quotes to make arduino-cli sork - if platform.system() == "Windows": - cmd = cmd.replace('/', '\\') + # Try removing quotes to make arduino-cli work + #if platform.system() == "Windows": + # cmd = cmd.replace('/', '\\') if args.verbose: print('Building: ' + cmd, file=f) From bce91f34b7c769578409395afd33453487e7cc8b Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 10 Sep 2019 08:21:02 -0700 Subject: [PATCH 4/9] Use real python list to make arduino-builder command line Instead of making a string with spaces and then splitting on " ", just make the list itself with individual parameters. This will allow spaces in paths to be supported properly. --- tests/common.sh | 13 +++++++------ tools/build.py | 50 +++++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index f04823d9b4..9436593aff 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -69,11 +69,7 @@ function build_sketches() 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 " if [ "$WINDOWS" = "1" ]; then # Paths to the arduino builder need to be / referenced, not our native ones - local pwd_win=$(realpath $PWD | sed 's/^\/c//') - local bar_win=$(echo $build_arg | sed 's/^\/c\//') - # Make ARDUINO_IDE_PATH to Windows slashies - export ARDUINO_IDE_PATH=$(realpath $arduino | sed 's/\/c/C:/' | tr / '\\' ) - build_cmd="python3 tools/build.py -b generic -v -w all -s 4M1M -v -k -p $pwd_win/$build_dir -n $lwip $bar_win " + build_cmd=$(echo $build_cmd --ide_path $arduino | sed 's/ \/c\// \//g' ) # replace '/c/' with '/' fi local sketches=$(find $srcpath -name *.ino | sort) print_size_info >size.log @@ -116,7 +112,12 @@ function build_sketches() echo -e "\n ------------ Building $sketch ------------ \n"; # $arduino --verify $sketch; if [ "$WINDOWS" == "1" ]; then - sketch=$(echo $sketch | sed 's/\/c/C:/') + sketch=$(echo $sketch | sed 's/^\/c//') + # 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. + # http://www.mingw.org/wiki/Posix_path_conversion + # https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line#34386471 + export MSYS2_ARG_CONV_EXC="*" + export MSYS_NO_PATHCONV=1 fi echo "$build_cmd $sketch" time ($build_cmd $sketch >build.log) diff --git a/tools/build.py b/tools/build.py index 9b63abfdec..f48b1fcda7 100755 --- a/tools/build.py +++ b/tools/build.py @@ -30,23 +30,24 @@ import shutil def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): - cmd = ide_path + '/arduino-builder ' - cmd += '-compile -logger=human ' - cmd += '-build-path ' + tmp_dir + ' ' - cmd += '-tools ' + ide_path + '/tools-builder ' + cmd = [] + cmd += [ide_path + '/arduino-builder'] + cmd += ['-compile', '-logger=human'] + cmd += ['-build-path', tmp_dir] + cmd += ['-tools', ide_path + '/tools-builder'] if cache != "": - cmd += '-build-cache ' + cache + ' ' + cmd += ['-build-cache', cache ] if args.library_path: for lib_dir in args.library_path: - cmd += '-libraries ' + lib_dir + ' ' - cmd += '-hardware ' + ide_path + '/hardware ' + cmd += ['-libraries', lib_dir] + cmd += ['-hardware', ide_path + '/hardware'] if args.hardware_dir: for hw_dir in args.hardware_dir: - cmd += '-hardware ' + hw_dir + ' ' + cmd += ['-hardware', hw_dir] else: - cmd += '-hardware ' + hardware_dir + ' ' + cmd += ['-hardware', hardware_dir] # Debug=Serial,DebugLevel=Core____ - cmd += '-fqbn=esp8266com:esp8266:{board_name}:' \ + fqbn = '-fqbn=esp8266com:esp8266:{board_name}:' \ 'xtal={cpu_freq},' \ 'FlashFreq={flash_freq},' \ 'FlashMode={flash_mode},' \ @@ -55,24 +56,19 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): 'ip={lwIP},' \ 'ResetMethod=nodemcu'.format(**vars(args)) if args.debug_port and args.debug_level: - cmd += 'dbg={debug_port},lvl={debug_level}'.format(**vars(args)) - cmd += ' ' - cmd += '-built-in-libraries ' + ide_path + '/libraries ' - cmd += '-ide-version=10607 ' - cmd += '-warnings={warnings} '.format(**vars(args)) + fqbn += 'dbg={debug_port},lvl={debug_level}'.format(**vars(args)) + cmd += [fqbn] + cmd += ['-built-in-libraries', ide_path + '/libraries'] + cmd += ['-ide-version=10607'] + cmd += ['-warnings={warnings}'.format(**vars(args))] if args.verbose: - cmd += '-verbose ' - cmd += sketch - - # Try removing quotes to make arduino-cli work - #if platform.system() == "Windows": - # cmd = cmd.replace('/', '\\') + cmd += ['-verbose'] + cmd += [sketch] if args.verbose: - print('Building: ' + cmd, file=f) + print('Building: ' + " ".join(cmd), file=f) - cmds = cmd.split(' ') - p = subprocess.Popen(cmds, stdout=f, stderr=subprocess.STDOUT) + p = subprocess.Popen(cmd, stdout=f, stderr=subprocess.STDOUT) p.wait() return p.returncode @@ -113,6 +109,10 @@ def main(): args = parse_args() ide_path = args.ide_path + try: + print("IDE dir1: ", ide_path) + except: + pass if not ide_path: ide_path = os.environ.get('ARDUINO_IDE_PATH') if not ide_path: @@ -120,6 +120,7 @@ def main(): "or ARDUINO_IDE_PATH environment variable.", file=sys.stderr) return 2 + print("IDE dir2: ", ide_path) sketch_path = args.sketch_path tmp_dir = args.build_path created_tmp_dir = False @@ -134,6 +135,7 @@ def main(): output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin' if args.verbose: + print("IDE dir: ", ide_path) print("Sketch: ", sketch_path) print("Build dir: ", tmp_dir) print("Cache dir: ", args.build_cache) From 378fc980db4340b0f3b782d06be246be238a8308 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 10 Sep 2019 10:39:24 -0700 Subject: [PATCH 5/9] Try and fix Windows HW and TOOLS paths --- tools/build.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/build.py b/tools/build.py index f48b1fcda7..0bec6f3f14 100755 --- a/tools/build.py +++ b/tools/build.py @@ -109,10 +109,6 @@ def main(): args = parse_args() ide_path = args.ide_path - try: - print("IDE dir1: ", ide_path) - except: - pass if not ide_path: ide_path = os.environ.get('ARDUINO_IDE_PATH') if not ide_path: @@ -120,7 +116,6 @@ def main(): "or ARDUINO_IDE_PATH environment variable.", file=sys.stderr) return 2 - print("IDE dir2: ", ide_path) sketch_path = args.sketch_path tmp_dir = args.build_path created_tmp_dir = False @@ -128,14 +123,17 @@ def main(): tmp_dir = tempfile.mkdtemp() created_tmp_dir = True - tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools' - # this is not the correct hardware folder to add. - hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores' + if platform.system() == "Windows": + tools_dir = os.path.dirname(os.path.realpath(__file__)) + '\\..\\tools' + hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '\\..\\cores' + else: + tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools' + # this is not the correct hardware folder to add. + hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores' output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin' if args.verbose: - print("IDE dir: ", ide_path) print("Sketch: ", sketch_path) print("Build dir: ", tmp_dir) print("Cache dir: ", args.build_cache) From 9d2eb10e020b92749567250f8ace13717981d8ef Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 10 Sep 2019 12:27:12 -0700 Subject: [PATCH 6/9] Try and Windows-ize paths in build.py --- tools/build.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/build.py b/tools/build.py index 0bec6f3f14..de64de3e4a 100755 --- a/tools/build.py +++ b/tools/build.py @@ -29,6 +29,15 @@ import tempfile import shutil + +def windowsize_paths(l): + out = [] + for i in l: + if i.startswith('/'): + i = 'C:' + i + out += [i.replace('/', '\\')] + return out + def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): cmd = [] cmd += [ide_path + '/arduino-builder'] @@ -65,6 +74,9 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): cmd += ['-verbose'] cmd += [sketch] + if platform.system() == "Windows": + cmd = windowsize_paths(cmd) + if args.verbose: print('Building: ' + " ".join(cmd), file=f) From d4b3b61f1f4e4c75a5c4759a1c87de3170c1511f Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 10 Sep 2019 12:46:38 -0700 Subject: [PATCH 7/9] Fix size reporting on Windows --- tests/common.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index 9436593aff..71678e42f9 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -32,8 +32,10 @@ function print_size_info() fi elf_name=$(basename $elf_file) + ls -l $elf_name sketch_name="${elf_name%.*}" # echo $sketch_name + echo $PATH declare -A segments while read -a tokens; do seg=${tokens[0]} @@ -44,7 +46,6 @@ function print_size_info() segments[$seg]=$size fi - done < <(xtensa-lx106-elf-size --format=sysv $elf_file) total_ram=$((${segments[data]} + ${segments[rodata]} + ${segments[bss]})) @@ -203,7 +204,13 @@ function install_ide() echo -e "\n----\n" cd esp8266/tools python3 get.py -q - export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH" + if [ "$WINDOWS" = "1" ]; then + # Because the symlinks don't work well under Win32, we need to add the path to this copy, not the original... + relbin=$(realpath $PWD/xtensa-lx106-elf/bin) + export PATH="$ide_path:$relbin:$PATH" + else + export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH" + fi } function install_arduino() From 67ecfd972770905d59a23c2b064a321ad693f9cb Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 10 Sep 2019 13:42:00 -0700 Subject: [PATCH 8/9] Fix endline output for size command --- tests/common.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index 71678e42f9..7592407626 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -32,10 +32,9 @@ function print_size_info() fi elf_name=$(basename $elf_file) - ls -l $elf_name sketch_name="${elf_name%.*}" # echo $sketch_name - echo $PATH + declare -A segments while read -a tokens; do seg=${tokens[0]} @@ -46,7 +45,7 @@ function print_size_info() segments[$seg]=$size fi - done < <(xtensa-lx106-elf-size --format=sysv $elf_file) + done < <(xtensa-lx106-elf-size --format=sysv $elf_file | sed 's/\r//g' ) total_ram=$((${segments[data]} + ${segments[rodata]} + ${segments[bss]})) total_flash=$((${segments[data]} + ${segments[rodata]} + ${segments[text]} + ${segments[irom0text]})) From d7873e594d2b14ea8ac0e46e16a03f1dfe346e39 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 10 Sep 2019 14:02:57 -0700 Subject: [PATCH 9/9] Minimize differences and remove debug messages --- .travis.yml | 14 +++++++------- tests/build.sh | 2 +- tests/common.sh | 5 ++--- tools/build.py | 13 ++++++------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index c30cf73807..e6a2b4012c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,12 +29,6 @@ jobs: include: # Build stage. To save time, run all kinds of builds and tests in parallel. - - name: "Windows can build sketches" - os: windows - stage: build - script: $TRAVIS_BUILD_DIR/tests/build.sh - env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1 - - name: "Platformio (1)" stage: build script: $TRAVIS_BUILD_DIR/tests/platformio.sh @@ -113,12 +107,18 @@ jobs: script: $TRAVIS_BUILD_DIR/tests/buildm.sh env: CC=gcc-7 CXX=g++-7 - - name: "MacOS can build sketches" + - name: "Mac OSX can build sketches" os: osx stage: build script: $TRAVIS_BUILD_DIR/tests/build.sh env: MACOSX=1 BUILD_PARITY=custom mod=500 rem=1 + - name: "Windows can build sketches" + os: windows + stage: build + script: $TRAVIS_BUILD_DIR/tests/build.sh + env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1 + - name: "Boards" stage: build script: $TRAVIS_BUILD_DIR/tests/ci/build_boards.sh diff --git a/tests/build.sh b/tests/build.sh index e04b02c1a0..45f88e7ef2 100755 --- a/tests/build.sh +++ b/tests/build.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -x + cache_dir=$(mktemp -d) source "$TRAVIS_BUILD_DIR"/tests/common.sh diff --git a/tests/common.sh b/tests/common.sh index 7592407626..b93bd57ba9 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -x + # return 1 if this test should not be built in CI (for other archs, not needed, etc.) function skip_ino() { @@ -34,7 +34,6 @@ function print_size_info() elf_name=$(basename $elf_file) sketch_name="${elf_name%.*}" # echo $sketch_name - declare -A segments while read -a tokens; do seg=${tokens[0]} @@ -64,7 +63,6 @@ function build_sketches() local build_mod=$4 local build_rem=$5 local lwip=$6 - export ARDUINO_IDE_PATH=$arduino mkdir -p $build_dir 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 " if [ "$WINDOWS" = "1" ]; then @@ -73,6 +71,7 @@ function build_sketches() fi local sketches=$(find $srcpath -name *.ino | sort) print_size_info >size.log + export ARDUINO_IDE_PATH=$arduino local testcnt=0 for sketch in $sketches; do testcnt=$(( ($testcnt + 1) % $build_mod )) diff --git a/tools/build.py b/tools/build.py index de64de3e4a..efb1409ba7 100755 --- a/tools/build.py +++ b/tools/build.py @@ -30,7 +30,10 @@ import shutil +# Arduino-builder needs forward-slash paths for passed in params or it cannot +# launch the needed toolset. def windowsize_paths(l): + """Convert forward-slash paths to backslash paths referenced from C:""" out = [] for i in l: if i.startswith('/'): @@ -135,13 +138,9 @@ def main(): tmp_dir = tempfile.mkdtemp() created_tmp_dir = True - if platform.system() == "Windows": - tools_dir = os.path.dirname(os.path.realpath(__file__)) + '\\..\\tools' - hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '\\..\\cores' - else: - tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools' - # this is not the correct hardware folder to add. - hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores' + tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools' + # this is not the correct hardware folder to add. + hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores' output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin'