Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CANBridge: Add support for Linux and macOS #29

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e1a8217
Made SerialDevice complie when linux
Moose1301 May 11, 2024
2fcc6c9
Fix compling on windows
Moose1301 May 11, 2024
cf8ec56
CI: Initial build config for macOS and Linux for both x86-64 and arm64
qwertychouskie Jun 11, 2024
b4234a7
Build: Disable warnings-as-errors
qwertychouskie Jun 11, 2024
72fa8d3
Add linker argument for IOKit framework on macOS universal builds
garrettsummerfi3ld Jun 12, 2024
2d3a57c
update build.yml for macosarm64
TBHGodPro Jun 14, 2024
7ba8b99
patch build gh-workflow for macosarm64
TBHGodPro Jun 14, 2024
306f141
Update artifact workflows, added macOS artifact creation
garrettsummerfi3ld Jun 14, 2024
833a167
Add Arm32, Arm64 builds, upload Linux artifacts
garrettsummerfi3ld Jun 15, 2024
5a4e90e
[ci-skip] Add name to CI jobs
garrettsummerfi3ld Jun 15, 2024
b0cb6df
Disable fail-fast, install 7z during Docker builds
garrettsummerfi3ld Jun 15, 2024
9e4ac8b
Separate step for 7zip installation
garrettsummerfi3ld Jun 15, 2024
ee6cee2
Enable verbose logging during build outputs on ARM builds
garrettsummerfi3ld Jun 15, 2024
42bf279
Finalize ARM builds and artifact packaging
garrettsummerfi3ld Jun 15, 2024
9ac8c1b
Fix incorrect directories for creating artifacts
garrettsummerfi3ld Jun 15, 2024
bc6df8b
Split steps apart for WPILib HAL archiving, update release.yml
garrettsummerfi3ld Jun 21, 2024
8288165
Update dependent actions
garrettsummerfi3ld Jun 21, 2024
cd3ac01
Merge pull request #3 from unofficial-rev-port/ci/artifact-uploads
garrettsummerfi3ld Jun 21, 2024
6cb092a
[ci skip] Updating release workflow to properly check for workflow re…
garrettsummerfi3ld Jun 21, 2024
8ea5baa
[ci skip] Update tags search release workflow
garrettsummerfi3ld Jun 21, 2024
c5dbaa0
Remove tag name
garrettsummerfi3ld Jun 21, 2024
f36d8b7
Add GITHUB_TOKEN to release workflow and permissions to write releases
garrettsummerfi3ld Jun 21, 2024
a547448
Fix broken check waiting for build to finish.
garrettsummerfi3ld Jun 21, 2024
77e0a8d
Shorten artifact names, skip unpacking for releases
garrettsummerfi3ld Jun 21, 2024
4f50436
[ci skip] Remove SHA on ARM builds for artifacts
garrettsummerfi3ld Jun 21, 2024
df26253
chore: Update WPILib HAL headers in release workflow
garrettsummerfi3ld Jun 22, 2024
4849e7b
chore: Fix missing directory in build artifacts
garrettsummerfi3ld Jun 22, 2024
22d7b1b
chore: Fix missing directory for build artifacts (again)
garrettsummerfi3ld Jun 22, 2024
f33c39c
Remove macOS ARM workflow
garrettsummerfi3ld Jun 24, 2024
8cd0385
fix: Un-nest the headers artifact
garrettsummerfi3ld Jul 1, 2024
9ee52d0
fix: Actually copy everything in `include` for `headers.zip`
garrettsummerfi3ld Jul 1, 2024
89f1c9d
Update `README.md`
garrettsummerfi3ld Jul 1, 2024
2680cd0
Attempt to fix runtime crash
qwertychouskie Jul 1, 2024
5ebb670
(hopefully) Fixup Windows build
qwertychouskie Jul 1, 2024
a8269d6
v2.3.5
qwertychouskie Jul 1, 2024
6188739
Serial: More debugging
qwertychouskie Jul 1, 2024
e5c47d5
Attempt to fix C++ exceptions on macOS
qwertychouskie Jul 1, 2024
16b913c
Attempt to fix C++ exceptions on macOS part 2
qwertychouskie Jul 1, 2024
7a2a655
Attempt to fix C++ exceptions on macOS part 3
qwertychouskie Jul 1, 2024
e5b0f8b
Attempt to fix C++ exceptions on macOS part 4: undo da changes
qwertychouskie Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 154 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,109 @@ defaults:
shell: bash

