Skip to content

Commit b17364a

Browse files
committed
conditionally build all languages
1 parent d35297c commit b17364a

File tree

12 files changed

+49
-17
lines changed

12 files changed

+49
-17
lines changed

.github/actions/deps/ports/broadcom/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ runs:
55
steps:
66
- name: Get broadcom toolchain
77
run: |
8-
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-10.3-2021.07-x86_64-broadcom64-none-elf.tar.xz
9-
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-10.3-2021.07-x86_64-broadcom64-none-elf.tar.xz
8+
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
9+
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
1010
sudo apt-get install -y mtools
1111
shell: bash
1212
- name: Install mkfs.fat

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ concurrency:
1818

1919
jobs:
2020
scheduler:
21-
runs-on: ubuntu-20.04
21+
runs-on: ubuntu-22.04
2222
outputs:
2323
docs: ${{ steps.set-matrix.outputs.docs }}
2424
boards: ${{ steps.set-matrix.outputs.boards }}
@@ -287,6 +287,7 @@ jobs:
287287
uses: ./.github/workflows/re-build-boards.yml
288288
secrets: inherit
289289
strategy:
290+
fail-fast: false
290291
matrix:
291292
port: ${{ fromJSON(needs.scheduler.outputs.boards).ports }}
292293
with:

.github/workflows/re-run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
run:
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
strategy:
1414
fail-fast: false
1515
matrix:
@@ -31,7 +31,7 @@ jobs:
3131
- name: Set up python
3232
uses: actions/setup-python@v4
3333
with:
34-
python-version: 3.x
34+
python-version: 3.8
3535
- name: Set up submodules
3636
uses: ./.github/actions/deps/submodules
3737
with:

ports/atmel-samd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE)
367367
$(STEPECHO) "LINK $@"
368368
$(Q)echo $(OBJ) > $(BUILD)/firmware.objs
369369
$(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group
370-
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE)
370+
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)
371371

372372
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
373373
$(STEPECHO) "Create $@"

ports/espressif/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ $(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
434434
$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_info.py
435435
$(STEPECHO) "Create $@"
436436
$(Q)esptool.py --chip $(IDF_TARGET) elf2image $(FLASH_FLAGS) --elf-sha256-offset 0xb0 -o $@ $^
437-
$(Q)$(PYTHON) tools/build_memory_info.py $< $(BUILD)/esp-idf/sdkconfig $@
437+
$(Q)$(PYTHON) tools/build_memory_info.py $< $(BUILD)/esp-idf/sdkconfig $@ $(BUILD)
438438

439439
$(BUILD)/firmware.bin: $(BUILD)/circuitpython-firmware.bin | esp-idf-stamp
440440
$(Q)$(PYTHON) ../../tools/join_bins.py $@ $(BOOTLOADER_OFFSET) $(BUILD)/esp-idf/bootloader/bootloader.bin $(PARTITION_TABLE_OFFSET) $(BUILD)/esp-idf/partition_table/partition-table.bin $(FIRMWARE_OFFSET) $(BUILD)/circuitpython-firmware.bin

ports/espressif/tools/build_memory_info.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
# SPDX-License-Identifier: MIT
77

88
import csv
9+
import json
910
import os
10-
import re
1111
import sys
1212

1313
from elftools.elf.elffile import ELFFile
1414

15-
print()
1615

1716
internal_memory = {
1817
"esp32": [
@@ -117,8 +116,12 @@ def find_region(start_address):
117116

118117
# This file is the bin
119118
used_flash = os.stat(sys.argv[3]).st_size
120-
121119
free_flash = firmware_region - used_flash
120+
121+
with open(f"{sys.argv[4]}/firmware.size.json", "w") as f:
122+
json.dump({"used_flash": used_flash, "firmware_region": firmware_region}, f)
123+
124+
print()
122125
print(
123126
"{:7} bytes used, {:7} bytes free in flash firmware space out of {} bytes ({}kB).".format(
124127
used_flash, free_flash, firmware_region, firmware_region / 1024

ports/litex/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.dfu
136136
$(BUILD)/firmware.elf: $(OBJ)
137137
$(STEPECHO) "LINK $@"
138138
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
139-
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LD_FILE)
139+
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)
140140

141141
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
142142
$(STEPECHO) "Create $@"

ports/nrf/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE)
212212
$(STEPECHO) "LINK $@"
213213
$(Q)echo $(OBJ) > $(BUILD)/firmware.objs
214214
$(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group
215-
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE)
215+
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)
216216

217217
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
218218
$(STEPECHO) "Create $@"

ports/raspberrypi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(LINK_LD)
417417
$(Q)echo $(OBJ) > $(BUILD)/firmware.objs
418418
$(Q)echo $(PICO_LDFLAGS) > $(BUILD)/firmware.ldflags
419419
$(Q)$(CC) -o $@ $(CFLAGS) @$(BUILD)/firmware.ldflags -Wl,-T,$(LINK_LD) -Wl,-Map=$@.map -Wl,-cref -Wl,--gc-sections @$(BUILD)/firmware.objs -Wl,-lc
420-
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LINK_LD)
420+
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LINK_LD) $(BUILD)
421421

