Travis

Embed Builds with PlatformIO

Overview #

PlatformIO is a cross-platform code-builder and library manager for embedded development with no external dependencies. Using PlatformIO you can compile your code on multiple platforms, frameworks, and boards. Unit testing requires a monthly subscription.

  • Platforms - pre-built different development platforms for the most popular host OS (macOS, Windows, Linux 32/64bit, Linux ARMv6+). Each of them includes compiler, debugger, uploader, etc:

    • Atmel AVR
    • Espressif
    • Teensy
    • ST STM32
    • Full list at PlatformIO
  • Frameworks - pre-configured build scripts for the popular embedded frameworks:

    • Arduino
    • libOpenCM3
    • mbed
    • Full list at PlatformIO
  • Embedded - pre-defined compilation profiles for a variety of embedded boards.

Full list at PlatformIO

.travis.yml file Settings #

Please read the official PlatformIO & Travis CI documentation before using PlatformIO.

PlatformIO is written in Python and is recommended to be run within a Travis CI Python isolated environment:

language: python
python:
  - "2.7"

cache:
  directories:
    - "~/.platformio"

env:
  - PLATFORMIO_CI_SRC=path/to/test/file.c
  - PLATFORMIO_CI_SRC=examples/file.ino
  - PLATFORMIO_CI_SRC=path/to/test/directory

install:
  - pip install -U platformio

script:
  - platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N

Test Libraries #

If the project you are testing is a library, please use the --lib="." option for the platformio ci command

script:
  - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N

Manage dependencies #

There are two options for testing projects with external dependencies:

  • using the PlatformIO Library Manager
  • installing dependencies manually

PlatformIO Library Manager #

For the dependencies available in the PlatformIO Library Registry:

install:
  - pip install -U platformio

  # Libraries from PlatformIO Library Registry:
  # http://platformio.org/#!/lib/show/1/OneWire
  - platformio lib install 1

Install dependencies manually #

For the dependencies not available in the PlatformIO Library Registry:

install:
  - pip install -U platformio

  # download library to the temporary directory
  - wget https://github.com/PaulStoffregen/OneWire/archive/master.zip -O /tmp/onewire_source.zip
  - unzip /tmp/onewire_source.zip -d /tmp/

script:
  - platformio ci --lib="/tmp/OneWire-master" --board=TYPE_1 --board=TYPE_2 --board=TYPE_N

Custom Build Flags #

To specify custom build flags using the PLATFORMIO_BUILD_FLAGS environment:

env:
  - PLATFORMIO_CI_SRC=path/to/test/file.c PLATFORMIO_BUILD_FLAGS="-D SPECIFIC_MACROS_PER_TEST_ENV -I/extra/inc"
  - PLATFORMIO_CI_SRC=examples/file.ino
  - PLATFORMIO_CI_SRC=path/to/test/directory

install:
  - pip install -U platformio
  - export PLATFORMIO_BUILD_FLAGS=-D GLOBAL_MACROS_FOR_ALL_TEST_ENV

More details are available at build flags/options.

Advanced configuration #

You can configure multiple build environments using a platformio.ini Project Configuration file, and specifying a –project-conf instead of --board.

script:
  - platformio ci --project-conf=/path/to/platformio.ini

Examples #