diff --git a/.gitignore b/.gitignore index 722d5e7..a0f0e53 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode +.DS_Store diff --git a/.travis.yml b/.travis.yml index 48d0747..762f4db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,46 +1,17 @@ sudo: false -language: bash + +language: python +python: + - "2.7" + os: - linux dist: - xenial -addons: - apt: - packages: - - xvfb - -# services: -# - xvfb - - script: - - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16 -# - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -screen 0 1400x900x24 -ac +extension GLX +render; - - export DISPLAY=:1.0 - - sleep 3 - - ls -l /tmp/*pid - - - wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz - - tar xf arduino-1.6.5-linux64.tar.xz - - mv arduino-1.6.5 $HOME/arduino_ide - - export PATH="$HOME/arduino_ide:$PATH" - - which arduino - - mkdir -p $HOME/Arduino/libraries - - cp -r $TRAVIS_BUILD_DIR $HOME/Arduino/libraries/ESPAsyncWebServer - - git clone https://github.com/bblanchon/ArduinoJson $HOME/Arduino/libraries/ArduinoJson - - git clone https://github.com/me-no-dev/ESPAsyncTCP $HOME/Arduino/libraries/ESPAsyncTCP - - cd $HOME/arduino_ide/hardware - - mkdir esp8266com - - cd esp8266com - - git clone https://github.com/esp8266/Arduino.git esp8266 - - cd esp8266/tools - - python get.py - - source $TRAVIS_BUILD_DIR/travis/common.sh - - arduino --board esp8266com:esp8266:generic --save-prefs - - arduino --get-pref sketchbook.path - - build_sketches arduino $HOME/Arduino/libraries/ESPAsyncWebServer esp8266 + - bash $TRAVIS_BUILD_DIR/travis/build.sh notifications: email: @@ -51,4 +22,4 @@ notifications: - https://webhooks.gitter.im/e/60e65d0c78ea0a920347 on_success: change # options: [always|never|change] default: always on_failure: always # options: [always|never|change] default: always - on_start: false # default: false + on_start: never # options: [always|never|change] default: always diff --git a/examples/ESP_AsyncFSBrowser/.esp31b.skip b/examples/ESP_AsyncFSBrowser/.esp31b.skip deleted file mode 100644 index e69de29..0000000 diff --git a/examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino b/examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino index b350dc3..2ea6246 100644 --- a/examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino +++ b/examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino @@ -1,9 +1,9 @@ -#include -#include +#include +#include #include #include -#include -#include +#include +#include #include #include @@ -94,7 +94,6 @@ const char* http_password = "admin"; void setup(){ Serial.begin(115200); Serial.setDebugOutput(true); - WiFi.hostname(hostName); WiFi.mode(WIFI_AP_STA); WiFi.softAP(hostName); WiFi.begin(ssid, password); @@ -135,7 +134,7 @@ void setup(){ }); server.addHandler(&events); - server.addHandler(new SPIFFSEditor(http_username,http_password)); + server.addHandler(new SPIFFSEditor(SPIFFS, http_username,http_password)); server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", String(ESP.getFreeHeap())); diff --git a/examples/simple_server/simple_server.ino b/examples/simple_server/simple_server.ino index 6fee6f7..a1ed7c1 100644 --- a/examples/simple_server/simple_server.ino +++ b/examples/simple_server/simple_server.ino @@ -6,9 +6,8 @@ // #include -#include -#include -#include +#include +#include #include AsyncWebServer server(80); @@ -34,8 +33,6 @@ void setup() { Serial.print("IP Address: "); Serial.println(WiFi.localIP()); - Serial.print("Hostname: "); - Serial.println(WiFi.hostname()); server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", "Hello, world"); diff --git a/travis/build.py b/travis/build.py new file mode 100755 index 0000000..a106f3d --- /dev/null +++ b/travis/build.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# build.py — build a sketch using arduino-builder +# +# Wrapper script around arduino-builder which accepts some ESP8266-specific +# options and translates them into FQBN +# +# Copyright © 2016 Ivan Grokhotkov +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# + + +from __future__ import print_function +import sys +import os +import argparse +import subprocess +import tempfile +import shutil + +def compile(tmp_dir, sketch, 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" ' + if args.library_path: + for lib_dir in args.library_path: + cmd += '-libraries "' + lib_dir + '" ' + cmd += '-hardware "' + ide_path + '/hardware" ' + if args.hardware_dir: + for hw_dir in args.hardware_dir: + cmd += '-hardware "' + hw_dir + '" ' + else: + cmd += '-hardware "' + hardware_dir + '" ' + # Debug=Serial,DebugLevel=Core____ + cmd += '-fqbn=espressif:esp32:{board_name}:' \ + 'FlashFreq={flash_freq},' \ + 'PartitionScheme=huge_app,' \ + 'UploadSpeed=921600'.format(**vars(args)) + cmd += ' ' + cmd += '-ide-version=10607 ' + cmd += '-warnings={warnings} '.format(**vars(args)) + if args.verbose: + cmd += '-verbose ' + cmd += sketch + + if args.verbose: + print('Building: ' + cmd, file=f) + + cmds = cmd.split(' ') + p = subprocess.Popen(cmds, stdout=f, stderr=subprocess.STDOUT) + p.wait() + return p.returncode + +def parse_args(): + parser = argparse.ArgumentParser(description='Sketch build helper') + parser.add_argument('-v', '--verbose', help='Enable verbose output', + action='store_true') + parser.add_argument('-i', '--ide_path', help='Arduino IDE path') + parser.add_argument('-p', '--build_path', help='Build directory') + parser.add_argument('-l', '--library_path', help='Additional library path', + action='append') + parser.add_argument('-d', '--hardware_dir', help='Additional hardware path', + action='append') + parser.add_argument('-b', '--board_name', help='Board name', default='esp32') + parser.add_argument('-w', '--warnings', help='Compilation warnings level', + default='none', choices=['none', 'all', 'more']) + parser.add_argument('-o', '--output_binary', help='File name for output binary') + parser.add_argument('-k', '--keep', action='store_true', + help='Don\'t delete temporary build directory') + parser.add_argument('--flash_freq', help='Flash frequency', default=40, + type=int, choices=[40, 80]) + parser.add_argument('sketch_path', help='Sketch file path') + return parser.parse_args() + +def main(): + args = parse_args() + + ide_path = args.ide_path + if not ide_path: + ide_path = os.environ.get('ARDUINO_IDE_PATH') + if not ide_path: + print("Please specify Arduino IDE path via --ide_path option" + "or ARDUINO_IDE_PATH environment variable.", file=sys.stderr) + return 2 + + sketch_path = args.sketch_path + tmp_dir = args.build_path + created_tmp_dir = False + if not tmp_dir: + 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 = ide_path + '/hardware' + + output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin' + if args.verbose: + print("Sketch: ", sketch_path) + print("Build dir: ", tmp_dir) + print("Output: ", output_name) + + if args.verbose: + f = sys.stdout + else: + f = open(tmp_dir + '/build.log', 'w') + + res = compile(tmp_dir, sketch_path, tools_dir, hardware_dir, ide_path, f, args) + if res != 0: + return res + + if args.output_binary is not None: + shutil.copy(output_name, args.output_binary) + + if created_tmp_dir and not args.keep: + shutil.rmtree(tmp_dir, ignore_errors=True) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/travis/build.sh b/travis/build.sh new file mode 100644 index 0000000..c3c62ec --- /dev/null +++ b/travis/build.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +echo -e "travis_fold:start:sketch_test_env_prepare" +pip install pyserial +wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz +tar xf arduino.tar.xz +mv arduino-nightly $HOME/arduino_ide +mkdir -p $HOME/Arduino/libraries +cd $HOME/Arduino/libraries +cp -rf $TRAVIS_BUILD_DIR ESPAsyncWebServer +git clone https://github.com/bblanchon/ArduinoJson +git clone https://github.com/me-no-dev/AsyncTCP +cd $HOME/arduino_ide/hardware +mkdir espressif +cd espressif +git clone https://github.com/espressif/arduino-esp32.git esp32 +cd esp32 +git submodule update --init --recursive +cd tools +python get.py +cd $TRAVIS_BUILD_DIR +export PATH="$HOME/arduino_ide:$HOME/arduino_ide/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin:$PATH" +source travis/common.sh +echo -e "travis_fold:end:sketch_test_env_prepare" + +echo -e "travis_fold:start:sketch_test" +build_sketches $HOME/arduino_ide $HOME/Arduino/libraries/ESPAsyncWebServer/examples "-l $HOME/Arduino/libraries" +if [ $? -ne 0 ]; then exit 1; fi +echo -e "travis_fold:end:sketch_test" diff --git a/travis/common.sh b/travis/common.sh index 57bede3..d299b4f 100755 --- a/travis/common.sh +++ b/travis/common.sh @@ -2,22 +2,38 @@ function build_sketches() { + #set +e local arduino=$1 local srcpath=$2 - local platform=$3 + local build_arg=$3 + local build_dir=build.tmp + mkdir -p $build_dir + local build_cmd="python travis/build.py -b esp32 -k -p $PWD/$build_dir $build_arg " local sketches=$(find $srcpath -name *.ino) + export ARDUINO_IDE_PATH=$arduino for sketch in $sketches; do + rm -rf $build_dir/* local sketchdir=$(dirname $sketch) - if [[ -f "$sketchdir/.$platform.skip" ]]; then - echo -e "\n\n ------------ Skipping $sketch ------------ \n\n"; + local sketchdirname=$(basename $sketchdir) + local sketchname=$(basename $sketch) + if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then + echo "Skipping $sketch, beacause it is not the main sketch file"; + continue + fi; + if [[ -f "$sketchdir/.test.skip" ]]; then + echo -e "\n ------------ Skipping $sketch ------------ \n"; continue fi - echo -e "\n\n ------------ Building $sketch ------------ \n\n"; - $arduino --verify $sketch; + echo -e "\n ------------ Building $sketch ------------ \n"; + time ($build_cmd $sketch >$build_dir/build.log) local result=$? if [ $result -ne 0 ]; then echo "Build failed ($1)" + echo "Build log:" + cat $build_dir/build.log return $result fi + rm $build_dir/build.log done + #set -e }