From b46cd406a7de76c09051d5ce199426636d2697fd Mon Sep 17 00:00:00 2001 From: luocai Date: Tue, 15 Oct 2024 18:14:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81CI=E6=9E=84=E5=BB=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/release_windows.yaml | 23 ++++++ CMakeLists.txt | 2 +- resources/build.ps1 | 106 ++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/release_windows.yaml create mode 100644 resources/build.ps1 diff --git a/.gitea/workflows/release_windows.yaml b/.gitea/workflows/release_windows.yaml new file mode 100644 index 0000000..cd13de7 --- /dev/null +++ b/.gitea/workflows/release_windows.yaml @@ -0,0 +1,23 @@ +name: Release tag +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: [windows11] + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Build and deploy + run: | + resources/build.ps1 build + resources/build.ps1 deploy + resources/build.ps1 changelog + - name: Upload Gitea Release + uses: akkuman/gitea-release-action@v1 + with: + body_path: build/CHANGELOG.txt + files: |- + build/AntiClipSettings.zip \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2307226..d03a882 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(AntiClipSettings VERSION 1.3 LANGUAGES C CXX) +project(AntiClipSettings VERSION 1.4 LANGUAGES C CXX) set(APPLICATION_NAME "视觉防夹设备上位机工具") set(CMAKE_CXX_STANDARD 17) diff --git a/resources/build.ps1 b/resources/build.ps1 new file mode 100644 index 0000000..b8c2ca6 --- /dev/null +++ b/resources/build.ps1 @@ -0,0 +1,106 @@ +param($type) + +$MsvcScript = 'D:\Program Files\Microsoft Visual Studio\2022\\Community\Common7\Tools\Launch-VsDevShell.ps1' +if (!(Test-Path $MsvcScript)) { $MsvcScript = 'D:\Program Files\Microsoft Visual Studio\2022\\Professional\Common7\Tools\Launch-VsDevShell.ps1' } +. $MsvcScript -SkipAutomaticLocation -Arch amd64 + +$qtHome = "D:\Qt\5.15.2\msvc2019_64" +$openSSLRoot = "D:\Qt\Tools\OpenSSLv3\Win_x64" + +$librariesPath = "E:\Projects\Libraries" +if (!(Test-Path $librariesPath)) { $librariesPath = "D:\Projects\Libraries" } +$boostRoot = "$librariesPath\boost_1_83_0_msvc2022_64bit" +$ffmpegRoot = "$librariesPath\ffmpeg-7.0.2-full_build-shared" + +$projectPath = Get-Location +$buildPath = Join-Path -Path $projectPath -ChildPath "build" +$deployPath = Join-Path -Path $buildPath -ChildPath "AntiClipSettings" +$zipFilePath = Join-Path -Path $buildPath -ChildPath "AntiClipSettings.zip" +$changelogPath = Join-Path -Path $buildPath -ChildPath "CHANGELOG.txt" + +function Build() { + if (!(Test-Path $buildPath\CMakeCache.txt)) { + cmake.exe -G Ninja -S . -B build ` + -DCMAKE_BUILD_TYPE=Release ` + -DCMAKE_PREFIX_PATH=$qtHome ` + -DQT_DIR="$qtHome\lib\cmake\Qt5" ` + -DQt5_DIR="$qtHome\lib\cmake\Qt5" ` + -DLibraries_ROOT="$librariesPath" + } + + cmake.exe --build $buildPath --target all +} + +function Deploy() { + if (Test-Path $deployPath) { + Remove-Item $deployPath -Recurse -Force + } + New-Item $deployPath -ItemType Directory + Copy-Item $buildPath\AntiClipSettings.exe $deployPath\AntiClipSettings.exe + & $qtHome\bin\windeployqt.exe $deployPath\AntiClipSettings.exe --qmldir=$qtHome\qml + + + # $modules = "QmlCore" + # foreach ($module in $modules) { + # Copy-Item -Path $qtHome\bin\Qt6$module.dll -Destination $deployPath + # } + + # if (-Not (Test-Path -Path $deployPath\qml\QtCore)) { + # New-Item $deployPath\qml\QtCore -ItemType Directory + # $plugins = "qtqmlcoreplugin.dll", "qmldir", "plugins.qmltypes" + # foreach ($plugin in $plugins) { + # Copy-Item -Path $QtHome\qml\QtCore\$plugin -Destination $deployPath\qml\QtCore + # } + # } + + Copy-Item $openSSLRoot\bin\libssl-3-x64.dll $deployPath + Copy-Item $openSSLRoot\bin\libcrypto-3-x64.dll $deployPath + + $boosts = "atomic", "thread", "filesystem", "log", "json" + foreach ($boost in $boosts) { + Copy-Item -Path $boostRoot\lib\boost_$boost-vc143-mt-x64-1_83.dll -Destination $deployPath + } + + $ffmpegs = "avcodec-61", "avdevice-61", "avfilter-10", "avformat-61", "avutil-59", "postproc-58", "swresample-5", "swscale-8" + foreach ($ffmpeg in $ffmpegs) { + Copy-Item -Path $ffmpegRoot\bin\$ffmpeg.dll -Destination $deployPath + } + + Compress-Archive -Path $deployPath -DestinationPath $zipFilePath -Force +} + +function Clean() { + if (Test-Path $buildPath) { + Remove-Item $buildPath -Recurse -Force + } +} + +function Changelog() { + $commit_message = git log -1 --pretty=format:"%B" + Write-Output "Latest commit message:" + Write-Output $commit_message + $commit_message | Out-File -FilePath $changelogPath -Encoding utf8 + Write-Output "Commit message has been written to $changelogPath" +} + + +switch ($type) { + "build" { + Build + } + "deploy" { + Deploy + } + "clean" { + Clean + } + "installer" { + Installer + } + "changelog" { + Changelog + } + "update" { + UpdateServer + } +} \ No newline at end of file