Skip to content

Commit 3ff7c3e

Browse files
authored
Add github actions compile test (#131)
* Add build & test workflow * Ensure no picotool needed for xip_ram_perms and flash_id compilation * Still check LIBUSB_ROOT if pkgconfig libusb not found
1 parent 971ee85 commit 3ff7c3e

File tree

5 files changed

+87
-1
lines changed

5 files changed

+87
-1
lines changed
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="gcc-arm-embedded" version="10.2.1" />
4+
<package id="cmake" version="3.25.2" installArguments="ADD_CMAKE_TO_PATH=System" />
5+
<package id="mingw" version="12.2.0" />
6+
<package id="ninja" version="1.11.1" />
7+
</packages>

.github/workflows/test.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
on:
2+
push:
3+
pull_request:
4+
5+
jobs:
6+
build:
7+
# Prevent running twice for PRs from same repo
8+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
9+
name: Build & Test
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [ubuntu-latest, windows-latest, macos-latest]
14+
generator: ["Ninja", "Unix Makefiles"]
15+
mbedtls: ["mbedtls", ""]
16+
libusb: ["libusb", ""]
17+
compile: ["compile", ""]
18+
exclude:
19+
- os: 'windows-latest'
20+
generator: "Unix Makefiles"
21+
- libusb: ""
22+
compile: "compile"
23+
runs-on: ${{ matrix.os }}
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- name: Install dependencies (Windows)
29+
if: runner.os == 'Windows'
30+
run: |
31+
choco install -y .github/workflows/choco_packages.config
32+
curl -L https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z -o libusb.7z
33+
7z x libusb.7z -olibusb
34+
- name: Set LIBUSB_ROOT (Windows)
35+
if: runner.os == 'Windows'
36+
shell: bash
37+
run: echo "LIBUSB_ROOT=$(pwd)/libusb" >> "$GITHUB_ENV"
38+
39+
- name: Install dependencies (macOS)
40+
if: runner.os == 'macOS'
41+
run: |
42+
brew install cmake libusb pkg-config ninja
43+
brew install --cask gcc-arm-embedded
44+
45+
- name: Install dependencies (Linux)
46+
if: runner.os == 'Linux'
47+
run: sudo apt install cmake ninja-build python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib libusb-1.0-0-dev
48+
- name: Checkout Pico SDK
49+
uses: actions/checkout@v4
50+
with:
51+
repository: raspberrypi/pico-sdk
52+
ref: develop
53+
path: pico-sdk
54+
submodules: ${{ !(!matrix.mbedtls) }}
55+
56+
- name: Build and Install
57+
run: |
58+
cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ !matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }}
59+
cmake --build build
60+
${{ runner.os != 'Windows' && 'sudo' || '' }} cmake --install build
61+
- name: Add to path (Windows)
62+
if: runner.os == 'Windows'
63+
run: echo "C:\Program Files (x86)\picotool\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
64+
65+
- name: Test
66+
run: |
67+
picotool help
68+
curl -L https://datasheets.raspberrypi.com/soft/blink.uf2 -o blink.uf2
69+
curl -L https://datasheets.raspberrypi.com/soft/hello_world.uf2 -o hello_world.uf2
70+
curl -L https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 -o flash_nuke.uf2
71+
picotool info -a blink.uf2
72+
picotool info -a hello_world.uf2
73+
picotool info -a flash_nuke.uf2

cmake/FindLIBUSB.cmake

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
2525

2626
if (PKG_CONFIG_FOUND)
2727
pkg_check_modules(PC_LIBUSB libusb-1.0)
28-
else ()
28+
endif()
29+
30+
if (NOT PC_LIBUSB_FOUND)
2931
# As the pkg-config was not found we are probably building under windows.
3032
# Determine the architecture of the host, to choose right library
3133
if (NOT DEFINED ARCHITECTURE)

picoboot_flash_id/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.12)
22

33
if (NOT USE_PRECOMPILED)
4+
set(PICO_NO_PICOTOOL 1)
5+
46
# default build type
57
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "build type")
68

xip_ram_perms/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.12)
22

33
if (NOT USE_PRECOMPILED)
44
set(PICO_PLATFORM rp2350-arm-s)
5+
6+
set(PICO_NO_PICOTOOL 1)
57

68
# Pull in SDK (must be before project)
79
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)

0 commit comments

Comments
 (0)