Skip to content

Commit 054420c

Browse files
authored
Merge pull request #37 from unofficial-rev-port/fix/upstream-build-changes
Update build system for Linux, macOS, overhaul GitHub Actions, remove serial driver
2 parents 44bdc5b + a06a0bb commit 054420c

24 files changed

+198
-5081
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
# Dependabot updates for GitHub Actions
4+
- package-ecosystem: github-actions
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 150 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,203 @@
11
name: Build
22

33
on:
4-
push:
5-
branches:
6-
- 'main'
7-
pull_request:
8-
branches:
9-
- '*'
4+
[push, pull_request]
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: false
109

1110
defaults:
1211
run:
1312
shell: bash
1413

1514
jobs:
15+
# Use native runners to build for Windows, Linux x86-64, and macOS; use WPI provided Docker images to build for Linux ARM32 and ARM64 platforms
1616
build:
17-
timeout-minutes: 15
1817
strategy:
1918
fail-fast: false
2019
matrix:
2120
include:
2221
- os: windows-latest
23-
container: ''
24-
name: windows64
25-
name: "build-${{ matrix.name }}"
22+
name: Win64
23+
build-options: ""
24+
platform-type: windowsx86-64
25+
- os: ubuntu-latest
26+
name: Linux64
27+
platform-type: linuxx86-64
28+
build-options: ""
29+
- os: macos-latest
30+
name: macOS
31+
platform-type: osxuniversal
32+
build-options: ""
33+
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
34+
os: ubuntu-latest
35+
name: LinuxARM64
36+
build-options: "-Ponlylinuxarm64"
37+
platform-type: linuxarm64
38+
arch: arm64
39+
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
40+
os: ubuntu-latest
41+
name: LinuxARM32
42+
build-options: "-Ponlylinuxarm32"
43+
platform-type: linuxarm32
44+
arch: arm32
45+
name: "Build - ${{ matrix.name }}"
2646
runs-on: ${{ matrix.os }}
2747
container: ${{ matrix.container }}
2848
steps:
2949
- name: Checkout
30-
uses: actions/checkout@v3
50+
uses: actions/checkout@v4
3151
with:
3252
ref: ${{ github.sha }}
3353

3454
- name: Setup Java
35-
uses: actions/setup-java@v3
55+
uses: actions/setup-java@v4
3656
with:
3757
distribution: 'zulu'
3858
java-version: 11
3959