422422
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
423423
$(STEPECHO) "Create $@"

ports/stm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ $(BUILD)/firmware.elf: $(OBJ)
268268
$(STEPECHO) "LINK $@"
269269
$(Q)echo $^ > $(BUILD)/firmware.objs
270270
$(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group
271-
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LD_FILE)
271+
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)
272272

273273
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
274274
$(STEPECHO) "Create $@"

tools/build_memory_info.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import re
99
import sys
10+
import json
11+
1012

1113
# Handle size constants with K or M suffixes (allowed in .ld but not in Python).
1214
K_PATTERN = re.compile(r"([0-9]+)[kK]")
@@ -15,11 +17,10 @@
1517
M_PATTERN = re.compile(r"([0-9]+)[mM]")
1618
M_REPLACE = r"(\1*1024*1024)"
1719

18-
print()
19-
2020
text = 0
2121
data = 0
2222
bss = 0
23+
2324
# stdin is the linker output.
2425
for line in sys.stdin:
2526
# Uncomment to see linker output.
@@ -29,6 +30,7 @@
2930
text, data, bss = map(int, line.split()[:3])
3031

3132
regions = {}
33+
3234
# This file is the linker script.
3335
with open(sys.argv[1], "r") as f:
3436
for line in f:
@@ -51,6 +53,11 @@
5153
free_flash = firmware_region - used_flash
5254
used_ram = data + bss
5355
free_ram = ram_region - used_ram
56+
57+
with open(f"{sys.argv[2]}/firmware.size.json", "w") as f:
58+
json.dump({"used_flash": used_flash, "firmware_region": firmware_region}, f)
59+
60+
print()
5461
print(
5562
"{} bytes used, {} bytes free in flash firmware space out of {} bytes ({}kB).".format(
5663
used_flash, free_flash, firmware_region, firmware_region / 1024

tools/build_release_files.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
import shutil
1212
import build_board_info as build_info
1313
import time
14+
import json
1415

1516
sys.path.append("../docs")
1617
from shared_bindings_matrix import get_settings_from_makefile
1718

1819
for port in build_info.SUPPORTED_PORTS:
1920
result = subprocess.run("rm -rf ../ports/{port}/build*".format(port=port), shell=True)
2021

21-
PARALLEL = "-j 5"
22+
PARALLEL = "-j 4"
2223
if "GITHUB_ACTION" in os.environ:
2324
PARALLEL = "-j 2"
2425

@@ -29,6 +30,11 @@
2930

3031
sha, version = build_info.get_version_info()
3132

33+
build_all = os.environ.get("GITHUB_EVENT_NAME") != "pull_request"
34+
35+
LANGUAGE_FIRST = "en_US"
36+
LANGUAGE_THRESHOLD = 10 * 1024
37+
3238
languages = build_info.get_languages()
3339

3440
all_languages = build_info.get_languages(list_all=True)
@@ -44,6 +50,9 @@
4450
board_info = all_boards[board]
4551
board_settings = get_settings_from_makefile("../ports/" + board_info["port"], board)
4652

53+
languages.remove(LANGUAGE_FIRST)
54+
languages.insert(0, LANGUAGE_FIRST)
55+
4756
for language in languages:
4857
bin_directory = "../bin/{board}/{language}".format(board=board, language=language)
4958
os.makedirs(bin_directory, exist_ok=True)
@@ -130,4 +139,16 @@
130139
# Flush so we will see something before 10 minutes has passed.
131140
print(flush=True)
132141

142+
if (not build_all) and (language is LANGUAGE_FIRST) and (exit_status is 0):
143+
try:
144+
with open(
145+
f"../ports/{board_info['port']}/{build_dir}/firmware.size.json", "r"
146+
) as f:
147+
firmware = json.load(f)
148+
if firmware["used_flash"] + LANGUAGE_THRESHOLD < firmware["firmware_region"]:
149+
print("Skipping languages")
150+
break
151+
except FileNotFoundError:
152+
pass
153+
133154
sys.exit(exit_status)

0 commit comments

Comments
 (0)