【初始提交】
This commit is contained in:
39
build-win-app.ps1
Normal file
39
build-win-app.ps1
Normal file
@@ -0,0 +1,39 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$build_type,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$build_and_run
|
||||
)
|
||||
|
||||
# 定义项目和构建目录的变量
|
||||
$projectDir = "$PSScriptRoot"
|
||||
echo $projectDir
|
||||
$buildDir = "$projectDir\build"
|
||||
|
||||
# 创建构建目录
|
||||
if (-Not (Test-Path -Path $buildDir)) {
|
||||
New-Item -ItemType Directory -Path $buildDir
|
||||
}
|
||||
|
||||
# 进入构建目录
|
||||
Set-Location -Path $buildDir
|
||||
|
||||
# 运行CMake生成构建系统
|
||||
# 这里假设CMakeLists.txt在项目根目录下
|
||||
cmake -G "Visual Studio 17 2022" -T host=x64 -DCMAKE_BUILD_TYPE=$build_type ..
|
||||
# 编译项目
|
||||
cmake --build . --config $build_type
|
||||
|
||||
# 返回项目目录
|
||||
Set-Location -Path $projectDir
|
||||
|
||||
# 打印构建完成的消息
|
||||
Write-Host "build done." -ForegroundColor Darkgreen
|
||||
|
||||
if($build_and_run -eq "true"){
|
||||
Write-Host "################## APP Run ##################" -ForegroundColor Blue
|
||||
Start-Process -FilePath "build\\${build_type}\\TestCode.exe"
|
||||
# & "build\\$build_type\\TestCode.exe"
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user