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

Create cmake-multi-platform.yml #39

Merged
5 commits merged into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .github/patches/No-Werror.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/cmake/modules/CompileWarnings.cmake b/cmake/modules/CompileWarnings.cmake
index 93b35b8abf..bf00ad1d3a 100644
--- a/cmake/modules/CompileWarnings.cmake
+++ b/cmake/modules/CompileWarnings.cmake
@@ -1,6 +1,6 @@
macro(wpilib_target_warnings target)
if(NOT MSVC)
- target_compile_options(${target} PRIVATE -Wall -pedantic -Wextra -Werror -Wno-unused-parameter ${WPILIB_TARGET_WARNINGS})
+ target_compile_options(${target} PRIVATE -Wall -pedantic -Wextra -Wno-unused-parameter ${WPILIB_TARGET_WARNINGS})
else()
target_compile_options(${target} PRIVATE /wd4146 /wd4244 /wd4251 /wd4267 /WX /D_CRT_SECURE_NO_WARNINGS ${WPILIB_TARGET_WARNINGS})
endif()
300 changes: 300 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

workflow_call:
inputs:
build_type:
description: Type of build (Debug, Release, RelWithDebInfo, MinSizeRel)
type: string
default: Debug

jobs:
build:
strategy:
fail-fast: false
matrix:
include:

- os: ubuntu-20.04
qt_host: linux
qt_version: '6.6.0'
qt_modules: 'qt6-multimedia-dev'

runs-on: ${{ matrix.os }}

env:
INSTALL_DIR: "install"
INSTALL_APPIMAGE_DIR: "install-appdir"
BUILD_DIR: "build"
VERSION: "0.9.0"

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: 'Install Qt 6.6.0'
if: runner.os == 'Linux'
uses: jurplel/[email protected]
with:
version: 6.6.0
modules: qtmultimedia

- name: 'Checkout wpilib'
uses: actions/checkout@v4
with:
repository: 'wpilibsuite/allwpilib'
ref: '9b8011aa67e30f150862545758056ff4d0cc0eac' # MAY want 2023
path: 'allwpilib'

- name: 'Prepare ntcore'
run: |
cd allwpilib
git apply ../.github/patches/No-Werror.patch
cd ..

- name: 'Install Python Dependencies (Linux)'
if: runner.os == 'Linux'
run: |
pip install jinja2

- name: 'Build ntcore (Linux)'
if: runner.os == 'Linux'
run: |
sudo apt-get install libprotobuf-dev libprotobuf17 libstdc++-10-dev gcc-10 ninja-build
cmake -B wpilib_build -S "allwpilib" \
-DCMAKE_INSTALL_PREFIX='/usr' \
-DUSE_SYSTEM_EIGEN=OFF \
-DUSE_SYSTEM_FMTLIB=OFF \
-DWITH_JAVA=OFF \
-DWITH_CSCORE=OFF \
-DWITH_NTCORE=ON \
-DWITH_WPIMATH=OFF \
-DWITH_WPILIB=OFF \
-DWITH_TESTS=OFF \
-DWITH_GUI=OFF \
-DWITH_SIMULATION_MODULES=OFF \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
-Wno-dev
cmake --build wpilib_build --parallel $(nproc)
sudo cmake --install wpilib_build

- name: Prepare AppImage (Linux)
if: runner.os == 'Linux'
run: |
wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage"
wget "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"

- name: Configure CMake (Linux)
if: runner.os == 'Linux'
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/g++-10

- name: Build
run: |
cmake --build ${{ env.BUILD_DIR }} --parallel $(nproc)

# - name: Test
# working-directory: ${{ steps.strings.outputs.build-output-dir }}
# # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest --build-config ${{ matrix.build_type }}

- name: Package (Linux)
if: runner.os == 'Linux'
run: |
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }}

cd ${{ env.INSTALL_DIR }}
tar --owner root --group root -czf ../QFRCDashboard.tar.gz *

- name: Package AppImage (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get install libxcb-cursor-dev libxcb-cursor0
mkdir -p ${{ env.INSTALL_APPIMAGE_DIR}}/usr/{lib,bin}
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr

export OUTPUT="QFRCDashboard-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage"

chmod +x linuxdeploy-*.AppImage

mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines

cp -r /home/runner/work/QFRCDashboard/Qt/${{ matrix.qt_version }}/gcc_64/plugins/iconengines/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines

cp /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/
cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}//usr/lib/

./linuxdeploy-x86_64.AppImage --appdir ${{ env.INSTALL_APPIMAGE_DIR }} --output appimage --plugin qt

