Skip to content

Commit fb2b960

Browse files
committed
Add initial support for PlatformIO in CI
1 parent 9647626 commit fb2b960

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

Diff for: .travis.yml

+23
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,29 @@ matrix:
3434
else
3535
echo "Coding style check OK";
3636
fi
37+
38+
#
39+
# PlatformIO test
40+
#
41+
- env:
42+
- NAME=PlatformIO
43+
- CMSIS_VERSION=5.5.1
44+
install:
45+
# Install PlatformIO
46+
- pip install -U platformio
47+
# Install the development version of ststm32 platform
48+
- platformio platform install https://github.com/platformio/platform-ststm32.git
49+
# Prepare framework for CI
50+
- python -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/ststm32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoststm32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()"
51+
- sudo ln -sf $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoststm32
52+
# Download and unpack CMSIS package
53+
- wget https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/CMSIS-$CMSIS_VERSION.tar.bz2
54+
- tar -xvjf CMSIS-$CMSIS_VERSION.tar.bz2
55+
before_script:
56+
- cd $TRAVIS_BUILD_DIR/CI/build/
57+
script:
58+
- python platformio-builder.py --board=blackpill_f103c8 --board=remram_v1
59+
3760
#
3861
# Build test
3962
#

Diff for: CI/build/platformio-builder.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import argparse
2+
import os
3+
import subprocess
4+
import sys
5+
6+
7+
def run_platformio(example_path, boards):
8+
return subprocess.call(
9+
["platformio", "ci", example_path] + ["--board=" + b for b in boards])
10+
11+
12+
def collect_examples(libs_dir):
13+
examples = []
14+
for lib in os.listdir(libs_dir):
15+
lib_dir = os.path.join(libs_dir, lib)
16+
examples_dir = os.path.join(lib_dir, "examples")
17+
if os.path.isdir(examples_dir):
18+
examples.extend(
19+
[os.path.join(examples_dir, ex) for ex in os.listdir(examples_dir)])
20+
return examples
21+
22+
23+
parser = argparse.ArgumentParser(description="Basic PlatformIO runner")
24+
25+
parser.add_argument(
26+
"-b",
27+
"--board",
28+
action="append",
29+
help="board ID used for PlatformIO project"
30+
)
31+
32+
33+
def main():
34+
args = parser.parse_args()
35+
boards = args.board
36+
if boards is None:
37+
boards = ["nucleo_f401re"]
38+
39+
libs_dir = os.path.join(os.environ["TRAVIS_BUILD_DIR"], "libraries")
40+
if any(run_platformio(example, boards) for example in collect_examples(libs_dir)):
41+
sys.exit(1)
42+
43+
44+
if __name__ == "__main__":
45+
main()

0 commit comments

Comments
 (0)