From c2098edcc546c4657720b2ce1ad084eaac117957 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 9 Jun 2019 12:24:09 +0700 Subject: [PATCH] try to build all sketches with python script --- .travis.yml | 5 ++--- tools/build_all.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 tools/build_all.py diff --git a/.travis.yml b/.travis.yml index df7f0dc6..fdbdbf07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,8 +23,7 @@ install: - arduino --install-library "Adafruit NeoPixel","Adafruit SSD1306" before_script: - + - arduino --board adafruit:nrf52:feather52840:softdevice=s140v6,debug=l0 --save-prefs script: - - arduino --version - #- build_nrf5x_platforms + - python3 tools/build_all.py diff --git a/tools/build_all.py b/tools/build_all.py new file mode 100644 index 00000000..c7815498 --- /dev/null +++ b/tools/build_all.py @@ -0,0 +1,41 @@ +import os +import glob +import sys +import subprocess +import time +from pathlib import Path + +home = str(Path.home()) + +exit_status = 0 +success_count = 0 +fail_count = 0 + +for sketch in glob.iglob('libraries/**/*.ino', recursive=True): + start_time = time.monotonic() + #build_result = subprocess.run("/home/hathach/Applications/arduino-1.8.9/arduino-builder -compile -hardware /home/hathach/Applications/arduino-1.8.9/hardware -hardware /home/hathach/.arduino15/packages -hardware /home/hathach/Arduino/hardware/ -tools /home/hathach/.arduino15/packages/adafruit/tools -tools /home/hathach/Applications/arduino-1.8.9/tools-builder -tools /home/hathach/.arduino15/packages -built-in-libraries /home/hathach/Applications/arduino-1.8.9/libraries -libraries /home/hathach/Arduino/libraries -fqbn=adafruit:nrf52:feather52840:softdevice=s140v6,debug=l0 -ide-version=10807 -warnings=none -prefs=build.warn_data_percentage=75 -verbose {}".format(sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + build_result = subprocess.run("arduino --verify {}".format(sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + build_duration = time.monotonic() - start_time + + if build_result.returncode != 0: + exit_status = build_result.returncode + success = "\033[31mfailed\033[0m" + fail_count += 1 + else: + success = "\033[32msucceeded\033[0m" + success_count += 1 + + if travis: + print('travis_fold:start:build-{}\\r'.format(sketch)) + + print("Build {} took {:.2f}s and {}".format(sketch, build_duration, success)) + if build_result.returncode != 0: + print(build_result.stdout.decode("utf-8")) + + if travis: + print('travis_fold:end:build-{}\\r'.format(sketch)) + + +print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m".format(success_count, fail_count)) +sys.exit(exit_status) \ No newline at end of file