124 lines
4.1 KiB
PowerShell
124 lines
4.1 KiB
PowerShell
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"
|
|
|
|
# 6.1.1 版本支持 windows7
|
|
$ffmpegRoot = "$librariesPath\ffmpeg-6.1.1-full_build-shared"
|
|
|
|
$projectPath = Get-Location
|
|
$buildPath = Join-Path -Path $projectPath -ChildPath "build"
|
|
|
|
$fileContent = (Get-Content -Path "CMakeLists.txt") -join " "
|
|
if ($fileContent -match 'project\([^\)]+VERSION\s+([0-9]+\.[0-9]+)') {
|
|
$version = $Matches[1]
|
|
} else {
|
|
Write-Output "未找到版本号"
|
|
}
|
|
|
|
$deployPath = Join-Path -Path $buildPath -ChildPath "AntiClipSettings_v$version"
|
|
$zipFilePath = Join-Path -Path $buildPath -ChildPath "AntiClipSettings_v$version.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
|
|
Remove-Item -Path $deployPath\d3dcompiler_47.dll -Force
|
|
Remove-Item -Path $deployPath\Qt5RemoteObjects.dll -Force
|
|
Remove-Item -Path $deployPath\Qt5QuickTest.dll -Force
|
|
Remove-Item -Path $deployPath\translations -Recurse -Force # 暂时不需要翻译文件
|
|
Remove-Item -Path $deployPath\qmltooling -Recurse -Force
|
|
Remove-Item -Path $deployPath\QtTest -Recurse -Force
|
|
Remove-Item -Path $deployPath\QtGraphicalEffects -Recurse -Force
|
|
|
|
|
|
# $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
|
|
}
|
|
|
|
# 暂时不需要 avfilter-9、avformat-60
|
|
$ffmpegs = "avcodec-60", "avdevice-60", "avutil-58", "postproc-57", "swresample-4", "swscale-7"
|
|
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
|
|
}
|
|
} |