60+
- name: Setup Gradle
61+
uses: gradle/actions/setup-gradle@v4
62+
4063
- name: Build
4164
run: |
4265
./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode
4366
44-
- name: Download WPILib HAL artifacts and headers, gather all needed headers
67+
- name: Download WPILib HAL artifacts and headers for ${{ matrix.platform-type }}
4568
run : |
4669
halVersion=$(cat wpiHalVersion.txt)
70+
71+
sharedHalPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
72+
sharedUtilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
73+
curl -L -o sharedHalPlatform.zip "$sharedHalPlatformUrl"
74+
curl -L -o sharedUtilPlatform.zip "$sharedUtilPlatformUrl"
4775
48-
# Download WPILib artifacts from Artifactory
49-
halWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-windowsx86-64.zip
76+
staticHalPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}static.zip
77+
staticUtilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}static.zip
78+
curl -L -o staticHalPlatform.zip "$staticHalPlatformUrl"
79+
curl -L -o staticUtilPlatform.zip "$staticUtilPlatformUrl"
80+
81+
- name: Unzip WPILib HAL artifacts and headers
82+
run: |
83+
unzip sharedHalPlatform.zip -d sharedHalPlatform
84+
unzip sharedUtilPlatform.zip -d sharedUtilPlatform
85+
unzip staticHalPlatform.zip -d staticHalPlatform
86+
unzip staticUtilPlatform.zip -d staticUtilPlatform
87+
mkdir -p CANBridge-artifacts/static
88+
mkdir -p CANBridge-artifacts/shared
89+
90+
# Put release files together in one directory based on platform
91+
- name: Create Artifact
92+
run: |
93+
mkdir -p CANBridge-artifacts
94+
if [[ "${{ matrix.platform-type }}" == "windowsx86-64" ]]; then
95+
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.dll CANBridge-artifacts/shared/
96+
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/shared/
97+
cp sharedHalPlatform/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/shared/
98+
cp sharedHalPlatform/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/shared/
99+
cp sharedUtilPlatform/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/shared/
100+
cp sharedUtilPlatform/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/shared/
101+
102+
cp build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/static/
103+
cp staticHalPlatform/windows/x86-64/static/wpiHal.lib CANBridge-artifacts/static/
104+
cp staticUtilPlatform/windows/x86-64/static/wpiutil.lib CANBridge-artifacts/static/
105+
elif [[ "${{ matrix.platform-type }}" == "linuxx86-64" ]]; then
106+
cp build/libs/cANBridge/shared/linuxx86-64/release/libCANBridge.so CANBridge-artifacts/shared/
107+
cp sharedHalPlatform/linux/x86-64/shared/libwpiHal.so CANBridge-artifacts/shared/
108+
cp sharedUtilPlatform/linux/x86-64/shared/libwpiutil.so CANBridge-artifacts/shared/
109+
110+
cp build/libs/cANBridge/static/linuxx86-64/release/libCANBridge.a CANBridge-artifacts/static/
111+
cp staticHalPlatform/linux/x86-64/static/libwpiHal.a CANBridge-artifacts/static/
112+
cp staticUtilPlatform/linux/x86-64/static/libwpiutil.a CANBridge-artifacts/static/
113+
elif [[ "${{ matrix.platform-type }}" == "osxuniversal" ]]; then
114+
cp build/libs/cANBridge/shared/osxuniversal/release/libCANBridge.dylib CANBridge-artifacts/shared/
115+
cp sharedHalPlatform/osx/universal/shared/libwpiHal.dylib CANBridge-artifacts/shared/
116+
cp sharedUtilPlatform/osx/universal/shared/libwpiutil.dylib CANBridge-artifacts/shared
117+
118+
cp build/libs/cANBridge/static/osxuniversal/release/libCANBridge.a CANBridge-artifacts/static/
119+
cp staticHalPlatform/osx/universal/static/libwpiHal.a CANBridge-artifacts/static/
120+
cp staticUtilPlatform/osx/universal/static/libwpiutil.a CANBridge-artifacts/static/
121+
elif [[ "${{ matrix.platform-type }}" == "linuxarm32" || "${{ matrix.platform-type }}" == "linuxarm64" ]]; then
122+
cp build/libs/cANBridge/shared/release/libCANBridge.so CANBridge-artifacts/shared/libCANBridge.so
123+
cp sharedHalPlatform/linux/${{ matrix.arch }}/shared/libwpiHal.so CANBridge-artifacts/shared/libwpiHal.so
124+
cp sharedUtilPlatform/linux/${{ matrix.arch }}/shared/libwpiutil.so CANBridge-artifacts/shared/libwpiutil.so
125+
126+
cp build/libs/cANBridge/static/release/libCANBridge.a CANBridge-artifacts/static/libCANBridge.a
127+
cp staticHalPlatform/linux/${{ matrix.arch }}/static/libwpiHal.a CANBridge-artifacts/static/libwpiHal.a
128+
cp staticUtilPlatform/linux/${{ matrix.arch }}/static/libwpiutil.a CANBridge-artifacts/static/libwpiutil.a
129+
fi
130+
131+
# Upload build artifact
132+
- name: Upload build artifact
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: CANBridge-${{ matrix.platform-type }}-${{ github.sha}}
136+
path: CANBridge-artifacts/
137+
138+
# Upload combined headers for WPILib from HAL and WPIUtil
139+
wpi-headers:
140+
runs-on: ubuntu-latest
141+
name: "WPILib Headers"
142+
steps:
143+
- name: Checkout
144+
uses: actions/checkout@v4
145+
with:
146+
ref: ${{ github.sha }}
147+
- name: Download WPILib HAL artifacts and headers
148+
run : |
149+
halVersion=$(cat wpiHalVersion.txt)
150+
50151
halHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-headers.zip
51-
utilWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-windowsx86-64.zip
52152
utilHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-headers.zip
53-
curl -L -o halWindows.zip "$halWindowsUrl"
153+
54154
curl -L -o halHeaders.zip "$halHeadersUrl"
55-
curl -L -o utilWindows.zip "$utilWindowsUrl"
56155
curl -L -o utilHeaders.zip "$utilHeadersUrl"
57-
unzip halWindows.zip -d halWindows
156+
157+
- name: Unzip WPILib HAL artifacts and headers
158+
run: |
58159
unzip halHeaders.zip -d halHeaders
59-
unzip utilWindows.zip -d utilWindows
60160
unzip utilHeaders.zip -d utilHeaders
61161
62-
# Gather all of the the needed headers
162+
- name: Gather all needed headers
163+
run: |
63164
mkdir headers-for-artifact
64165
cp -r halHeaders/hal headers-for-artifact
65166
cp -r utilHeaders/wpi headers-for-artifact
66167
cp -r src/main/native/include/* headers-for-artifact
67168
68-
# Zip the needed headers and put them in the appropriate location for artifact upload
69-
mkdir -p CANBridge-artifacts
70-
7z a CANBridge-artifacts/headers.zip ./headers-for-artifact/*
71-
72-
# Put release files together in one directory
73-
- name: Create Artifact
74-
run: |
75-
mkdir -p CANBridge-artifacts
76-
cp build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib
77-
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.dll CANBridge-artifacts/CANBridge.dll
78-
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib
79-
cp halWindows/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/wpiHal.dll
80-
cp halWindows/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/wpiHal.lib
81-
cp utilWindows/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/wpiutil.dll
82-
cp utilWindows/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/wpiutil.lib
83-
84169
# Upload build artifact
85170
- name: Upload build artifact
86-
uses: actions/upload-artifact@v3
171+
uses: actions/upload-artifact@v4
87172
with:
88-
name: CANBridge-${{ github.sha }}
89-
path: CANBridge-artifacts/
173+
path: headers-for-artifact
174+
name: headers
175+
176+
# Upload version file, used for versioning
177+
version:
178+
runs-on: ubuntu-latest
179+
name: "Version"
180+
steps:
181+
- name: Checkout
182+
uses: actions/checkout@v4
183+
with:
184+
ref: ${{ github.sha }}
185+
186+
- name: Setup Java
187+
uses: actions/setup-java@v4
188+
with:
189+
distribution: 'zulu'
190+
java-version: 11
191+
192+
- name: Setup Gradle
193+
uses: gradle/actions/setup-gradle@v4
194+
195+
- name: Build
196+
run: |
197+
./gradlew outputVersions -PreleaseMode
90198
91-
# Upload version.txt
92-
- name: Upload version artifact
93-
uses: actions/upload-artifact@v3
199+
- name: Upload build artifact
200+
uses: actions/upload-artifact@v4
94201
with:
95202
name: version
96203
path: build/allOutputs/version.txt

.github/workflows/release.yml

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,86 @@ name: Create release
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- 'v**'
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: false
714

815
defaults:
916
run:
1017
shell: bash
1118

1219
jobs:
13-
check-versions:
20+
# Checks previous build workflow and gets the version from publish.gradle
21+
check-build:
22+
name: Check build and publish versions
1423
runs-on: ubuntu-latest
1524
outputs:
1625
TAG_NAME: ${{ env.TAG_NAME }}
1726
VERSION: ${{ steps.get_version.outputs.version }}
1827
steps:
19-
- name: Wait for build to finish
20-
uses: lewagon/[email protected].1
28+
- name: Wait for build workflow to finish
29+
uses: lewagon/[email protected].4
2130
with:
2231
ref: ${{ github.ref }}
23-
check-name: 'build-windows64'
32+
check-regexp: 'Build|WPILib Headers|Version'
2433
repo-token: ${{ secrets.GITHUB_TOKEN }}
2534
wait-interval: 10
26-
- name: Get tag name
27-
run: |
28-
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
2935

3036
# Download artifacts from build workflow
3137
- name: Download workflow artifacts
32-
uses: dawidd6/action-download-artifact@v2
38+
uses: dawidd6/action-download-artifact@v6
3339
with:
3440
workflow: build.yml
3541
commit: ${{ github.sha }}
3642
path: '.'
3743

3844
# Get publish.gradle version
3945
- name: Get publish.gradle version
40-
id: get_version
46+
id: get-version
4147
run: |
4248
echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT
4349
echo "expectedTagName=v$(cat version/version.txt)" >> $GITHUB_OUTPUT
4450
45-
# Check publish.gradle version
46-
- name: publish.gradle version check FAILED
47-
if: ${{ steps.get_version.outputs.expectedTagName != env.TAG_NAME }}
51+
# Check if the publish.gradle version matches the tag name
52+
- name: Check version
4853
run: |
49-
echo Tag name: ${{ env.TAG_NAME }}
50-
echo publish.gradle version: ${{ steps.get_version.outputs.version }}
51-
exit 1
54+
if [[ "${{ steps.get-version.outputs.expectedTagName }}" != "${{ env.TAG_NAME }}" ]]; then
55+
echo "Version mismatch: ${{ steps.get-version.outputs.expectedTagName }} != ${{ env.TAG_NAME }}"
56+
exit 1
57+
fi
5258
59+
# Creates a release draft with the artifacts from the build workflow
5360
prepare-release:
61+
name: Prepare release
5462
runs-on: ubuntu-latest
55-
needs: check-versions
63+
needs: check-build
5664
steps:
5765
# Download API, docs, and version.txt
5866
- name: Download workflow artifacts
59-
uses: dawidd6/action-download-artifact@v2
67+
uses: dawidd6/action-download-artifact@v6
6068
with:
6169
workflow: build.yml
6270
commit: ${{ github.sha }}
6371
path: '.'
72+
skip_unpack: true
73+
74+
# This step is to check what files are downloaded and how they are structured, as well as binary sizes for releases
75+
- name: List files
76+
run: |
77+
ls -Rlh
6478
6579
# Create new release draft
6680
- name: Create release
67-
id: create_release
68-
env:
69-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70-
run: |
71-
VERSION=${{ needs.check-versions.outputs.version }}
72-
TAG=v$VERSION
73-
ls --recursive -l
74-
gh release create $TAG CANBridge-${{ github.sha }}/* --repo $GITHUB_REPOSITORY --draft --title "Version $VERSION"
81+
uses: softprops/action-gh-release@v2
82+
with:
83+
draft: true
84+
generate_release_notes: true
85+
tag_name: v${{ steps.get-version.outputs.version }}
86+
name: Version ${{ steps.get-version.outputs.version }}
87+
files: |
88+
**/**

config.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ nativeUtils {
88
// When updating WPILib, be sure to also update wpiHalVersion.txt
99
wpiVersion = "2023.+"
1010
niLibVersion = "2023.3.0"
11-
googleTestVersion = "1.11.0-3"
11+
googleTestVersion = "1.11.0-4"
1212
}
1313
}
1414
}

gradlew

100644100755
File mode changed.

src/main/native/cpp/CANBridge.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
#include "rev/Drivers/CandleWinUSB/CandleWinUSBDriver.h"
4444
#endif
4545

46-
#include "rev/Drivers/SerialPort/SerialDriver.h"
47-
4846
#include <hal/simulation/CanData.h>
4947
#include <hal/CAN.h>
5048

@@ -61,7 +59,6 @@ static const std::vector<rev::usb::CANDriver*> CANDriverList = {
6159
#ifdef _WIN32
6260
new rev::usb::CandleWinUSBDriver(),
6361
#endif
64-
new rev::usb::SerialDriver()
6562
};
6663

6764
static std::vector<std::pair<std::unique_ptr<rev::usb::CANDevice>, rev::usb::CANBridge_CANFilter>> CANDeviceList = {};

0 commit comments

Comments
 (0)