jobs:
build:
build-docker:
strategy:
fail-fast: false
matrix:
include:
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
name: LinuxARM64
build-options: "-Ponlylinuxarm64"
platform-type: linuxarm64
arch: arm64
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
name: LinuxARM32
build-options: "-Ponlylinuxarm32"
platform-type: linuxarm32
arch: arm32
runs-on: ubuntu-latest
name: "Build - ${{ matrix.name }}"
container: ${{ matrix.container }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11

- name: Build
run: |
./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode

- name: Download WPILib HAL artifacts and headers for ${{ matrix.platform-type }}
run : |
halVersion=$(cat wpiHalVersion.txt)

halPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
utilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}.zip

curl -o halPlatform.zip "$halPlatformUrl"
curl -o utilPlatform.zip "$utilPlatformUrl"

- name: Unzip WPILib HAL artifacts and headers
run: |
unzip halPlatform.zip -d halPlatform
unzip utilPlatform.zip -d utilPlatform
mkdir -p CANBridge-artifacts

# Put Linux ARM release files together in one directory
- name: Create Artifact
run: |
cp build/libs/cANBridge/static/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a
cp build/libs/cANBridge/shared/release/libCANBridge.so CANBridge-artifacts/libCANBridge.so
cp halPlatform/linux/${{ matrix.arch }}/shared/libwpiHal.so CANBridge-artifacts/libwpiHal.so
cp utilPlatform/linux/${{ matrix.arch }}/shared/libwpiutil.so CANBridge-artifacts/libwpiutil.so

# Upload build artifact
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: CANBridge-${{ matrix.platform-type }}
path: CANBridge-artifacts/

build-native:
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
container: ''
name: windows64
name: "build-${{ matrix.name }}"
name: Win64
build-options: ""
platform-type: windowsx86-64
- os: ubuntu-latest
container: ''
name: Linux64
platform-type: linuxx86-64
build-options: ""
- os: macos-latest
container: ''
name: macOS
platform-type: osxuniversal
build-options: ""
name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}

- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11

- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
.gradle
Expand All @@ -52,56 +129,92 @@ jobs:
run: |
./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode

- name: Download WPILib HAL artifacts and headers, gather all needed headers
- name: Download WPILib HAL artifacts and headers for ${{ matrix.platform-type }}
run : |
halVersion=$(cat wpiHalVersion.txt)

# Download WPILib artifacts from Artifactory
halWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-windowsx86-64.zip
halHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-headers.zip
utilWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-windowsx86-64.zip
utilHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-headers.zip
curl -o halWindows.zip "$halWindowsUrl"
curl -o halHeaders.zip "$halHeadersUrl"
curl -o utilWindows.zip "$utilWindowsUrl"
curl -o utilHeaders.zip "$utilHeadersUrl"
unzip halWindows.zip -d halWindows
unzip halHeaders.zip -d halHeaders
unzip utilWindows.zip -d utilWindows
unzip utilHeaders.zip -d utilHeaders
halPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
utilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}.zip

