Skip to content

Commit 9d07e95

Browse files
committed
Add support for adding release info into adafruit/circuitpython-org
This also changes the build script to python with better output.
1 parent ab94344 commit 9d07e95

File tree

12 files changed

+354
-136
lines changed

12 files changed

+354
-136
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@
8383
[submodule "tools/huffman"]
8484
path = tools/huffman
8585
url = https://github.com/tannewt/huffman.git
86+
[submodule "tools/adabot"]
87+
path = tools/adabot
88+
url = https://github.com/adafruit/adabot.git

.travis.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,29 @@ git:
2121
# that SDK is shortest and add it there. In the case of major re-organizations,
2222
# just try to make the builds "about equal in run time"
2323
env:
24-
- TRAVIS_TESTS="unix docs translations" TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express makerdiary_nrf52840_mdk" TRAVIS_SDK=arm:nrf:esp8266
24+
- TRAVIS_TESTS="unix docs translations website" TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express makerdiary_nrf52840_mdk" TRAVIS_SDK=arm:nrf:esp8266
2525
- TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm
2626
- TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow" TRAVIS_SDK=arm
2727
- TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300" TRAVIS_SDK=arm
28-
- TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick" TRAVIS_SDK=arm
28+
- TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick" TRAVIS_SDK=arm
2929

3030
addons:
3131
artifacts:
3232
paths:
3333
- $(ls -d1 bin/*/* | tr "\n" ":")
3434
target_paths: /
3535

36+
deploy:
37+
provider: releases
38+
api_key:
39+
secure: "jdqVFw6itRY4qwQF4ReXo0uaymT+Mob6RhYX0lw8KWFNqBgHnLVuKmKKcGMEuRvBVMPkvxF7bMuOQzSBOunqwlHFse3oMzdWvQODv1zwV7pSRXGwTdIvTPbBjKWxnBG9uSNRf2R5AMflJFUxy2CbtBpgvNzr+4VLREZDrrjEu8C1iTtXGpSm5AQ5iIp2fkMAWD85FP7CQPpkqRoxhSIFZmTdurfYRmenq1OZ/4SeD5TESKcyvqJNzVT9z210B3cg3eAkP6ukvelW4qE2zgIANqUkGqvDEnAvEII9M89kuwhCMAekdfwnUSPrry+g77i1dUZHoRN1+MFj+waYtPaqxdYo2G1sysa6enxlu4jHMR5MfMk9eKHgaNgL3PiyANusYSS44amh8QIiVaX5nw82myZDCpQOZW7YqJKE6WX70Lbs4mS+wIs+ig4KIXO1B0p9kMb0OeVjHRl+KcXsWGRu/ECG/ExpqlVIssSPU407LohMXT2cJ37CY/R/EeK2XSDsQ2M3L3EAGUjCJdBGuwsOJ+2lG+HQpAVu9vAB4kq5jy9Ye+MG+8Xlkly3XZZ5+FkXyYxKnXb26/QVv0e5sIG5OmdJCPYFaH2J1QdKo7CdhEcBtrf6DMPWaimGMldShFqzLjOz3b3qLysRxFF0aGb7ipKPa57vawNzYHoPAViOcXQ="
40+
file:
41+
- $(ls -d1 bin/*/* | tr "\n" ":")
42+
skip_cleanup: true
43+
draft: true
44+
on:
45+
tags: true
46+
3647
notifications:
3748
webhooks:
3849
urls:
@@ -46,12 +57,13 @@ notifications:
4657
before_script:
4758
# Expand the git tree back to 4.0.0-alpha.1 and then fetch the latest tag.
4859
- LAST_TAG=`git ls-remote --quiet --tags --sort=version:refname | egrep -o "refs/tags/[0-9]+.*\$" | tail -n 1`
49-
- git fetch --shallow-exclude=4.0.0-alpha.1
60+
- git fetch --shallow-exclude=4.0.0-alpha.1 || git fetch --unshallow
5061
- git fetch --depth 1 origin $LAST_TAG:$LAST_TAG
5162
- git describe --dirty --always --tags
5263
- function var_search () { case "$1" in *$2*) true;; *) false;; esac; }
5364
- sudo dpkg --add-architecture i386
5465

