From cfdde6b1e9cbffebbbacec9ed35cf09f61f16d5d Mon Sep 17 00:00:00 2001 From: Zhennan Tu <17048267+numbaa@users.noreply.github.com> Date: Tue, 10 Oct 2023 07:48:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Github=20Actions=20(#38)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- .github/workflows/win-build.yml | 30 +++- .gitignore | 4 +- .gitmodules | 33 ---- CMakeLists.txt | 22 +-- build.ps1 | 269 ++++++++++---------------------- third_party/SDL | 1 - third_party/ViGEmClient | 1 - third_party/ffmpeg | 1 - third_party/g3log | 1 - third_party/googletest | 1 - third_party/libuv | 1 - third_party/mbedtls | 1 - third_party/oneVPL | 1 - third_party/opus | 1 - third_party/protobuf | 1 - transport/rtc | 1 - 16 files changed, 120 insertions(+), 249 deletions(-) delete mode 160000 third_party/SDL delete mode 160000 third_party/ViGEmClient delete mode 160000 third_party/ffmpeg delete mode 160000 third_party/g3log delete mode 160000 third_party/googletest delete mode 160000 third_party/libuv delete mode 160000 third_party/mbedtls delete mode 160000 third_party/oneVPL delete mode 160000 third_party/opus delete mode 160000 third_party/protobuf delete mode 160000 transport/rtc diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 2c73e5d..a168080 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -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." \ No newline at end of file + - 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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1e0c08f..e50c8e0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.gitmodules b/.gitmodules index d41cf9b..d334a58 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index fc277eb..56e6db7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/build.ps1 b/build.ps1 index b33462c..fd1ade0 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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 } \ No newline at end of file diff --git a/third_party/SDL b/third_party/SDL deleted file mode 160000 index b424665..0000000 --- a/third_party/SDL +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b424665e0899769b200231ba943353a5fee1b6b6 diff --git a/third_party/ViGEmClient b/third_party/ViGEmClient deleted file mode 160000 index b66d02d..0000000 --- a/third_party/ViGEmClient +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b66d02d57e32cc8595369c53418b843e958649b4 diff --git a/third_party/ffmpeg b/third_party/ffmpeg deleted file mode 160000 index 79cbea7..0000000 --- a/third_party/ffmpeg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 79cbea78ddc09b093abd2823b43bfa04bde9043c diff --git a/third_party/g3log b/third_party/g3log deleted file mode 160000 index 4f1224b..0000000 --- a/third_party/g3log +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4f1224b9d52d7bfe74fde2bf31f88733ce04d19d diff --git a/third_party/googletest b/third_party/googletest deleted file mode 160000 index b796f7d..0000000 --- a/third_party/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b796f7d44681514f58a683a3a71ff17c94edb0c1 diff --git a/third_party/libuv b/third_party/libuv deleted file mode 160000 index e8b7eb6..0000000 --- a/third_party/libuv +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e8b7eb6908a847ffbe6ab2eec7428e43a0aa53a2 diff --git a/third_party/mbedtls b/third_party/mbedtls deleted file mode 160000 index 869298b..0000000 --- a/third_party/mbedtls +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 869298bffeea13b205343361b7a7daf2b210e33d diff --git a/third_party/oneVPL b/third_party/oneVPL deleted file mode 160000 index ca5bbbb..0000000 --- a/third_party/oneVPL +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ca5bbbb057a6e84b103aca807612afb693ad046c diff --git a/third_party/opus b/third_party/opus deleted file mode 160000 index 82ac57d..0000000 --- a/third_party/opus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 82ac57d9f1aaf575800cf17373348e45b7ce6c0d diff --git a/third_party/protobuf b/third_party/protobuf deleted file mode 160000 index ee13554..0000000 --- a/third_party/protobuf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ee1355459c9ce7ffe264bc40cfdc7b7623d37e99 diff --git a/transport/rtc b/transport/rtc deleted file mode 160000 index 27ea169..0000000 --- a/transport/rtc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 27ea169f3d0f9415247996bdd5a6353c5979dd38