diff --git a/.travis.yml b/.travis.yml index 4903f98..a9cbf86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,30 @@ -language: c -before_install: - - export ARDUINO_VERSION=1.6.5 - - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" - - sleep 3 - - export DISPLAY=:1.0 - - wget http://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz - - tar xf arduino-${ARDUINO_VERSION}-linux64.tar.xz - - sudo mv arduino-${ARDUINO_VERSION} /usr/local/share/arduino - - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino +language: python + +python: + - 2.7 + +sudo: false + +cache: + directories: + - ~/.platformio + +# update Makefile if target boards added +env: + - PLATFORMIO_BOARD=uno + - PLATFORMIO_BOARD=due + - PLATFORMIO_BOARD=huzzah + - PLATFORMIO_BOARD=genuino101 + - PLATFORMIO_BOARD=teensy31 + install: - - ln -s ${PWD} /usr/local/share/arduino/libraries/ModbusMaster - - arduino --pref "compiler.warning_level=all" --save-prefs -script: - - echo $PWD + - pip install -U platformio + +before_script: + - env - echo $HOME + - echo $TRAVIS_BUILD_DIR - ls -al $PWD - - source ${TRAVIS_BUILD_DIR}/travis/common.sh - - build_examples + +script: + - make build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f28e24c --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +#-------------------------------------------------------------------- settings +FIND := find +DIR := $(PWD)/examples +CRITERIA := \( -name "*.ino" -o -name "*.pde" \) +EACH_EXAMPLE := $(FIND) $(DIR) $(CRITERIA) -exec +BUILD := platformio ci +LIB := . + +#--------------------------------------------------------------------- targets +# update .travis.yml if target boards added +all: uno due huzzah genuino101 teensy31 + +uno due huzzah genuino101 teensy31: + PLATFORMIO_BOARD=$@ $(MAKE) build + +build: + $(EACH_EXAMPLE) $(BUILD) --board=$(PLATFORMIO_BOARD) --lib=$(LIB) {} \; + +.PHONY: all uno due huzzah genuino101 teensy31 build diff --git a/travis/common.sh b/travis/common.sh deleted file mode 100755 index d115085..0000000 --- a/travis/common.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -function build_examples() -{ - # track the exit code for this platform - local exit_code=0 - # loop through results and add them to the array - examples=($(find $PWD/examples/ -name "*.pde" -o -name "*.ino")) - - # get the last example in the array - local last="${examples[@]:(-1)}" - - # loop through example sketches - for example in "${examples[@]}"; do - - # store the full path to the example's sketch directory - local example_dir=$(dirname $example) - - # store the filename for the example without the path - local example_file=$(basename $example) - - echo "$example_file: " - local sketch="$example_dir/$example_file" - echo "$sketch" - #arduino -v --verbose-build --verify $sketch - - # verify the example, and save stdout & stderr to a variable - # we have to avoid reading the exit code of local: - # "when declaring a local variable in a function, the local acts as a command in its own right" - local build_stdout - build_stdout=$(arduino --verify $sketch 2>&1) - - # echo output if the build failed - if [ $? -ne 0 ]; then - # heavy X - echo -e "\xe2\x9c\x96" - echo -e "----------------------------- DEBUG OUTPUT -----------------------------\n" - echo "$build_stdout" - echo -e "\n------------------------------------------------------------------------\n" - - # mark as fail - exit_code=1 - - else - # heavy checkmark - echo -e "\xe2\x9c\x93" - fi - done - - return $exit_code -}