66+
5567
- (! var_search "${TRAVIS_SDK-}" arm || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
5668

5769
# For nrf builds
@@ -62,10 +74,11 @@ before_script:
6274
- if var_search "${TRAVIS_SDK-}" esp8266 ; then PATH=$(readlink -f ../xtensa-lx106-elf/bin):$PATH; fi
6375

6476
# For coverage testing (upgrade is used to get latest urllib3 version)
65-
- ([[ -z "$TRAVIS_TESTS" ]] || sudo apt-get install -y python3-pip)
77+
- sudo apt-get install -y python3-pip
78+
- pip3 install --user sh click
6679
- ([[ -z "$TRAVIS_TESTS" ]] || sudo pip install --upgrade cpp-coveralls)
67-
- (! var_search "${TRAVIS_TESTS-}" docs || sudo pip install 'Sphinx<1.8.0' sphinx-rtd-theme recommonmark)
68-
- (! var_search "${TRAVIS_TESTS-}" translations || sudo pip3 install polib)
80+
- (! var_search "${TRAVIS_TESTS-}" docs || pip install --user 'Sphinx<1.8.0' sphinx-rtd-theme recommonmark)
81+
- (! var_search "${TRAVIS_TESTS-}" translations || pip3 install --user polib)
6982

7083
# report some good version numbers to the build
7184
- gcc --version
@@ -79,9 +92,8 @@ script:
7992
- make -C mpy-cross -j2
8093
- echo -en 'travis_fold:end:mpy-cross\\r'
8194

82-
- echo 'Building Adafruit binaries' && echo -en 'travis_fold:start:adafruit-bins\\r'
83-
- (for board in $TRAVIS_BOARDS; do TRAVIS_BOARD=$board tools/build_adafruit_bins.sh || exit $?; done)
84-
- echo -en 'travis_fold:end:adafruit-bins\\r'
95+
- cd tools && python3 build_adafruit_bins.py
96+
- cd ..
8597

8698
- echo 'Building unix' && echo -en 'travis_fold:start:unix\\r'
8799
- (! var_search "${TRAVIS_TESTS-}" unix || (make -C ports/unix deplibs -j2 && make -C ports/unix -j2 && make -C ports/unix coverage -j2))
@@ -119,5 +131,7 @@ script:
119131
# run coveralls coverage analysis (try to, even if some builds/tests failed)
120132
#- (cd ports/unix && coveralls --root ../.. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod)
121133

134+
- (! var_search "${TRAVIS_TESTS-}" website || (cd tools && python3 build_board_info.py && cd ..))
135+
122136
after_failure:
123137
- (cd tests && for exp in *.exp; do testbase=$(basename $exp .exp); echo -e "\nFAILURE $testbase"; diff -u $testbase.exp $testbase.out; done)

ports/esp8266/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build-*/

ports/esp8266/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $(error Invalid BOARD specified)
66
endif
77

88
# If the build directory is not given, make it reflect the board name.
9-
BUILD ?= build
9+
BUILD ?= build-$(BOARD)
1010

1111
include ../../py/mkenv.mk
1212

@@ -25,7 +25,7 @@ FROZEN_MPY_DIR ?= modules
2525
# include py core make definitions
2626
include $(TOP)/py/py.mk
2727

28-
FWBIN = $(BUILD)/firmware-combined.bin
28+
FWBIN = $(BUILD)/firmware.bin
2929
PORT ?= /dev/ttyACM0
3030
BAUD ?= 115200
3131
FLASH_MODE ?= qio
@@ -232,7 +232,7 @@ FROZEN_EXTRA_DEPS = $(CONFVARS_FILE)
232232

233233
.PHONY: deploy
234234

235-
deploy: $(BUILD)/firmware-combined.bin
235+
deploy: $(FWBIN)
236236
$(ECHO) "Writing $< to the board"
237237
$(Q)$(ESPTOOL) --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=$(FLASH_SIZE) --flash_mode=$(FLASH_MODE) 0 $<
238238

@@ -275,4 +275,4 @@ $(BUILD)/libaxtls.a:
275275

276276
clean-modules:
277277
git clean -f -d modules
278-
rm -f build/frozen*.c
278+
rm -f $(BUILD)/frozen*.c

ports/esp8266/esp8266_common.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ SECTIONS
142142
*lib/utils/*.o*(.literal*, .text*)
143143
*drivers/bus/*.o(.literal* .text*)
144144

145-
build/main.o(.literal* .text*)
145+
build*/main.o(.literal* .text*)
146146
*gccollect.o(.literal* .text*)
147147
*gchelper.o(.literal* .text*)
148148
*help.o(.literal* .text*)
@@ -178,7 +178,7 @@ SECTIONS
178178
*/frozen.o(.rodata.mp_frozen_content) /* frozen modules */
179179

180180
/* for -mforce-l32 */
181-
build/*.o(.rodata*)
181+
build*/*.o(.rodata*)
182182

183183
_irom0_text_end = ABSOLUTE(.);
184184
} >irom0_0_seg :irom0_0_phdr

ports/nrf/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ else
1010
endif
1111
endif
1212

13+
CLI_SD := $(SD)
14+
1315
include boards/$(BOARD)/mpconfigboard.mk
1416

1517
SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
1618

