Skip to content

Commit 82363f7

Browse files
committed
add CI workflow
1 parent 733c6cd commit 82363f7

7 files changed

Lines changed: 169 additions & 56 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: CMake on multiple platforms
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
15+
fail-fast: false
16+
17+
# Set up a matrix to run the following 3 configurations:
18+
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
19+
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
20+
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
21+
#
22+
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
23+
matrix:
24+
os: [ubuntu-latest, windows-latest]
25+
build_type: [Release]
26+
c_compiler: [gcc, clang, cl]
27+
include:
28+
- os: windows-latest
29+
c_compiler: cl
30+
cpp_compiler: cl
31+
- os: ubuntu-latest
32+
c_compiler: gcc
33+
cpp_compiler: g++
34+
- os: ubuntu-latest
35+
c_compiler: clang
36+
cpp_compiler: clang++
37+
exclude:
38+
- os: windows-latest
39+
c_compiler: gcc
40+
- os: windows-latest
41+
c_compiler: clang
42+
- os: ubuntu-latest
43+
c_compiler: cl
44+
45+
env:
46+
CI_COMPILER: ${{ matrix.c_compiler }}
47+
QT_VERSION: '6.8.0'
48+
QT_HOST: ${{ matrix.os == 'windows-latest' && 'windows' || 'linux' }}
49+
QT_ARCH: ${{ matrix.os == 'windows-latest' && 'win64_msvc2022_64' || 'linux_gcc_64' }}
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
with:
54+
submodules: 'recursive'
55+
56+
- name: Set reusable strings
57+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
58+
id: strings
59+
shell: bash
60+
run: |
61+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
62+
63+
- name: Create Qt dir on Linux and install deps
64+
if: matrix.os != 'windows-latest'
65+
run: |
66+
sudo mkdir /Qt
67+
sudo chmod 777 /Qt
68+
sudo add-apt-repository universe
69+
sudo apt install libfuse2
70+
71+
- name: Install Qt
72+
uses: jurplel/install-qt-action@v4
73+
with:
74+
version: ${{ env.QT_VERSION }}
75+
host: ${{ env.QT_HOST }}
76+
target: desktop
77+
arch: ${{ env.QT_ARCH }}
78+
#dir: ${{ runner.temp }}
79+
dir: '/'
80+
setup-python: false
81+
82+
- name: Fix env vars if needed
83+
uses: actions/github-script@v7
84+
with:
85+
script: |
86+
if (process.env.QT_ROOT_DIR) {
87+
core.exportVariable('QT_ROOT_DIR', process.env.QT_ROOT_DIR.replace(/[/\\]bin[/\\]qmake[^/\\]*/i, ""));
88+
core.exportVariable('Qt6_DIR', process.env.QT_ROOT_DIR + "/lib/cmake/Qt6");
89+
core.addPath(process.env.QT_ROOT_DIR + "/bin");
90+
}
91+
if (process.env.QT_PLUGIN_PATH)
92+
core.exportVariable('QT_PLUGIN_PATH', process.env.QT_PLUGIN_PATH.replace(/[/\\]bin[/\\]qmake[^/\\]*/i, ""));
93+
if (process.env.QML2_IMPORT_PATH)
94+
core.exportVariable('QML2_IMPORT_PATH', process.env.QML2_IMPORT_PATH.replace(/[/\\]bin[/\\]qmake[^/\\]*/i, ""));
95+
96+
- name: Configure CMake
97+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
98+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
99+
run: >
100+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
101+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
102+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
103+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
104+
-DCMAKE_PREFIX_PATH:PATH="${{ env.QT_ROOT_DIR }}"
105+
-S ${{ github.workspace }}
106+
107+
- name: Build
108+
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
109+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
110+
111+
- name: Upload build artifacts
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: build-${{ matrix.c_compiler }}-${{ matrix.os }}
115+
path: build/
116+
117+
- name: Pack
118+
shell: pwsh
119+
run: ./ci/pack.ps1
120+
121+
- name: Upload package artifacts
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: package-${{ matrix.c_compiler }}-${{ matrix.os }}
125+
path: |
126+
build/package/
127+
build/*.7z

CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ if(MSVC)
1616
endif()
1717

1818
option(UNCSO2_USE_LTO "Use 'Link Time Optimizations'" ON)
19-
option(UNCSO2_USE_CLANG_FSAPI "Use libc++fs when available" OFF)
2019

2120
set(UNCSO2_ROOT_DIR "${PROJECT_SOURCE_DIR}")
2221
set(UNCSO2_LIBS_DIR "${UNCSO2_ROOT_DIR}/external")
@@ -63,11 +62,6 @@ endif()
6362
#
6463
# find dependencies
6564
#
66-
if(UNCSO2_USE_CLANG_FSAPI)
67-
set(PKG_USE_CLANG_FSAPI
68-
TRUE
69-
CACHE BOOL "" FORCE)
70-
endif()
7165

7266
add_subdirectory("libuncso2")
7367

@@ -241,14 +235,6 @@ target_include_directories(uc2 PRIVATE ${UNCSO2_GENERATED_DIR})
241235
#
242236
target_include_directories(uc2 PRIVATE "${UNCSO2_LIB_GSL_DIR}/include")
243237

244-
if(UNCSO2_USE_CLANG_FSAPI)
245-
message(STATUS "uc2: Using libc++fs")
246-
target_link_libraries(uc2 c++fs)
247-
elseif(NOT MSVC)
248-
message(STATUS "uc2: Using stdlibc++fs")
249-
target_link_libraries(uc2 stdc++fs)
250-
endif()
251-
252238
# link libuncso2
253239
target_include_directories(uc2 PRIVATE ${PKG_INCLUDE_DIR})
254240
target_link_libraries(uc2 uncso2)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Those regions are: South Korea, China, Taiwan and Japan.
3333
## Building
3434

3535
### Requirements
36+
3637
- [CMake](https://cmake.org/download/) (must be in PATH)
3738
- [Qt 6.8](https://www.qt.io/download)
3839
- A C++20 compile.
@@ -41,7 +42,7 @@ Those regions are: South Korea, China, Taiwan and Japan.
4142

4243
Visual Studio nowadays has built-in integration for CMake projects.
4344

44-
1. File -> Open -> CMake...
45+
1. File -> Open -> CMake... -> Select CMakeLists.txt
4546

4647
2. Build -> Build All
4748

ci/pack.ps1

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ function CreateDirectory {
33
New-Item -ItemType Directory -Path $newDirectory
44
}
55

6-
$curBuildCombo = $env:BUILD_COMBO
7-
$curConfig = $env:CONFIGURATION
6+
#$curBuildCombo = $env:BUILD_COMBO
7+
#$curConfig = $env:CONFIGURATION
8+
$curCompiler = $env:CI_COMPILER
89

910
# only package on Release builds, but don't error out
10-
if ($curConfig -ne 'Release') {
11-
Write-Host 'Non release build detected, exiting packaging script...'
12-
exit 0
13-
}
11+
#if ($curConfig -ne 'Release') {
12+
# Write-Host 'Non release build detected, exiting packaging script...'
13+
# exit 0
14+
#}
1415

15-
$isGccBuild = $curBuildCombo -eq 'linux-gcc'
16-
$isLinuxClangBuild = $curBuildCombo -eq 'linux-clang'
17-
$isMingwBuild = $curBuildCombo -eq 'windows-mingw'
18-
$isMsvcBuild = $curBuildCombo -eq 'windows-msvc'
16+
$isGccBuild = $curCompiler -eq 'gcc'
17+
$isClangBuild = $curCompiler -eq 'clang'
18+
#$isMingwBuild = $curBuildCombo -eq 'windows-mingw'
19+
#$isMsvcBuild = $curBuildCombo -eq 'windows-msvc'
20+
$qtVersion = if ($env:QT_VERSION) { $env:QT_VERSION } else { "6.8.0" };
1921

2022
Write-Host "Running packaging script..."
2123
Write-Host "Current setup build combo is: $curBuildCombo"
@@ -28,7 +30,7 @@ if ($isLinux) {
2830
Copy-Item ./build/libuncso2/libuncso2.so* -Destination ./build/package/
2931

3032
# copy libcryptopp to the package dir
31-
Copy-Item ./build/libuncso2/external/cryptopp/libcryptopp.so* -Destination ./build/package/
33+
#Copy-Item ./build/libuncso2/external/cryptopp/libcryptopp.so* -Destination ./build/package/
3234

3335
# copy AppImage prebuilt files
3436
Copy-Item ./appimage/* -Destination ./build/package/
@@ -38,10 +40,10 @@ if ($isLinux) {
3840

3941
}
4042
elseif ($isWindows) {
41-
if ($isMingwBuild) {
42-
# copy crypto++ to the package dir
43-
Copy-Item ./build/libuncso2/external/cryptopp/libcryptopp.dll -Destination ./build/package/
44-
}
43+
#if ($isMingwBuild) {
44+
# # copy crypto++ to the package dir
45+
# Copy-Item ./build/libuncso2/external/cryptopp/libcryptopp.dll -Destination ./build/package/
46+
#}
4547

4648
# copy libuncso2 to the package dir
4749
Copy-Item ./build/libuncso2/*uncso2.dll -Destination ./build/package/
@@ -81,7 +83,7 @@ if ($isLinux) {
8183
if ($isGccBuild) {
8284
Move-Item *.AppImage -Destination "UnCSO2-$versionStr-linux64_gcc.AppImage"
8385
}
84-
elseif ($isLinuxClangBuild) {
86+
elseif ($isClangBuild) {
8587
Move-Item *.AppImage -Destination "UnCSO2-$versionStr-linux64_clang.AppImage"
8688
}
8789

@@ -90,37 +92,33 @@ if ($isLinux) {
9092
elseif ($isWindows) {
9193
$windeployBin = ''
9294

93-
if ($isMingwBuild) {
94-
$windeployBin = 'C:\Qt\5.14\mingw73_64\bin\windeployqt.exe'
95-
}
96-
elseif ($isMsvcBuild) {
97-
$windeployBin = 'C:\Qt\5.14\msvc2017_64\bin\windeployqt.exe'
95+
if ($env:QT_ROOT_DIR) {
96+
$windeployBin = "$env:QT_ROOT_DIR\bin\windeployqt.exe"
9897
}
9998
else {
100-
Write-Error 'Unknown build combo detected.'
101-
exit 1
99+
$windeployBin = "C:\Qt\$qtVersion\msvc2022_64\bin\windeployqt.exe"
102100
}
103101

104-
if ($curConfig -eq 'Release') {
105-
if ($isMingwBuild) {
106-
& $windeployBin ./uc2.exe
107-
}
108-
else {
102+
#if ($curConfig -eq 'Release') {
103+
# if ($isMingwBuild) {
104+
# & $windeployBin ./uc2.exe
105+
# }
106+
# else {
109107
& $windeployBin --release ./uc2.exe
110-
}
111-
}
112-
else {
113-
& $windeployBin ./uc2.exe
114-
}
108+
# }
109+
#}
110+
#else {
111+
# & $windeployBin ./uc2.exe
112+
#}
115113

116114
Pop-Location
117115

118-
if ($isMingwBuild) {
119-
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=64m -ms=on "UnCSO2-$versionStr-win64_mingw.7z" ./package/*
120-
}
121-
elseif ($isMsvcBuild) {
116+
#if ($isMingwBuild) {
117+
# 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=64m -ms=on "UnCSO2-$versionStr-win64_mingw.7z" ./package/*
118+
#}
119+
#elseif ($isMsvcBuild) {
122120
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=64m -ms=on "UnCSO2-$versionStr-win64_msvc.7z" ./package/*
123-
}
121+
#}
124122
}
125123

126124
Pop-Location

ci/setup.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function SetupVsToolsPath {
22
# from https://allen-mack.blogspot.com/2008/03/replace-visual-studio-command-prompt.html
33

4-
Push-Location 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build'
4+
Push-Location 'C:\Program Files\Microsoft Visual Studio\2022'
5+
Push-Location '.\Community\VC\Auxiliary\Build'
56

67
cmd /c "vcvars64.bat&set" |
78
ForEach-Object {

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.7
1+
2.1.0

0 commit comments

Comments
 (0)