添加Github Actions (#38)

* Update win-build.yml

* Update build.ps1 and win-build.yml

* Use github actions prebuilt instead of manualy prebuilt

* Update build.ps1

* Update build.ps1

* Replace rtc submodule with 'fetch prebuilt'

* Update win-build.yml
This commit is contained in:
Zhennan Tu
2023-10-10 07:48:09 +08:00
committed by GitHub
parent 1d0f695a3a
commit cfdde6b1e9
16 changed files with 120 additions and 249 deletions

View File

@@ -1,10 +1,28 @@
name: Windows
# for test
on: workflow_dispatch
name: win-build
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: windows-2022
steps:
- name: Echo Test
run: |
echo "It works."
- name: Checkout
with:
submodules: true
uses: actions/checkout@v4
- name: Init MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '6.5.3'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
- name: Fetch prebuilt
run: ./build.ps1 prebuilt fetch
- name: Build lanthing-pc
run: ./build.ps1 build Release

4
.gitignore vendored
View File

@@ -37,12 +37,14 @@
/.vs
/build
/install
/third_party/prebuilt
/transport/rtc
CMakeSettings.json
options-user.cmake
# misc
draft.txt
/third_party/Video_Codec*
fonts/
icons/
.VSCodeCounter

33
.gitmodules vendored
View File

@@ -1,48 +1,15 @@
[submodule "third_party/g3log"]
path = third_party/g3log
url = https://github.com/KjellKod/g3log.git
[submodule "third_party/libuv"]
path = third_party/libuv
url = https://github.com/libuv/libuv.git
[submodule "third_party/protobuf"]
path = third_party/protobuf
url = https://github.com/protocolbuffers/protobuf.git
[submodule "third_party/utfcpp"]
path = third_party/utfcpp
url = https://github.com/nemtrif/utfcpp.git
[submodule "third_party/mbedtls"]
path = third_party/mbedtls
url = https://github.com/Mbed-TLS/mbedtls.git
[submodule "third_party/SDL"]
path = third_party/SDL
url = https://github.com/libsdl-org/SDL.git
[submodule "ltproto"]
path = ltproto
url = https://github.com/pjlt/ltproto.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
[submodule "third_party/breakpad"]
path = third_party/breakpad
url = https://github.com/google/breakpad.git
[submodule "third_party/ffmpeg"]
path = third_party/ffmpeg
url = https://github.com/pjlt/ffmpeg.git
[submodule "rtc"]
path = rtc
url = https://github.com/pjlt/rtc.git
[submodule "third_party/oneVPL"]
path = third_party/oneVPL
url = https://github.com/oneapi-src/oneVPL.git
[submodule "third_party/opus"]
path = third_party/opus
url = https://github.com/xiph/opus.git
[submodule "third_party/imgui"]
path = third_party/imgui
url = https://github.com/ocornut/imgui.git
[submodule "third_party/ViGEmClient"]
path = third_party/ViGEmClient
url = https://github.com/nefarius/ViGEmClient.git
[submodule "transport/rtc"]
path = transport/rtc
url = https://github.com/pjlt/rtc.git

View File

@@ -82,21 +82,21 @@ add_subdirectory(third_party/tomlplusplus)
add_subdirectory(third_party/utfcpp)
add_subdirectory(third_party/nvcodec)
add_subdirectory(third_party/amf)
add_subdirectory(third_party/ffmpeg)
add_subdirectory(third_party/prebuilt/ffmpeg)
add_subdirectory(third_party/breakpad_builder)
#add_subdirectory(third_party/lodepng)
#protobuf依赖absl
find_package(absl REQUIRED PATHS third_party/protobuf/build2/install/${THIRD_PARTY_BUILD_TYPE}/lib/cmake)
find_package(protobuf REQUIRED PATHS third_party/protobuf/build2/install/${THIRD_PARTY_BUILD_TYPE})
find_package(GTest REQUIRED PATHS third_party/googletest/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(g3log REQUIRED PATHS third_party/g3log/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(MbedTLS REQUIRED PATHS third_party/mbedtls/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(libuv REQUIRED PATHS third_party/libuv/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(SDL2 REQUIRED PATHS third_party/SDL/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(VPL REQUIRED PATHS third_party/oneVPL/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(Opus REQUIRED PATHS third_party/opus/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(ViGEmClient REQUIRED PATHS third_party/ViGEmClient/build/install/${THIRD_PARTY_BUILD_TYPE})
find_package(absl REQUIRED PATHS third_party/prebuilt/protobuf/${THIRD_PARTY_BUILD_TYPE}/lib/cmake)
find_package(protobuf REQUIRED PATHS third_party/prebuilt/protobuf/${THIRD_PARTY_BUILD_TYPE})
find_package(GTest REQUIRED PATHS third_party/prebuilt/googletest/${THIRD_PARTY_BUILD_TYPE})
find_package(g3log REQUIRED PATHS third_party/prebuilt/g3log/${THIRD_PARTY_BUILD_TYPE})
find_package(MbedTLS REQUIRED PATHS third_party/prebuilt/mbedtls/${THIRD_PARTY_BUILD_TYPE})
find_package(libuv REQUIRED PATHS third_party/prebuilt/libuv/${THIRD_PARTY_BUILD_TYPE})
find_package(SDL2 REQUIRED PATHS third_party/prebuilt/sdl/${THIRD_PARTY_BUILD_TYPE})
find_package(VPL REQUIRED PATHS third_party/prebuilt/onevpl/${THIRD_PARTY_BUILD_TYPE})
find_package(Opus REQUIRED PATHS third_party/prebuilt/opus/${THIRD_PARTY_BUILD_TYPE})
find_package(ViGEmClient REQUIRED PATHS third_party/prebuilt/vigemclient/${THIRD_PARTY_BUILD_TYPE})
# 依赖于SDL
add_subdirectory(third_party/imgui_builder)

269
build.ps1
View File

@@ -7,175 +7,21 @@ function exit_if_fail {
}
}
function build_protobuf() {
Write-Host -ForegroundColor Green building google-protobuf
Set-Location third_party/protobuf
New-Item -ItemType Directory -ErrorAction SilentlyContinue build2
Set-Location build2
Invoke-Expression "cmake ../ -DBUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=OFF"
Invoke-Expression "cmake --build . --config Debug"
Invoke-Expression "cmake --install . --config Debug --prefix install/Debug"
Invoke-Expression "cmake --build . --config Release"
Invoke-Expression "cmake --install . --config Release --prefix install/Release"
Set-Location $root_dir
}
function clear_protobuf {
Remove-Item -Force -Recurse third_party/protobuf/build2/*
exit_if_fail
}
function build_google_test() {
Write-Host -ForegroundColor Green building google-test
Set-Location third_party/googletest;
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake ../ -Dgtest_force_shared_crt=ON"
Invoke-Expression "cmake --build . --config Debug"
Invoke-Expression "cmake --install . --config Debug --prefix install/Debug"
Invoke-Expression "cmake --build . --config Release"
Invoke-Expression "cmake --install . --config Release --prefix install/Release"
Set-Location $root_dir
}
function clear_google_test() {
Remove-Item -Force -Recurse third_party/googletest/build/*
exit_if_fail
}
function build_mbedtls() {
Write-Host -ForegroundColor Green building MbedTLS
Set-Location third_party/mbedtls
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake .. -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF -DDISABLE_PACKAGE_CONFIG_AND_INSTALL=OFF"
Invoke-Expression "cmake --build . --config Debug"
Invoke-Expression "cmake --install . --config Debug --prefix install/Debug"
Invoke-Expression "cmake --build . --config Release"
Invoke-Expression "cmake --install . --config Release --prefix install/Release"
Set-Location $root_dir
}
function clear_mbedtls() {
Remove-Item -Force -Recurse third_party/mbedtls/build/*
exit_if_fail
}
function build_libuv() {
Write-Host -ForegroundColor Green building libuv
Set-Location third_party/libuv
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake .. -DLIBUV_BUILD_TESTS=OFF -DLIBUV_BUILD_BENCH=OFF"
Invoke-Expression "cmake --build . --config Debug"
Invoke-Expression "cmake --install . --config Debug --prefix install/Debug"
Invoke-Expression "cmake --build . --config Release"
Invoke-Expression "cmake --install . --config Release --prefix install/Release"
Set-Location $root_dir
}
function clear_libuv() {
Remove-Item -Force -Recurse third_party/libuv/build/*
exit_if_fail
}
function build_sdl() {
Write-Host -ForegroundColor Green building SDL
Set-Location third_party/SDL
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake .."
Invoke-Expression "cmake --build . --config Debug"
Invoke-Expression "cmake --install . --config Debug --prefix install/Debug"
Invoke-Expression "cmake --build . --config Release"
Invoke-Expression "cmake --install . --config Release --prefix install/Release"
Set-Location $root_dir
}
function clear_sdl() {
Remove-Item -Force -Recurse third_party/SDL/build/*
exit_if_fail
}
function build_onevpl() {
Write-Host -ForegroundColor Green building oneVPL
Set-Location third_party/oneVPL
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake .. -DBUILD_DEV=ON -DBUILD_DISPATCHER=ON -DBUILD_TOOLS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PREVIEW=OFF -DINSTALL_EXAMPLE_CODE=OFF -DBUILD_DISPATCHER_ONEVPL_EXPERIMENTAL=ON -DBUILD_TOOLS_ONEVPL_EXPERIMENTAL=OFF -DCMAKE_INSTALL_PREFIX=install/Debug"
Invoke-Expression "cmake --build . --config Debug --target install"
Invoke-Expression "cmake .. -DBUILD_DEV=ON -DBUILD_DISPATCHER=ON -DBUILD_TOOLS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PREVIEW=OFF -DINSTALL_EXAMPLE_CODE=OFF -DBUILD_DISPATCHER_ONEVPL_EXPERIMENTAL=ON -DBUILD_TOOLS_ONEVPL_EXPERIMENTAL=OFF -DCMAKE_INSTALL_PREFIX=install/Release"
Invoke-Expression "cmake --build . --config Release --target install"
Set-Location $root_dir
}
function clear_onevpl() {
Remove-Item -Force -Recurse third_party/oneVPL/build/*
exit_if_fail
}
function build_opus() {
Write-Host -ForegroundColor Green building opus
Set-Location third_party/opus
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake .. -DCMAKE_INSTALL_PREFIX=install/Debug"
Invoke-Expression "cmake --build . --config Debug --target install"
Invoke-Expression "cmake .. -DCMAKE_INSTALL_PREFIX=install/Release"
Invoke-Expression "cmake --build . --config Release --target install"
Set-Location $root_dir
}
function clear_opus() {
Remove-Item -Force -Recurse third_party/opus/build/*
exit_if_fail
}
function build_g3log() {
Write-Host -ForegroundColor Green building g3log
Set-Location third_party/g3log
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake .. -DUSE_DYNAMIC_LOGGING_LEVELS=ON -DENABLE_VECTORED_EXCEPTIONHANDLING=OFF -DENABLE_FATAL_SIGNALHANDLING=OFF -DCMAKE_INSTALL_PREFIX=install/Debug"
Invoke-Expression "cmake --build . --config Debug --target install"
Invoke-Expression "cmake .. -DUSE_DYNAMIC_LOGGING_LEVELS=ON -DENABLE_VECTORED_EXCEPTIONHANDLING=OFF -DENABLE_FATAL_SIGNALHANDLING=OFF -DCMAKE_INSTALL_PREFIX=install/Release"
Invoke-Expression "cmake --build . --config Release --target install"
Set-Location $root_dir
}
function build_vigemclient() {
Write-Host -ForegroundColor Green building ViGEmClient
Set-Location third_party/ViGEmClient
New-Item -ItemType Directory -ErrorAction SilentlyContinue build
Set-Location build
Invoke-Expression "cmake .. -DCMAKE_INSTALL_PREFIX=install/Debug -DViGEmClient_DLL=ON"
Invoke-Expression "cmake --build . --config Debug --target install"
Invoke-Expression "cmake .. -DCMAKE_INSTALL_PREFIX=install/Release -DViGEmClient_DLL=ON"
Invoke-Expression "cmake --build . --config Release --target install"
Set-Location $root_dir
}
function clear_vigemclient() {
Remove-Item -Force -Recurse third_party/ViGEmClient/build/*
exit_if_fail
}
function clear_g3log() {
Remove-Item -Force -Recurse third_party/g3log/build/*
exit_if_fail
}
function cmake_project() {
function cmake_configure() {
Invoke-Expression "cmake -B build/$script:build_type -DCMAKE_BUILD_TYPE=$script:build_type -DCMAKE_INSTALL_PREFIX=install/$script:build_type"
exit_if_fail
}
function cmake_build() {
Invoke-Expression "cmake --build build/$script:build_type --config $script:build_type --target install"
# Github Actions runners only have 2 cores
Invoke-Expression "cmake --build build/$script:build_type --parallel 2 --config $script:build_type --target install"
exit_if_fail
}
function cmake_clean() {
Invoke-Expression "cmake --build build/$script:build_type --target clean"
}
function check_build_type() {
if ($script:build_type -eq "debug") {
$script:build_type = "Debug"
@@ -184,42 +30,91 @@ function check_build_type() {
Write-Host -ForegroundColor Green Release
$script:build_type = "Release"
} else {
Write-Host -ForegroundColor Red 'Please specify build type [Debug|Release]'
Write-Host -ForegroundColor Red 'Please specify target type [ Debug | Release ]'
Exit -1
}
}
function rtc_fetch() {
$RtcUri = "https://github.com/numbaa/rtc-prebuilt/releases/download/v0.1.0/rtc.zip"
New-Item -ItemType Directory -ErrorAction SilentlyContinue transport/rtc
echo "Fetch $RtcUri"
Invoke-WebRequest -Uri $RtcUri -OutFile ./third_party/prebuilt/rtc.zip
Expand-Archive ./third_party/prebuilt/rtc.zip -DestinationPath ./transport/rtc
}
class BuiltLib {
[string]$Name
[string]$Uri
BuiltLib([string]$n, [string]$u) {
$this.Uri = $u
$this.Name = $n
}
}
function prebuilt_fetch() {
$libs = @(
[BuiltLib]::new("mbedtls", "https://github.com/numbaa/mbedtls-build/releases/download/v3.2.1-1/mbedtls.zip"),
[BuiltLib]::new("sdl", "https://github.com/numbaa/sdl-build/releases/download/v2.0.20-1/sdl.zip"),
[BuiltLib]::new("vigemclient", "https://github.com/numbaa/vigemclient-build/releases/download/v1/vigemclient.zip"),
[BuiltLib]::new("libuv", "https://github.com/numbaa/libuv-build/releases/download/v1.44.1-1/libuv.zip"),
[BuiltLib]::new("onevpl", "https://github.com/numbaa/onevpl-build/releases/download/v2023.3.1-1/onevpl.zip"),
[BuiltLib]::new("opus", "https://github.com/numbaa/opus-build/releases/download/v1.4-1/opus.zip"),
[BuiltLib]::new("g3log", "https://github.com/numbaa/g3log-build/releases/download/v2.3-1/g3log.zip"),
[BuiltLib]::new("googletest", "https://github.com/numbaa/googletest-build/releases/download/v1.13.0-1/googletest.zip"),
[BuiltLib]::new("ffmpeg", "https://github.com/numbaa/ffmpeg-build/releases/download/v5.1.3-3/ffmpeg.zip"),
[BuiltLib]::new("protobuf", "https://github.com/numbaa/protobuf-build/releases/download/v3.24.3-1/protobuf.zip")
)
New-Item -ItemType Directory -ErrorAction SilentlyContinue third_party/prebuilt
foreach ($lib in $libs) {
$LibName = $lib.Name
$LibUri = $lib.Uri
echo "Fetch $LibUri"
Invoke-WebRequest -Uri $lib.Uri -OutFile ./third_party/prebuilt/$LibName.zip
# exit_if_fail
echo "Unzip $LibName"
Expand-Archive ./third_party/prebuilt/$LibName.zip -DestinationPath ./third_party/prebuilt/$LibName
# exit_if_fail
}
rtc_fetch
}
function prebuilt_clean() {
Remove-Item -Force -Recurse third_party/prebuilt
}
function print_usage() {
Write-Host -ForegroundColor Green 'Usage: '
Write-Host -ForegroundColor Green ' build.ps1 prebuilt [ fetch | clean ]'
Write-Host -ForegroundColor Green ' build.ps1 build [ Debug | Release ]'
Write-Host -ForegroundColor Green ' build.ps1 clean [ Debug | Release ]'
Exit -1
}
$action = $args[0]
if ($action -eq "prebuild") {
build_protobuf
build_google_test
build_mbedtls
build_libuv
build_sdl
build_onevpl
build_opus
build_g3log
build_vigemclient
if ($action -eq "prebuilt") {
if ($args[1] -eq "fetch") {
prebuilt_fetch
} elseif ($args[1] -eq "clean") {
prebuilt_clean
} else {
Write-Host -ForegroundColor Red 'Please specify prebuilt type [ fetch | clean ]'
Exit -1
}
} elseif ($action -eq "clean") {
clear_protobuf
clear_google_test
clear_mbedtls
clear_libuv
clear_sdl
clear_onevpl
clear_opus
clear_g3log
clear_vigemclient
$script:build_type=$args[1]
check_build_type
cmake_clean
} elseif ($action -eq "build") {
$script:build_type=$args[1]
check_build_type
cmake_project
cmake_configure
cmake_build
} else {
Write-Host -ForegroundColor Green 'Usage: '
Write-Host -ForegroundColor Green ' build.ps1 [prebuild][build][clean]'
Write-Host -ForegroundColor Green ' build.ps1 prebuild'
Write-Host -ForegroundColor Green ' build.ps1 build [Debug|Release]'
Write-Host -ForegroundColor Green ' build.ps1 clean'
print_usage
}

1
third_party/SDL vendored

Submodule third_party/SDL deleted from b424665e08

Submodule third_party/ViGEmClient deleted from b66d02d57e

1
third_party/ffmpeg vendored

Submodule third_party/ffmpeg deleted from 79cbea78dd

1
third_party/g3log vendored

Submodule third_party/g3log deleted from 4f1224b9d5

Submodule third_party/googletest deleted from b796f7d446

1
third_party/libuv vendored

Submodule third_party/libuv deleted from e8b7eb6908

1
third_party/mbedtls vendored

Submodule third_party/mbedtls deleted from 869298bffe

1
third_party/oneVPL vendored

Submodule third_party/oneVPL deleted from ca5bbbb057

1
third_party/opus vendored

Submodule third_party/opus deleted from 82ac57d9f1

Submodule third_party/protobuf deleted from ee1355459c

Submodule transport/rtc deleted from 27ea169f3d