17-
# Build directory with SD
18-
BUILD ?= $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
19+
# Build directory with SD if it's different from the default.
20+
BUILD ?= $(if $(CLI_SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
1921

2022
include ../../py/mkenv.mk
2123
-include mpconfigport.mk

ports/unix/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ else
7474
# Use gcc syntax for map file
7575
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
7676
endif
77-
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
77+
LDFLAGS = -Lbuild $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
7878

7979
ifeq ($(MICROPY_FORCE_32BIT),1)
8080
# Note: you may need to install i386 versions of dependency packages,
@@ -245,7 +245,7 @@ coverage:
245245
$(MAKE) \
246246
COPT="-O0" CFLAGS_EXTRA='$(CFLAGS_EXTRA) -DMP_CONFIGFILE="<mpconfigport_coverage.h>" \
247247
-fprofile-arcs -ftest-coverage \
248-
-Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wsign-compare \
248+
-Wformat -Wmissing-declarations -Wmissing-prototypes -Wsign-compare \
249249
-Wold-style-definition -Wpointer-arith -Wshadow -Wuninitialized -Wunused-parameter \
250250
-DMICROPY_UNIX_COVERAGE' \
251251
LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' \

py/py.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ifeq ($(MICROPY_PY_USSL),1)
2828
CFLAGS_MOD += -DMICROPY_PY_USSL=1
2929
ifeq ($(MICROPY_SSL_AXTLS),1)
3030
CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I$(TOP)/lib/axtls/ssl -I$(TOP)/lib/axtls/crypto -I$(TOP)/lib/axtls/config
31-
LDFLAGS_MOD += -Lbuild -laxtls
31+
LDFLAGS_MOD += -L$(BUILD) -laxtls
3232
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
3333
# Can be overridden by ports which have "builtin" mbedTLS
3434
MICROPY_SSL_MBEDTLS_INCLUDE ?= $(TOP)/lib/mbedtls/include

tools/adabot

Submodule adabot added at 393c275

tools/build_adafruit_bins.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import os
2+
from sh import rm
3+
from sh import make
4+
import sys
5+
import subprocess
6+
import shutil
7+
import build_board_info as build_info
8+
import time
9+
10+
for port in build_info.SUPPORTED_PORTS:
11+
rm("-rf", "../ports/{}/build*".format(port))
12+
13+
ROSIE_SETUPS = ["rosie-ci"]
14+
rosie_ok = {}
15+
for rosie in ROSIE_SETUPS:
16+
rosie_ok[rosie] = True
17+
18+
PARALLEL = "-j 5"
19+
travis = False
20+
if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true":
21+
PARALLEL="-j 2"
22+
travis = True
23+
24+
all_boards = build_info.get_board_mapping()
25+
build_boards = list(all_boards.keys())
26+
if "TRAVIS_BOARDS" in os.environ:
27+
build_boards = os.environ["TRAVIS_BOARDS"].split()
28+
29+
sha, version = build_info.get_version_info()
30+
31+
languages = build_info.get_languages()
32+
exit_status = 0
33+
for board in build_boards:
34+
bin_directory = "../bin/{}/".format(board)
35+
os.makedirs(bin_directory, exist_ok=True)
36+
board_info = all_boards[board]
37+
38+
for language in languages:
39+
start_time = time.monotonic()
40+
make_result = subprocess.run("make -C ../ports/" + board_info["port"] + " TRANSLATION=" + language + " BOARD=" + board, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
41+
build_duration = time.monotonic() - start_time
42+
success = "\033[32msucceeded\033[0m"
43+
if make_result.returncode != 0:
44+
exit_status = make_result.returncode
45+
success = "\033[31mfailed\033[0m"
46+
47+
for extension in board_info["extensions"]:
48+
temp_filename = "../ports/{port}/build-{board}/firmware.{extension}".format(port=board_info["port"], board=board, extension=extension)
49+
final_filename = "adafruit-circuitpython-{board}-{language}-{version}.{extension}".format(board=board, language=language, version=version, extension=extension)
50+
final_filename = os.path.join(bin_directory, final_filename)
51+
shutil.copyfile(temp_filename, final_filename)
52+
53+
if travis:
54+
print('travis_fold:start:adafruit-bins-{}-{}\\r'.format(language, board))
55+
print("Build {} for {} took {:.2f}s and {}".format(board, language, build_duration, success))
56+
print(len(make_result.stdout))
57+
print(make_result.stdout.decode("utf-8"))
58+
# Only upload to Rosie if its a pull request.
59+
if travis:
60+
for rosie in ROSIE_SETUPS:
61+
if not rosie_ok[rosie]:
62+
break
63+
print("Uploading to https://{rosie}.ngrok.io/upload/{sha}".format(rosie=rosie, sha=sha))
64+
#curl -F "file=@$final_filename" https://$rosie.ngrok.io/upload/$sha
65+
if travis:
66+
print('travis_fold:end:adafruit-bins-{}-{}\\r'.format(language, board))
67+
68+
print()
69+
70+
sys.exit(exit_status)

0 commit comments

Comments
 (0)