# Gather all of the the needed headers
mkdir headers-for-artifact
cp -r halHeaders/hal headers-for-artifact
cp -r utilHeaders/wpi headers-for-artifact
cp -r src/main/native/include/* headers-for-artifact
curl -o halPlatform.zip "$halPlatformUrl"
curl -o utilPlatform.zip "$utilPlatformUrl"

# Zip the needed headers and put them in the appropriate location for artifact upload
- name: Unzip WPILib HAL artifacts and headers
run: |
unzip halPlatform.zip -d halPlatform
unzip utilPlatform.zip -d utilPlatform
mkdir -p CANBridge-artifacts
7z a CANBridge-artifacts/headers.zip ./headers-for-artifact/*

# Put release files together in one directory
- name: Create Artifact
# Put Windows release files together in one directory
- name: Create Artifact (windows64)
if: matrix.platform-type == 'windowsx86-64'
run: |
mkdir -p CANBridge-artifacts
cp build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.dll CANBridge-artifacts/CANBridge.dll
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib
cp halWindows/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/wpiHal.dll
cp halWindows/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/wpiHal.lib
cp utilWindows/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/wpiutil.dll
cp utilWindows/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/wpiutil.lib
cp halPlatform/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/wpiHal.dll
cp halPlatform/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/wpiHal.lib
cp utilPlatform/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/wpiutil.dll
cp utilPlatform/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/wpiutil.lib

# Put Linux release files together in one directory
- name: Create Artifact (linux64)
if: matrix.platform-type == 'linuxx86-64'
run: |
cp build/libs/cANBridge/static/linuxx86-64/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a
cp build/libs/cANBridge/shared/linuxx86-64/release/libCANBridge.so CANBridge-artifacts/libCANBridge.so
cp halPlatform/linux/x86-64/shared/libwpiHal.so CANBridge-artifacts/libwpiHal.so
cp utilPlatform/linux/x86-64/shared/libwpiutil.so CANBridge-artifacts/libwpiutil.so

# Put macOS release files together in one directory
- name: Create Artifact (osxuniversal)
if: matrix.platform-type == 'osxuniversal'
run: |
cp build/libs/cANBridge/static/osxuniversal/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a
cp build/libs/cANBridge/shared/osxuniversal/release/libCANBridge.dylib CANBridge-artifacts/libCANBridge.dylib
cp halPlatform/osx/universal/shared/libwpiHal.dylib CANBridge-artifacts/libwpiHal.dylib
cp utilPlatform/osx/universal/shared/libwpiutil.dylib CANBridge-artifacts/libwpiutil.dylib

# Upload build artifact
- name: Upload build artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: CANBridge-${{ github.sha }}
name: CANBridge-${{ matrix.platform-type }}-${{ matrix.name }}
path: CANBridge-artifacts/

# Upload version.txt
- name: Upload version artifact
uses: actions/upload-artifact@v3
wpi-headers:
runs-on: ubuntu-latest
name: "WPILib Headers"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Download WPILib HAL artifacts and headers for linuxx86-64
run : |
halVersion=$(cat wpiHalVersion.txt)

halHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-headers.zip
utilHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-headers.zip

curl -o halHeaders.zip "$halHeadersUrl"
curl -o utilHeaders.zip "$utilHeadersUrl"

- name: Unzip WPILib HAL artifacts and headers
run: |
unzip halHeaders.zip -d halHeaders
unzip utilHeaders.zip -d utilHeaders

- name: Gather all needed headers
run: |
mkdir headers-for-artifact
cp -r halHeaders/hal headers-for-artifact
cp -r utilHeaders/wpi headers-for-artifact
cp -r src/main/native/include/* headers-for-artifact

# Upload build artifact
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: version
path: build/allOutputs/version.txt
path: headers-for-artifact
name: headers
50 changes: 24 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,70 @@ name: Create release
on:
push:
tags:
- 'v*'
- 'v**'

permissions:
contents: write

defaults:
run:
shell: bash

jobs:
check-versions:
name: Check build and publish versions
runs-on: ubuntu-latest
outputs:
TAG_NAME: ${{ env.TAG_NAME }}
VERSION: ${{ steps.get_version.outputs.version }}
steps:
- name: Wait for build to finish
uses: lewagon/[email protected].1
- name: Wait for build workflow to finish
uses: lewagon/[email protected].4
with:
ref: ${{ github.ref }}
check-name: 'build-windows64'
check-regexp: 'Build|WPILib Headers'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Get tag name
run: |
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

# Download artifacts from build workflow
- name: Download workflow artifacts
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
commit: ${{ github.sha }}
path: '.'

# Get publish.gradle version
- name: Get publish.gradle version
id: get_version
id: get-version
run: |
echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT
echo "expectedTagName=v$(cat version/version.txt)" >> $GITHUB_OUTPUT

# Check publish.gradle version
- name: publish.gradle version check FAILED
if: ${{ steps.get_version.outputs.expectedTagName != env.TAG_NAME }}
run: |
echo Tag name: ${{ env.TAG_NAME }}
echo publish.gradle version: ${{ steps.get_version.outputs.version }}
exit 1

prepare-release:
name: Prepare release
runs-on: ubuntu-latest
needs: check-versions
steps:
# Download API, docs, and version.txt
- name: Download workflow artifacts
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
commit: ${{ github.sha }}
path: '.'
skip_unpack: true

# This step is to check what files are downloaded and how they are structured, as well as binary sizes for releases
- name: List files
run: |
ls -Rlh

# Create new release draft
- name: Create release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ needs.check-versions.outputs.version }}
TAG=v$VERSION
ls --recursive -l
gh release create $TAG CANBridge-${{ github.sha }}/* --repo $GITHUB_REPOSITORY --draft --title "Version $VERSION"
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
files: |
**/**
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ bin/
# End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode

/docs/

#Intellji
.idea/
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"cctype": "cpp",
"concepts": "cpp"
},
"C_Cpp.default.configurationProvider": "vscode-wpilib"
"C_Cpp.default.configurationProvider": "vscode-wpilib",
"C_Cpp.errorSquiggles": "enabled"
}
4 changes: 3 additions & 1 deletion CANBridge.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
"list": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"xhash": "cpp"
"xhash": "cpp",
"stdlib.h": "c",
"candle.h": "c"
},
"java.configuration.updateBuildConfiguration": "disabled"
}
Expand Down
Loading