Skip to content

Commit

Permalink
Add Github Actions CI, fixup CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Oct 8, 2023
1 parent 56ad321 commit 4f4ede5
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 1 deletion.
103 changes: 103 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CMake Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_TYPE: "Release"
PICOSDK_VER: "1.5.1"
PICOEXTRA_VER: "sdk-1.5.1"
# The Pico-SDK will listen to these environment vars
PICO_SDK_PATH: ${{github.workspace}}/pico/pico-sdk
PICO_EXTRAS_PATH: ${{github.workspace}}/pico/pico-extras
OUTPUT_DIR: ${{github.workspace}}/binaries
steps:
- name: Checkout repo with submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '12.3.Rel1'

# Since we reference stable versions of Pico-SDK and pico-extras, we can cache their (HUGE!) downloads.
# If this were to reference changing branches (like "master"), this caching step must be removed!!!
- name: Cache Pico-SDK and Extras
id: cache-sdk
uses: actions/cache@v3
with:
path: ${{github.workspace}}/pico/
key: ${{ env.PICOSDK_VER }}-${{ env.PICOEXTRA_VER }}

# If we did not find stuff in the cache, download it fresh.
- name: Clone Pico-SDK
if: steps.cache-sdk.outputs.cache-hit != 'true'
run: git clone -b "$PICOSDK_VER" --recursive https://github.com/raspberrypi/pico-sdk.git $PICO_SDK_PATH
- name: Clone Pico-Extras
if: steps.cache-sdk.outputs.cache-hit != 'true'
run: git clone -b "$PICOEXTRA_VER" --recursive https://github.com/raspberrypi/pico-extras.git $PICO_EXTRAS_PATH

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Patch CMake (disable LTO)
# in-place delete line
run: sed -i 's/add_compile_options(-flto=jobserver)//g' ${{github.workspace}}/sw/CMakeLists.txt

- name: Build GUS Firmware
shell: bash
working-directory: ${{github.workspace}}/build
run: |
mkdir -p $OUTPUT_DIR
cmake $GITHUB_WORKSPACE/sw -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPROJECT_TYPE="GUS"
cmake --build . --config $BUILD_TYPE --parallel $(nproc)
cp picogus.uf2 $OUTPUT_DIR/picogus-gus.uf2
- name: Build OPL / AdLib Firmware
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake $GITHUB_WORKSPACE/sw -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPROJECT_TYPE="OPL"
cmake --build . --config $BUILD_TYPE --parallel $(nproc)
cp picogus.uf2 $OUTPUT_DIR/picogus-opl.uf2
- name: Build MPU401 Firmware
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake $GITHUB_WORKSPACE/sw -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPROJECT_TYPE="MPU"
cmake --build . --config $BUILD_TYPE --parallel $(nproc)
cp picogus.uf2 $OUTPUT_DIR/picogus-mpu401.uf2
- name: Build Tandy Firmware
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake $GITHUB_WORKSPACE/sw -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPROJECT_TYPE="TANDY"
cmake --build . --config $BUILD_TYPE --parallel $(nproc)
cp picogus.uf2 $OUTPUT_DIR/picogus-tandy.uf2
- name: Build CMS Firmware
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake $GITHUB_WORKSPACE/sw -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPROJECT_TYPE="CMS"
cmake --build . --config $BUILD_TYPE --parallel $(nproc)
cp picogus.uf2 $OUTPUT_DIR/picogus-cms.uf2
- name: Build Joy Firmware
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake $GITHUB_WORKSPACE/sw -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPROJECT_TYPE="JOY"
cmake --build . --config $BUILD_TYPE --parallel $(nproc)
cp picogus.uf2 $OUTPUT_DIR/picogus-joy.uf2
# will generate PicoGUS Firmwares.zip as downloadable artifact with all .uf2 files
- name: Upload All Firmwares
uses: actions/upload-artifact@v3
with:
name: PicoGUS Firmwares
path: ${{env.OUTPUT_DIR}}
7 changes: 6 additions & 1 deletion sw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ set(CMAKE_CXX_STANDARD 17)

# Initialise pico_sdk from installed location
# (note this can come from environment, CMake cache etc)
set(PICO_SDK_PATH "${CMAKE_SOURCE_DIR}/../../pico/pico-sdk")
# to manually set Pico SDK path, uncomment this with your path.
# Otherwise, the environment variable PICO_SDK_PATH will be used.
#set(PICO_SDK_PATH "${CMAKE_SOURCE_DIR}/../../pico/pico-sdk")

# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)
Expand Down Expand Up @@ -209,6 +211,9 @@ if(ASYNC_UART)
endif()

pico_add_extra_outputs(picogus)
# print size
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND arm-none-eabi-size --format=berkeley "${PROJECT_NAME}.elf")

add_custom_target(
program
Expand Down

0 comments on commit 4f4ede5

Please sign in to comment.