File tree 3 files changed +91
-1
lines changed
3 files changed +91
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ language: bash
3
3
os : linux
4
4
dist : trusty
5
5
6
+ cache :
7
+ directories :
8
+ - $HOME/astyle
9
+
6
10
matrix :
7
11
include :
8
12
- env :
@@ -15,9 +19,23 @@ matrix:
15
19
- BUILD_TYPE=package
16
20
- env :
17
21
- BUILD_TYPE=host_tests
22
+ - env :
23
+ - BUILD_TYPE=style_check
18
24
19
25
install :
20
- - pip install --user -r doc/requirements.txt
26
+ - >
27
+ [ "$BUILD_TYPE" = "docs" ] && {
28
+ pip install --user -r doc/requirements.txt;
29
+ } || true
30
+ - >
31
+ [ "$BUILD_TYPE" = "style_check" ] && {
32
+ [ -f $HOME/astyle/build/gcc/bin/astyle ] || {
33
+ wget -O astyle_3.1_linux.tar.gz https://sourceforge.net/projects/astyle/files/astyle/astyle%203.1/astyle_3.1_linux.tar.gz/download;
34
+ tar -xf astyle_3.1_linux.tar.gz -C $HOME;
35
+ make -C $HOME/astyle/build/gcc;
36
+ }
37
+ make -C $HOME/astyle/build/gcc prefix=$HOME install;
38
+ } || true
21
39
22
40
script :
23
41
- $TRAVIS_BUILD_DIR/tests/common.sh
Original file line number Diff line number Diff line change @@ -213,8 +213,30 @@ function build_sketches_with_arduino()
213
213
echo -e " travis_fold:end:size_report"
214
214
}
215
215
216
+ function check_examples_style()
217
+ {
218
+ echo -e " travis_fold:start:check_examples_style"
219
+
220
+ find $TRAVIS_BUILD_DIR /libraries -name ' *.ino' -exec \
221
+ astyle \
222
+ --suffix=none \
223
+ --options=$TRAVIS_BUILD_DIR /tests/examples_style.conf {} \;
224
+
225
+ git diff --exit-code -- $TRAVIS_BUILD_DIR /libraries
226
+
227
+ echo -e " travis_fold:end:check_examples_style"
228
+ }
229
+
216
230
set -e
217
231
232
+ if [ -z " $TRAVIS_BUILD_DIR " ]; then
233
+ echo " TRAVIS_BUILD_DIR is not set, trying to guess:"
234
+ pushd $( dirname $0 ) /../ > /dev/null
235
+ TRAVIS_BUILD_DIR=$PWD
236
+ popd > /dev/null
237
+ echo " TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR "
238
+ fi
239
+
218
240
if [ " $BUILD_TYPE " = " build" ]; then
219
241
install_arduino
220
242
build_sketches_with_arduino
@@ -236,5 +258,11 @@ elif [ "$BUILD_TYPE" = "host_tests" ]; then
236
258
# Run host side tests
237
259
cd $TRAVIS_BUILD_DIR /tests
238
260
run_host_tests
261
+ elif [ " $BUILD_TYPE " = " style_check" ]; then
262
+ # Check code style
263
+ check_examples_style
264
+ else
265
+ echo " BUILD_TYPE not set"
266
+ exit 1
239
267
fi
240
268
Original file line number Diff line number Diff line change
1
+ # Code formatting rules for Arduino examples, taken from:
2
+ #
3
+ # https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf
4
+ #
5
+
6
+ mode=c
7
+ lineend=linux
8
+
9
+ # 2 spaces indentation
10
+ indent=spaces=2
11
+
12
+ # also indent macros
13
+ indent-preprocessor
14
+
15
+ # indent classes, switches (and cases), comments starting at column 1
16
+ indent-classes
17
+ indent-switches
18
+ indent-cases
19
+ indent-col1-comments
20
+
21
+ # put a space around operators
22
+ pad-oper
23
+
24
+ # put a space after if/for/while
25
+ pad-header
26
+
27
+ # if you like one-liners, keep them
28
+ keep-one-line-statements
29
+ add-braces
30
+
31
+ style=java
32
+ attach-namespaces
33
+ attach-classes
34
+ attach-inlines
35
+ attach-extern-c
36
+ indent-modifiers
37
+ indent-namespaces
38
+ indent-labels
39
+ indent-preproc-block
40
+ indent-preproc-define
41
+ indent-preproc-cond
42
+ unpad-paren
43
+ add-braces
44
+ remove-comment-prefix
You can’t perform that action at this time.
0 commit comments