From 4e85c1ef91683929df0afe105e92ce6e4291b445 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 24 May 2019 15:32:24 -0400 Subject: [PATCH] Implement forced clean builds for boards so designated. Mark boards that set CFLAGS_INLINE_LIMIT for particular langauges as needing clean builds. Fixes #1910. --- .../mpconfigboard.mk | 1 + .../mpconfigboard.mk | 1 + .../feather_m0_express/mpconfigboard.mk | 1 + .../itsybitsy_m0_express/mpconfigboard.mk | 1 + .../boards/metro_m0_express/mpconfigboard.mk | 1 + .../boards/pewpew10/mpconfigboard.mk | 1 + .../sparkfun_redboard_turbo/mpconfigboard.mk | 1 + py/circuitpy_defns.mk | 5 +++ tools/build_release_files.py | 37 ++++++++++++++++--- 9 files changed, 43 insertions(+), 6 deletions(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk index bc33be315d..3b9eba7be2 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk @@ -28,6 +28,7 @@ FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 25 +RELEASE_NEEDS_CLEAN_BUILD = 1 else CFLAGS_INLINE_LIMIT = 55 endif diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index 99ce90b3ce..0a8ac37b84 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -21,6 +21,7 @@ CHIP_FAMILY = samd21 # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 23 +RELEASE_NEEDS_CLEAN_BUILD = 1 else CFLAGS_INLINE_LIMIT = 55 endif diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk index a6190267d3..64d81c64cc 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk @@ -15,4 +15,5 @@ CHIP_FAMILY = samd21 # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 60 +RELEASE_NEEDS_CLEAN_BUILD = 1 endif diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk index 4f3e1ca667..1b2a039b86 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk @@ -15,6 +15,7 @@ CHIP_FAMILY = samd21 # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 45 +RELEASE_NEEDS_CLEAN_BUILD = 1 else CFLAGS_INLINE_LIMIT = 70 endif diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk index ce9c4baba2..ff5284aabc 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk @@ -16,4 +16,5 @@ CHIP_FAMILY = samd21 # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 50 +RELEASE_NEEDS_CLEAN_BUILD = 1 endif diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk index b36a213689..ef0f8faa7f 100644 --- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk @@ -25,4 +25,5 @@ CIRCUITPY_SMALL_BUILD = 1 # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 40 +RELEASE_NEEDS_CLEAN_BUILD = 1 endif diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk index 9e45f8ad9a..57400d6a79 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk @@ -16,4 +16,5 @@ EXTERNAL_FLASH_DEVICES = "W25Q32FV" # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 50 +RELEASE_NEEDS_CLEAN_BUILD = 1 endif diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 1aca339011..fd8e00354e 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -361,3 +361,8 @@ $(addprefix lib/,\ libm/atan2f.c \ ) endif + +.PHONY: check-release-needs-clean-build + +check-release-needs-clean-build: + @echo "RELEASE_NEEDS_CLEAN_BUILD = $(RELEASE_NEEDS_CLEAN_BUILD)" diff --git a/tools/build_release_files.py b/tools/build_release_files.py index 872302a4f6..e29b098c79 100755 --- a/tools/build_release_files.py +++ b/tools/build_release_files.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python3 + import os import sys import subprocess @@ -6,7 +8,7 @@ import build_board_info as build_info import time for port in build_info.SUPPORTED_PORTS: - result = subprocess.run("rm -rf ../ports/{}/build*".format(port), shell=True) + result = subprocess.run("rm -rf ../ports/{port}/build*".format(port=port), shell=True) ROSIE_SETUPS = ["rosie-ci"] rosie_ok = {} @@ -37,7 +39,25 @@ for board in build_boards: bin_directory = "../bin/{board}/{language}".format(board=board, language=language) os.makedirs(bin_directory, exist_ok=True) start_time = time.monotonic() - make_result = subprocess.run("make -C ../ports/" + board_info["port"] + " TRANSLATION=" + language + " BOARD=" + board, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + # Normally different language builds are all done based on the same set of compiled sources. + # But sometimes a particular language needs to be built from scratch, if, for instance, + # CFLAGS_INLINE_LIMIT is set for a particular language to make it fit. + clean_build_check_result = subprocess.run( + "make -C ../ports/{port} TRANSLATION={language} BOARD={board} check-release-needs-clean-build | fgrep 'RELEASE_NEEDS_CLEAN_BUILD = 1'".format( + port = board_info["port"], language=language, board=board), + shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + clean_build = clean_build_check_result.returncode == 0 + + build_dir = "build-{board}".format(board=board) + if clean_build: + build_dir += "-{language}".format(language=language) + + make_result = subprocess.run( + "make -C ../ports/{port} TRANSLATION={language} BOARD={board} BUILD={build}".format( + port = board_info["port"], language=language, board=board, build=build_dir), + shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + build_duration = time.monotonic() - start_time success = "\033[32msucceeded\033[0m" if make_result.returncode != 0: @@ -47,11 +67,14 @@ for board in build_boards: other_output = "" for extension in board_info["extensions"]: - temp_filename = "../ports/{port}/build-{board}/firmware.{extension}".format(port=board_info["port"], board=board, extension=extension) + temp_filename = "../ports/{port}/{build}/firmware.{extension}".format( + port=board_info["port"], build=build_dir, extension=extension) for alias in board_info["aliases"] + [board]: - bin_directory = "../bin/{alias}/{language}".format(alias=alias, language=language) + bin_directory = "../bin/{alias}/{language}".format( + alias=alias, language=language) os.makedirs(bin_directory, exist_ok=True) - final_filename = "adafruit-circuitpython-{alias}-{language}-{version}.{extension}".format(alias=alias, language=language, version=version, extension=extension) + final_filename = "adafruit-circuitpython-{alias}-{language}-{version}.{extension}".format( + alias=alias, language=language, version=version, extension=extension) final_filename = os.path.join(bin_directory, final_filename) try: shutil.copyfile(temp_filename, final_filename) @@ -62,7 +85,9 @@ for board in build_boards: if travis: print('travis_fold:start:adafruit-bins-{}-{}\\r'.format(language, board)) - print("Build {} for {} took {:.2f}s and {}".format(board, language, build_duration, success)) + print("Build {board} for {language}{clean_build} took {build_duration:.2f}s and {success}".format( + board=board, language=language, clean_build=(" (clean_build)" if clean_build else ""), + build_duration=build_duration, success=success)) if make_result.returncode != 0: print(make_result.stdout.decode("utf-8")) print(other_output)