From aea537f8e77bd979151889c7fe0d3a2992eb3edd Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 27 Sep 2026 07:52:26 +0100 Subject: [PATCH 1/6] Storing the output of the build in tmp files so we can extract the bits we need But we need both main and branch checked out and the action can do it for us Pulling the bank occupancy from the map produced by sdcc rather than the output of the build as it appears the output number is only the maximum size of the banks BANK0 isn't output, but what I'm guessing are the consituents for it are --- .github/workflows/build.yml | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31a94891..b1bfb084 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,10 @@ on: branches: ['**'] pull_request: +permissions: + contents: read + pull-requests: write + jobs: build: runs-on: ubuntu-latest @@ -13,18 +17,48 @@ jobs: steps: - uses: actions/checkout@v6 + with: + path: branch + + - uses: actions/checkout@v6 + with: + path: main + ref: main - name: Install dependencies run: | apt update apt install make gcc sdcc xxd python-is-python3 libjson-c-dev zlib1g-dev -y - name: Run the host-side unit tests - run: make -C test + run: cd branch && make -C test - name: Check that every machine definition can be compiled - run: make machine_check + run: cd branch && make machine_check - name: Make project (4x2/RTL8372) - run: make CI=1 MACHINE="KP_9000_6XHML_X2" + run: cd branch && make CI=1 MACHINE="KP_9000_6XHML_X2" && cp output/KP_9000_6XHML_X2/rtlplayground.map /tmp/branch.map - name: Make project (8x1/RTL8373) - run: make CI=1 MACHINE="KP_9000_9XHML_X_V3_1" + run: cd branch && make CI=1 MACHINE="KP_9000_9XHML_X_V3_1" - name: Make project with the health instrumentation - run: make clean && make CI=1 MACHINE="KP_9000_6XHML_X2" HEALTH=1 + run: cd branch && make clean && make CI=1 MACHINE="KP_9000_6XHML_X2" HEALTH=1 + - name: Make main + run: cd main && make CI=1 MACHINE="KP_9000_6XHML_X2" && cp output/KP_9000_6XHML_X2/rtlplayground.map /tmp/main.map + - name: Calculate bank growth + run: | + sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/MAIN_\1=\3/p' /tmp/main.map | sort | uniq >> "$GITHUB_ENV" + sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/BRANCH_\1=\3/p' /tmp/branch.map | sort | uniq >> "$GITHUB_ENV" + - name: Update PR comment + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: Sizes + message: | + ## Image Growth + + Commit: ${{ github.sha }} + + | Bank # | Main | Branch | + | --- | --- | --- | + | XSEG | ${{ env.MAIN_XSEG }} bytes | ${{ env.BRANCH_XSEG }} bytes | + | CSEG | ${{ env.MAIN_CSEG }} bytes | ${{ env.BRANCH_CSEG }} bytes | + | DSEG | ${{ env.MAIN_DSEG }} bytes | ${{ env.BRANCH_DSEG }} bytes | + | 1 | ${{ env.MAIN_BANK1 }} bytes | ${{ env.BRANCH_BANK1 }} bytes | + | 2 | ${{ env.MAIN_BANK2 }} bytes | ${{ env.BRANCH_BANK2 }} bytes | + | 3 | ${{ env.MAIN_BANK3 }} bytes | ${{ env.BRANCH_BANK3 }} bytes | From 2bc6939f86ed4006961f5db60b5e2f7e3a3ea422 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 4 Oct 2026 09:56:39 +0100 Subject: [PATCH 2/6] Sort -u and use v3 to silence nodejs v20 warnings --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b1bfb084..c211d357 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,10 +43,10 @@ jobs: run: cd main && make CI=1 MACHINE="KP_9000_6XHML_X2" && cp output/KP_9000_6XHML_X2/rtlplayground.map /tmp/main.map - name: Calculate bank growth run: | - sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/MAIN_\1=\3/p' /tmp/main.map | sort | uniq >> "$GITHUB_ENV" - sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/BRANCH_\1=\3/p' /tmp/branch.map | sort | uniq >> "$GITHUB_ENV" + sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/MAIN_\1=\3/p' /tmp/main.map | sort -u >> "$GITHUB_ENV" + sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/BRANCH_\1=\3/p' /tmp/branch.map | sort -u >> "$GITHUB_ENV" - name: Update PR comment - uses: marocchino/sticky-pull-request-comment@v2 + uses: marocchino/sticky-pull-request-comment@v3 with: header: Sizes message: | From 69714c8a75e172a140062fffacef6b1449fa0487 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 10 Oct 2026 21:46:47 +0100 Subject: [PATCH 3/6] Adding the ability to override the BUILDDIR so I can store branch-builds elsewhere --- .gitignore | 1 + Makefile | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 11f5c4ed..5b169b0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gitignore .idea/ output/ +output-main/ html_data.c html_data.h version.h diff --git a/Makefile b/Makefile index c95f12af..5ebd9ddf 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,10 @@ endif # The board definition being built: one file per MACHINE_* symbol in machine.h. MACHINE_SRC = machine/$(MACHINE).c -BUILDDIR = output/$(MACHINE) +ifndef BUILDDIR + BUILDDIR = output/$(MACHINE) +endif + VERSION_HEADER := version.h GIT_VERSION := $(shell git rev-parse --short HEAD) From 94ca35f65eb2dd21b643f6d35ede26fee6bc9cc9 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 10 Oct 2026 22:09:21 +0100 Subject: [PATCH 4/6] First version of a local "make bank_size" --- .gitignore | 1 + Makefile | 3 +++ tools/bank_occupancy.sh | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100755 tools/bank_occupancy.sh diff --git a/.gitignore b/.gitignore index 5b169b0f..9f544835 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ build/ # host-test stand-ins for the two generated headers !test/stub/html_data.h !test/stub/version.h +.vscode diff --git a/Makefile b/Makefile index 5ebd9ddf..aa31af35 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,9 @@ endif # is built, including the tools/ subdirectory. all: create_build_dir $(VERSION_HEADER) $(MACHINE_SRC) $(SUBDIRS) $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin +bank_size: + tools/bank_occupancy.sh "$(MACHINE)" + create_build_dir: mkdir -p "$(BUILDDIR)" mkdir -p "$(BUILDDIR)/uip" diff --git a/tools/bank_occupancy.sh b/tools/bank_occupancy.sh new file mode 100755 index 00000000..c0dece81 --- /dev/null +++ b/tools/bank_occupancy.sh @@ -0,0 +1,21 @@ +#!/bin/bash +MACHINE="$1" +if [[ ! -s output-main/rtlplayground.map ]]; then + original_branch=$(git branch --show-current) + #trap 'git switch "$original_branch"' EXIT + git switch main && make CI=1 MACHINE="$MACHINE" BUILDDIR=output-main + git switch "$original_branch" +fi +source <(sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/main_\1=\3/p' output-main/rtlplayground.map | sort -u) +if [[ ! -s "output/$MACHINE/rtlplayground.map" ]]; then + make CI=1 MACHINE="$MACHINE" +fi +source <(sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/branch_\1=\3/p' output/"$MACHINE"/rtlplayground.map | sort -u) + +printf '%-20s %-20s %-20s %-20s\n' "segment" "main" "branch" "change" +printf '%-20s %-20s %-20s %-20s\n' "BANK1" "$main_BANK1" "$branch_BANK1" "$(($branch_BANK1-$main_BANK1))" +printf '%-20s %-20s %-20s %-20s\n' "BANK2" "$main_BANK2" "$branch_BANK2" "$(($branch_BANK2-$main_BANK2))" +printf '%-20s %-20s %-20s %-20s\n' "BANK3" "$main_BANK3" "$branch_BANK3" "$(($branch_BANK3-$main_BANK3))" +printf '%-20s %-20s %-20s %-20s\n' "CSEG" "$main_CSEG" "$branch_CSEG" "$(($branch_CSEG-$main_CSEG))" +printf '%-20s %-20s %-20s %-20s\n' "DSEG" "$main_DSEG" "$branch_DSEG" "$(($branch_DSEG-$main_DSEG))" +printf '%-20s %-20s %-20s %-20s\n' "XSEG" "$main_XSEG" "$branch_XSEG" "$(($branch_XSEG-$main_XSEG))" From ef0d9d872ef54a27766d715592ac1caf57c79eb5 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Thu, 22 Oct 2026 09:48:53 +0100 Subject: [PATCH 5/6] adding the HTML/JS compressed sizes to the comment --- .github/workflows/build.yml | 6 +++++- tools/bank_occupancy.sh | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c211d357..89a2a029 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,9 @@ jobs: run: | sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/MAIN_\1=\3/p' /tmp/main.map | sort -u >> "$GITHUB_ENV" sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/BRANCH_\1=\3/p' /tmp/branch.map | sort -u >> "$GITHUB_ENV" + du -sb main/output/html_min | awk '{print "MAIN_WEB="$1}' >> "$GITHUB_ENV" + du -sb branch/output/html_min | awk '{print "BRANCH_WEB="$1}' >>"$GITHUB_ENV" + - name: Update PR comment uses: marocchino/sticky-pull-request-comment@v3 with: @@ -54,7 +57,7 @@ jobs: Commit: ${{ github.sha }} - | Bank # | Main | Branch | + | Name | Main | Branch | | --- | --- | --- | | XSEG | ${{ env.MAIN_XSEG }} bytes | ${{ env.BRANCH_XSEG }} bytes | | CSEG | ${{ env.MAIN_CSEG }} bytes | ${{ env.BRANCH_CSEG }} bytes | @@ -62,3 +65,4 @@ jobs: | 1 | ${{ env.MAIN_BANK1 }} bytes | ${{ env.BRANCH_BANK1 }} bytes | | 2 | ${{ env.MAIN_BANK2 }} bytes | ${{ env.BRANCH_BANK2 }} bytes | | 3 | ${{ env.MAIN_BANK3 }} bytes | ${{ env.BRANCH_BANK3 }} bytes | + | HTML/JS | ${{ env.MAIN_WEB }} bytes | ${{ env.BRANCH_WEB }} bytes | \ No newline at end of file diff --git a/tools/bank_occupancy.sh b/tools/bank_occupancy.sh index c0dece81..8638d390 100755 --- a/tools/bank_occupancy.sh +++ b/tools/bank_occupancy.sh @@ -7,15 +7,25 @@ if [[ ! -s output-main/rtlplayground.map ]]; then git switch "$original_branch" fi source <(sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/main_\1=\3/p' output-main/rtlplayground.map | sort -u) + +main_WEB=$(du -sb output-main/html_min | awk '{print $1}') if [[ ! -s "output/$MACHINE/rtlplayground.map" ]]; then make CI=1 MACHINE="$MACHINE" fi source <(sed -rn 's/^([XCD]SEG|(BANK[0-9])).*=\s+([0-9]+)\. bytes.*$/branch_\1=\3/p' output/"$MACHINE"/rtlplayground.map | sort -u) +branch_WEB=$(du -sb output/html_min | awk '{print $1}') + +print_line() { + local name=$1 main=$2 branch=$3 + printf '%-20s %-20s %-20s %-20s\n' "$name" "$main" "$branch" "$((branch - main))" +} printf '%-20s %-20s %-20s %-20s\n' "segment" "main" "branch" "change" -printf '%-20s %-20s %-20s %-20s\n' "BANK1" "$main_BANK1" "$branch_BANK1" "$(($branch_BANK1-$main_BANK1))" -printf '%-20s %-20s %-20s %-20s\n' "BANK2" "$main_BANK2" "$branch_BANK2" "$(($branch_BANK2-$main_BANK2))" -printf '%-20s %-20s %-20s %-20s\n' "BANK3" "$main_BANK3" "$branch_BANK3" "$(($branch_BANK3-$main_BANK3))" -printf '%-20s %-20s %-20s %-20s\n' "CSEG" "$main_CSEG" "$branch_CSEG" "$(($branch_CSEG-$main_CSEG))" -printf '%-20s %-20s %-20s %-20s\n' "DSEG" "$main_DSEG" "$branch_DSEG" "$(($branch_DSEG-$main_DSEG))" -printf '%-20s %-20s %-20s %-20s\n' "XSEG" "$main_XSEG" "$branch_XSEG" "$(($branch_XSEG-$main_XSEG))" + +print_line "BANK1" "$main_BANK1" "$branch_BANK1" +print_line "BANK2" "$main_BANK2" "$branch_BANK2" +print_line "BANK3" "$main_BANK3" "$branch_BANK3" +print_line "CSEG" "$main_CSEG" "$branch_CSEG" +print_line "DSEG" "$main_DSEG" "$branch_DSEG" +print_line "XSEG" "$main_XSEG" "$branch_XSEG" +print_line "WEB" "$main_WEB" "$branch_WEB" From 98965b73f694cc6ab4aa12d85a15b6324a95eb40 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Thu, 22 Oct 2026 12:55:51 +0100 Subject: [PATCH 6/6] Fixes to BUILDDIR --- Makefile | 6 +++--- tools/Makefile | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index aa31af35..54660495 100644 --- a/Makefile +++ b/Makefile @@ -139,7 +139,7 @@ HTML := $(shell find html -name '*.js' -or -name '*.html' -or -name '*.svg' -or # Minified copy of the web UI sources, used as the fileadder input. # The raw html/ sources stay untouched for development; the minified # copy is a build artifact under output/. -HTML_MIN := output/html_min +HTML_MIN := $(BUILDDIR)/html_min .PHONY: html_min html_min: $(HTML) rm -rf $(HTML_MIN) @@ -161,7 +161,7 @@ $(VERSION_HEADER): FORCE httpd: html_data.h $(SUBDIRS): - $(MAKE) -C $@ + $(MAKE) -C $@ BUILDDIR=$(BUILDDIR) clean: $(SUBDIRSCLEAN) -rm -f html_data.c html_data.h $(VERSION_HEADER) @@ -204,7 +204,7 @@ $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin: $(BUILDDIR)/rtlplayground.i tools/output/fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@ tools/output/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -z -d $(HTML_MIN) -b BANK1 $@ tools/output/crc_calculator -u $@ - ln -sf $(MACHINE)/rtlplayground-$(FILENAME_EXTENSION).bin output/rtlplayground.bin + ln -sf $(MACHINE)/rtlplayground-$(FILENAME_EXTENSION).bin $(BUILDDIR)/../rtlplayground.bin .PHONY: clean distclean all $(SUBDIRS) $(SUBDIRSCLEAN) create_build_dir diff --git a/tools/Makefile b/tools/Makefile index 1b1c6685..80ac9743 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,6 +1,8 @@ CC = gcc CCFLAGS = -Wall -o -BUILDDIR = output +ifndef BUILDDIR + BUILDDIR = output +endif all: create_build_dir $(BUILDDIR)/injector $(BUILDDIR)/fileadder $(BUILDDIR)/httpd_sim\ $(BUILDDIR)/crc_calculator $(BUILDDIR)/imagebuilder