- name: Upload portable tarball (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: QFRCDashboard-${{ runner.os }}-Binary-${{ env.VERSION }}-${{ inputs.build_type }}
path: QFRCDashboard.tar.gz

- name: Upload system dir (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: QFRCDashboard-${{ runner.os }}-System-${{ env.VERSION }}-${{ inputs.build_type }}
path: ${{ env.INSTALL_APPIMAGE_DIR }}/**

- name: Upload AppImage (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: QFRCDashboard-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
path: QFRCDashboard-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage


build-windows:
name: "Build - Windows"
runs-on: windows-2022

env:
VERSION: "0.9.0"
BUILD_WIN_DIR: "winbuild"
INSTALL_WIN_DIR: "install-win"
NTCORE_INSTALL_DIR: "install-ntcore"
PROTOBUF_INSTALL_DIR: "install-protobuf"

steps:
- uses: ilammy/msvc-dev-cmd@v1

- name: Cache vcpkg
uses: actions/[email protected]
with:
path: allwpilib/vcpkg

- name: Install CMake
uses: lukka/[email protected]

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: 'Install Qt (Windows)'
uses: jurplel/[email protected]
with:
version: 6.6.0
modules: qtmultimedia

- name: Install jinja
run: |
python -m ensurepip
python -m pip install jinja2
dir ..\Qt\6.6.0\msvc2019_64\bin

- uses: actions/checkout@v3

- name: 'Checkout wpilib'
uses: actions/checkout@v4
with:
repository: 'wpilibsuite/allwpilib'
ref: '9b8011aa67e30f150862545758056ff4d0cc0eac' # MAY want 2023
path: 'allwpilib'

- name: Run vcpkg
uses: lukka/[email protected]
with:
vcpkgDirectory: ${{ runner.workspace }}/allwpilib/vcpkg
vcpkgGitCommitId: 78b61582c9e093fda56a01ebb654be15a0033897 # HEAD on 2023-08-6


- name: 'Prepare ntcore'
run: |
cd allwpilib
git apply ../.github/patches/No-Werror.patch
cd ..

- name: 'Configure ntcore CMake (Windows)'
run: |
cmake -S allwpilib -B win-nt-build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=OFF -DUSE_SYSTEM_FMTLIB=OFF -DUSE_SYSTEM_LIBUV=OFF -DUSE_SYSTEM_EIGEN=OFF -DWITH_CSCORE=OFF -DWITH_NTCORE=ON -DWITH_WPIMATH=OFF -DWITH_WPILIB=OFF -DWITH_TESTS=OFF -DWITH_GUI=OFF -DWITH_SIMULATION_MODULES=OFF -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/allwpilib/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }}
env:
SCCACHE_GHA_ENABLED: "true"

- name: 'Build ntcore (Windows)'
working-directory: win-nt-build
run: |
cmake --build . --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"

- name: 'Install ntcore (Windows)'
run: |
cmake --install win-nt-build --prefix ${{ env.NTCORE_INSTALL_DIR }}
env:
SCCACHE_GHA_ENABLED: "true"

- name: 'Checkout protobuf'
uses: actions/checkout@v4
with:
repository: 'protocolbuffers/protobuf'
# ref: 'v2024.1.1-beta-3' # MAY want 2023
path: 'protobuf'

- name: 'Prepare protobuf (Windows)'
working-directory: protobuf
run: |
git submodule update --init --recursive

- name: 'Configure protobuf CMake (Windows)'
run: |
cmake -S protobuf -B win-pb-build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_PROTOBUF_DIR }} -Dprotobuf_ALLOW_CCACHE=ON -Dprotobuf_BUILD_TESTS=OFF
env:
SCCACHE_GHA_ENABLED: "true"

- name: 'Build protobuf (Windows)'
working-directory: win-pb-build
run: |
cmake --build . --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"

- name: 'Install protobuf (Windows)'
run: |
cmake --install win-pb-build --prefix ${{ env.PROTOBUF_INSTALL_DIR }}
env:
SCCACHE_GHA_ENABLED: "true"

- name: 'Build (Windows)'
run: |
cmake -S . -B ${{ env.BUILD_WIN_DIR }} -Dntcore_ROOT=${{ env.NTCORE_INSTALL_DIR }} -DProtobuf_ROOT=${{ env.PROTOBUF_INSTALL_DIR }} -DCMAKE_CXX_FLAGS="/I${{ runner.workspace }}\QFRCDashboard\${{ env.NTCORE_INSTALL_DIR }}\include /MT" -G "Ninja" -DBUILD_SHARED_LIBS=OFF
cmake --build ${{ env.BUILD_WIN_DIR }} --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"

- name: Package (Windows)
shell: cmd
run: |
mkdir ${{ env.INSTALL_WIN_DIR }}
set PATH=%PATH%;"${{ runner.workspace }}\Qt\6.6.0\msvc2019_64\bin"
windeployqt ${{ env.BUILD_WIN_DIR }}\QFRCDashboard.exe --dir ${{ env.INSTALL_WIN_DIR }}
cp ${{ env.BUILD_WIN_DIR }}\QFRCDashboard.exe ${{ env.INSTALL_WIN_DIR }}


##
# UPLOAD BUILDS
##

- name: Upload binary zip (Windows, portable)
uses: actions/upload-artifact@v3
with:
name: QFRCDashboard-Windows-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
path: ${{ env.INSTALL_WIN_DIR }}/**
26 changes: 26 additions & 0 deletions .github/workflows/trigger_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build Application

on:
push:
branches-ignore:
- 'stable'
paths-ignore:
- '**.md'
- '**/LICENSE'
- '.github/ISSUE_TEMPLATE/**'
- '.markdownlint**'
pull_request:
paths-ignore:
- '**.md'
- '**/LICENSE'
- '.github/ISSUE_TEMPLATE/**'
- '.markdownlint**'
workflow_dispatch:

jobs:

build_debug:
name: Build Debug
uses: ./.github/workflows/build.yml
with:
build_type: Debug
Loading
Loading