From 747a12e16f2acaba6ab0432067e2c644a2008780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 20:40:22 +0100 Subject: [PATCH 01/15] Set up CI/CD for this project with a GitHub Actions Workflow that builds and publishes the USBDDOS DOS executable --- .github/workflows/01-build-and-release.yml | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/01-build-and-release.yml diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml new file mode 100644 index 0000000..5994685 --- /dev/null +++ b/.github/workflows/01-build-and-release.yml @@ -0,0 +1,57 @@ +# With thanks to https://gist.github.com/weibeld/f136048d0a82aacc063f42e684e3c494 +name: build-and-release +on: push +permissions: + contents: write +jobs: + build-job: + runs-on: ubuntu-latest + container: + image: ghcr.io/volkertb/debian-djgpp:v0.2 + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Build project + run: | + test -f main.c + cd Make + echo $(which gcc) + ln -s /opt/djgpp/i586-pc-msdosdjgpp/bin/gcc /opt/djgpp/i586-pc-msdosdjgpp/bin/i586-pc-msdosdjgpp-gcc + make + find output/ + test -f output/usbddosp.exe + - name: 'Upload Artifact' + uses: actions/upload-artifact@v4 + with: + name: compiled-usbddosp-executable + path: output/usbddosp.exe + retention-days: 5 + + publish_job: + # TODO: uncomment following line (and remove this TODO) once the PR is approved, just before merging to master/main + #if: github.event.ref_name == github.event.repository.default_branch + runs-on: ubuntu-latest + steps: + - name: Generate release tag + id: tag + run: | + echo "release_tag=UserBuild_$(date +"%Y.%m.%d_%H-%M")" >> $GITHUB_OUTPUT + - name: 'Download Artifact' + uses: actions/download-artifact@v4 + with: + name: compiled-usbddosp-executable + - name: Check existence of artifact + run: | + test -f output/usbddosp.exe + - name: Release compiled executable + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.release_tag }} + files: | + output/usbddosp.exe + body: | + ## Release notes + + TODO From 32f1b16cfd31fb700d31b5eef365012ed5f21361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 20:41:35 +0100 Subject: [PATCH 02/15] Improve Makefile so that it assumes `gcc` to be DJGPP as a fallback when `i586-pc-msdosdjgpp-gcc` is not found in the path --- .github/workflows/01-build-and-release.yml | 1 - Make/Makefile | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 5994685..980d838 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -16,7 +16,6 @@ jobs: test -f main.c cd Make echo $(which gcc) - ln -s /opt/djgpp/i586-pc-msdosdjgpp/bin/gcc /opt/djgpp/i586-pc-msdosdjgpp/bin/i586-pc-msdosdjgpp-gcc make find output/ test -f output/usbddosp.exe diff --git a/Make/Makefile b/Make/Makefile index 50dfd28..e0ae22e 100644 --- a/Make/Makefile +++ b/Make/Makefile @@ -8,7 +8,15 @@ RM := del clean: $(RM) output\*.o else #PROMPT +ifeq (, $(shell which i586-pc-msdosdjgpp-gcc)) # If i586-pc-msdosdjgpp-gcc is not in the path +ifeq (, $(shell which gcc)) # If gcc is also not in the path +$(error "No compiler found in $(PATH), make sure that either i586-pc-msdosdjgpp-gcc or gcc (DJGPP) is installed.") +else # gcc IS in the path +CC = gcc +endif # If gcc is also not in the path +else # i586-pc-msdosdjgpp-gcc IS in the path CC = i586-pc-msdosdjgpp-gcc +endif # If i586-pc-msdosdjgpp-gcc is not in the path SRC = $(shell find .. -name '*.c') clean: $(RM) $(OBJS) From c020cc07268f09f78c1536846e53b39cca69572d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 20:44:42 +0100 Subject: [PATCH 03/15] Fix some include paths that were causing DJGPP compilation to fail (when the included file between quotes is in the same dir as the including file, don't prefix it with a path) --- RetroWav/Board/OPL3.c | 2 +- RetroWav/Protocol/Serial.c | 2 +- RetroWav/RetroWav.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RetroWav/Board/OPL3.c b/RetroWav/Board/OPL3.c index 25a51df..107b3cc 100644 --- a/RetroWav/Board/OPL3.c +++ b/RetroWav/Board/OPL3.c @@ -41,7 +41,7 @@ 并将在法律允许的最大范围内被起诉。 */ -#include "RETROWAV/BOARD/OPL3.h" +#include "OPL3.h" static const int transfer_speed = 2e6; diff --git a/RetroWav/Protocol/Serial.c b/RetroWav/Protocol/Serial.c index ec9523c..eb48733 100644 --- a/RetroWav/Protocol/Serial.c +++ b/RetroWav/Protocol/Serial.c @@ -42,7 +42,7 @@ 并将在法律允许的最大范围内被起诉。 */ -#include "Retrowav/Protocol/Serial.h" +#include "Serial.h" #ifdef __cplusplus extern "C" { diff --git a/RetroWav/RetroWav.c b/RetroWav/RetroWav.c index f119f85..275dbb5 100644 --- a/RetroWav/RetroWav.c +++ b/RetroWav/RetroWav.c @@ -42,7 +42,7 @@ 并将在法律允许的最大范围内被起诉。 */ -#include "RetroWav/RetroWav.h" +#include "RetroWav.h" #include #define RETROWAVE_CMD_BUFFER_SIZE 110 From 17b25b2f630c6da4a6ddc58cb5992a17d49498ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 20:46:02 +0100 Subject: [PATCH 04/15] Fix file case in include directive, which was failing in Linux with case-sensitive file systems --- USBDDOS/HCD/hcd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USBDDOS/HCD/hcd.h b/USBDDOS/HCD/hcd.h index 19c2dd4..2ffecce 100644 --- a/USBDDOS/HCD/hcd.h +++ b/USBDDOS/HCD/hcd.h @@ -1,7 +1,7 @@ #ifndef _HCD_H_ #define _HCD_H_ 1 #include "USBDDOS/platform.h" -#include "USBDDOS/USBCFG.H" +#include "USBDDOS/usbcfg.h" #include "USBDDOS/pci.h" //host controler driver generic From ec0f3f346f2ee902009064636060a199b341d06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 20:47:04 +0100 Subject: [PATCH 05/15] Fix `error: "DEBUG" is not defined, evaluates to 0 [-Werror=undef]` error (since Makefile configured compiler to treat all warnings as errors) --- Make/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Make/Makefile b/Make/Makefile index e0ae22e..eeecfbc 100644 --- a/Make/Makefile +++ b/Make/Makefile @@ -32,7 +32,7 @@ LDFLAGS = -lm ifeq ($(DEBUG),0) LDFLAGS += -s -CFLAGS += -DNDEBUG +CFLAGS += -DNDEBUG -DDEBUG=0 else CFLAGS += -DDEBUG=1 endif From b18c3416d2b2c13b4992fbb50abe43cbbc0b9683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 20:48:31 +0100 Subject: [PATCH 06/15] Add JetBrains IDE metadata folder to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5963105..0c626fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.idea .vscode Make/output/*.* From 2830d65601efa47099b8c71bd7a4e24c8598341a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 20:55:58 +0100 Subject: [PATCH 07/15] Don't run the `publish-job` unless `build-job` runs successfully first --- .github/workflows/01-build-and-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 980d838..bac0ac4 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -26,9 +26,10 @@ jobs: path: output/usbddosp.exe retention-days: 5 - publish_job: + publish-job: # TODO: uncomment following line (and remove this TODO) once the PR is approved, just before merging to master/main #if: github.event.ref_name == github.event.repository.default_branch + needs: build-job runs-on: ubuntu-latest steps: - name: Generate release tag From 775a38a61afb104e0a64e799516400f07d69cf34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 22:52:18 +0100 Subject: [PATCH 08/15] Fix artifact output path --- .github/workflows/01-build-and-release.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index bac0ac4..1967c05 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -17,13 +17,12 @@ jobs: cd Make echo $(which gcc) make - find output/ test -f output/usbddosp.exe - name: 'Upload Artifact' uses: actions/upload-artifact@v4 with: name: compiled-usbddosp-executable - path: output/usbddosp.exe + path: Make/output/usbddosp.exe retention-days: 5 publish-job: @@ -42,7 +41,7 @@ jobs: name: compiled-usbddosp-executable - name: Check existence of artifact run: | - test -f output/usbddosp.exe + test -f Make/output/usbddosp.exe - name: Release compiled executable uses: softprops/action-gh-release@v1 env: @@ -50,7 +49,7 @@ jobs: with: tag_name: ${{ steps.tag.outputs.release_tag }} files: | - output/usbddosp.exe + Make/output/usbddosp.exe body: | ## Release notes From 7b61155f2efd3b2c48d1cdd7dc6bb98fd63623ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 22:54:59 +0100 Subject: [PATCH 09/15] Fix download of artifact (upload is working now) --- .github/workflows/01-build-and-release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 1967c05..d5ca93c 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -41,7 +41,8 @@ jobs: name: compiled-usbddosp-executable - name: Check existence of artifact run: | - test -f Make/output/usbddosp.exe + find ./ | grep usbddosp + test -f usbddosp.exe - name: Release compiled executable uses: softprops/action-gh-release@v1 env: @@ -49,7 +50,7 @@ jobs: with: tag_name: ${{ steps.tag.outputs.release_tag }} files: | - Make/output/usbddosp.exe + usbddosp.exe body: | ## Release notes From 265a8f1960fd5006a9bfeb528df6be9796ac7ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Thu, 28 Dec 2023 22:57:09 +0100 Subject: [PATCH 10/15] Remove unnecessary step that was only really necessary for troubleshooting the pipeline, which is now working --- .github/workflows/01-build-and-release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index d5ca93c..2bb16ff 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -39,10 +39,6 @@ jobs: uses: actions/download-artifact@v4 with: name: compiled-usbddosp-executable - - name: Check existence of artifact - run: | - find ./ | grep usbddosp - test -f usbddosp.exe - name: Release compiled executable uses: softprops/action-gh-release@v1 env: From 7553e23d9ad2e0c82002be28b9d7c2b131f5a7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Fri, 29 Dec 2023 14:23:43 +0100 Subject: [PATCH 11/15] Release both a regular and a debug-enabled build in GitHub Actions Workflow, replace TODO placeholder in release notes template with brief explanation about difference between the two artifacts --- .github/workflows/01-build-and-release.yml | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 2bb16ff..8c2ab7e 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -15,15 +15,22 @@ jobs: run: | test -f main.c cd Make - echo $(which gcc) + make DEBUG=1 + mv output/usbddosp.exe output/usbddosp_dbg.exe + make clean make test -f output/usbddosp.exe - - name: 'Upload Artifact' + test -f output/usbddosp_dbg.exe + # Verify that the non-debug variant is actually different from the debug variant. + ! diff output/usbddosp.exe output/usbddosp_dbg.exe + - name: 'Upload Artifacts' uses: actions/upload-artifact@v4 with: - name: compiled-usbddosp-executable - path: Make/output/usbddosp.exe - retention-days: 5 + name: compiled-usbddosp-executables + path: | + Make/output/usbddosp.exe + Make/output/usbddosp_dbg.exe + retention-days: 1 publish-job: # TODO: uncomment following line (and remove this TODO) once the PR is approved, just before merging to master/main @@ -35,11 +42,11 @@ jobs: id: tag run: | echo "release_tag=UserBuild_$(date +"%Y.%m.%d_%H-%M")" >> $GITHUB_OUTPUT - - name: 'Download Artifact' + - name: 'Download Artifacts' uses: actions/download-artifact@v4 with: - name: compiled-usbddosp-executable - - name: Release compiled executable + name: compiled-usbddosp-executables + - name: Release compiled executables uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -47,7 +54,12 @@ jobs: tag_name: ${{ steps.tag.outputs.release_tag }} files: | usbddosp.exe + usbddosp_dbg.exe body: | - ## Release notes + ## Description of files - TODO + - `usbddosp.exe` -> Regular build that you should use normally. + - `usbddosp_dbg.exe` -> Debug-enabled build to help with debugging and troubleshooting. + + When the tool isn't working on the hardware you're trying it on, then please try the debug-enabled build. + When opening a GitHub issue to report incompatible hardware, please include any debug output. From 2ba17b3497797dbf335d2c16975e8005505a51ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Fri, 29 Dec 2023 14:30:46 +0100 Subject: [PATCH 12/15] Run `make clean` before building the debug-enabled variant as well, since the compilation is passing locally with `act`, but failing in actual GitHub Actions for some reason. --- .github/workflows/01-build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 8c2ab7e..0e33a81 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -15,6 +15,7 @@ jobs: run: | test -f main.c cd Make + make clean make DEBUG=1 mv output/usbddosp.exe output/usbddosp_dbg.exe make clean From a54d2df52ef3fda28218f3265f92b5866fd88cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Fri, 29 Dec 2023 14:35:48 +0100 Subject: [PATCH 13/15] Build debug-enabled variant and non-debug-enabled (regular) variant in separate steps, to ease build failure troubleshooting --- .github/workflows/01-build-and-release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 0e33a81..501ac91 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -11,13 +11,16 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v4 - - name: Build project + - name: Build with debug run: | - test -f main.c cd Make make clean make DEBUG=1 mv output/usbddosp.exe output/usbddosp_dbg.exe + test -f output/usbddosp_dbg.exe + - name: Build without debug + run: | + cd Make make clean make test -f output/usbddosp.exe From c4a6558a5cb9d234339bba6ceeb8a8ef1ee56662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Fri, 29 Dec 2023 14:41:13 +0100 Subject: [PATCH 14/15] Temporarily disable the build of the debug-enabled version, to verify that it's only failing in GitHub Actions when building with `make DEBUG=1` (which passes locally with `act`, yet fails in actual GitHub Actions for some reason) --- .github/workflows/01-build-and-release.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 501ac91..6e7a7f7 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -11,29 +11,29 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v4 - - name: Build with debug - run: | - cd Make - make clean - make DEBUG=1 - mv output/usbddosp.exe output/usbddosp_dbg.exe - test -f output/usbddosp_dbg.exe +# - name: Build with debug +# run: | +# cd Make +# make clean +# make DEBUG=1 +# mv output/usbddosp.exe output/usbddosp_dbg.exe +# test -f output/usbddosp_dbg.exe - name: Build without debug run: | cd Make make clean make test -f output/usbddosp.exe - test -f output/usbddosp_dbg.exe +# test -f output/usbddosp_dbg.exe # Verify that the non-debug variant is actually different from the debug variant. - ! diff output/usbddosp.exe output/usbddosp_dbg.exe +# ! diff output/usbddosp.exe output/usbddosp_dbg.exe - name: 'Upload Artifacts' uses: actions/upload-artifact@v4 with: name: compiled-usbddosp-executables path: | Make/output/usbddosp.exe - Make/output/usbddosp_dbg.exe +# Make/output/usbddosp_dbg.exe retention-days: 1 publish-job: @@ -58,7 +58,7 @@ jobs: tag_name: ${{ steps.tag.outputs.release_tag }} files: | usbddosp.exe - usbddosp_dbg.exe +# usbddosp_dbg.exe body: | ## Description of files From c3b9cc93c56fed6e001d7e302df2f5be1a266fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkert=20de=20Buisonj=C3=A9?= Date: Fri, 29 Dec 2023 14:44:23 +0100 Subject: [PATCH 15/15] Revert "Temporarily disable the build of the debug-enabled version, to verify that it's only failing in GitHub Actions when building with `make DEBUG=1` (which passes locally with `act`, yet fails in actual GitHub Actions for some reason)" This reverts commit c4a6558a5cb9d234339bba6ceeb8a8ef1ee56662. --- .github/workflows/01-build-and-release.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/01-build-and-release.yml b/.github/workflows/01-build-and-release.yml index 6e7a7f7..501ac91 100644 --- a/.github/workflows/01-build-and-release.yml +++ b/.github/workflows/01-build-and-release.yml @@ -11,29 +11,29 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v4 -# - name: Build with debug -# run: | -# cd Make -# make clean -# make DEBUG=1 -# mv output/usbddosp.exe output/usbddosp_dbg.exe -# test -f output/usbddosp_dbg.exe + - name: Build with debug + run: | + cd Make + make clean + make DEBUG=1 + mv output/usbddosp.exe output/usbddosp_dbg.exe + test -f output/usbddosp_dbg.exe - name: Build without debug run: | cd Make make clean make test -f output/usbddosp.exe -# test -f output/usbddosp_dbg.exe + test -f output/usbddosp_dbg.exe # Verify that the non-debug variant is actually different from the debug variant. -# ! diff output/usbddosp.exe output/usbddosp_dbg.exe + ! diff output/usbddosp.exe output/usbddosp_dbg.exe - name: 'Upload Artifacts' uses: actions/upload-artifact@v4 with: name: compiled-usbddosp-executables path: | Make/output/usbddosp.exe -# Make/output/usbddosp_dbg.exe + Make/output/usbddosp_dbg.exe retention-days: 1 publish-job: @@ -58,7 +58,7 @@ jobs: tag_name: ${{ steps.tag.outputs.release_tag }} files: | usbddosp.exe -# usbddosp_dbg.exe + usbddosp_dbg.exe body: | ## Description of files