|
@@ -1,15 +1,12 @@
|
|
|
[CmdletBinding()]
|
|
|
param(
|
|
|
+ [ValidateSet('x64')]
|
|
|
+ [string] $Target = 'x64',
|
|
|
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
|
|
|
[string] $Configuration = 'RelWithDebInfo',
|
|
|
- [ValidateSet('x86', 'x64')]
|
|
|
- [string] $Target,
|
|
|
- [ValidateSet('Visual Studio 17 2022', 'Visual Studio 16 2019')]
|
|
|
- [string] $CMakeGenerator,
|
|
|
[switch] $SkipAll,
|
|
|
[switch] $SkipBuild,
|
|
|
- [switch] $SkipDeps,
|
|
|
- [switch] $SkipUnpack
|
|
|
+ [switch] $SkipDeps
|
|
|
)
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
@@ -19,6 +16,10 @@ if ( $DebugPreference -eq 'Continue' ) {
|
|
|
$InformationPreference = 'Continue'
|
|
|
}
|
|
|
|
|
|
+if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) {
|
|
|
+ throw "A 64-bit system is required to build the project."
|
|
|
+}
|
|
|
+
|
|
|
if ( $PSVersionTable.PSVersion -lt '7.0.0' ) {
|
|
|
Write-Warning 'The obs-deps PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
|
|
|
exit 2
|
|
@@ -28,6 +29,7 @@ function Build {
|
|
|
trap {
|
|
|
Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue'
|
|
|
Write-Error $_
|
|
|
+ Log-Group
|
|
|
exit 2
|
|
|
}
|
|
|
|
|
@@ -46,56 +48,58 @@ function Build {
|
|
|
$ProductName = $BuildSpec.name
|
|
|
$ProductVersion = $BuildSpec.version
|
|
|
|
|
|
- $script:DepsVersion = ''
|
|
|
- $script:QtVersion = '5'
|
|
|
- $script:VisualStudioVersion = ''
|
|
|
- $script:PlatformSDK = '10.0.18363.657'
|
|
|
-
|
|
|
- Setup-Host
|
|
|
-
|
|
|
- if ( $CmakeGenerator -eq '' ) {
|
|
|
- $CmakeGenerator = $script:VisualStudioVersion
|
|
|
+ if ( ! $SkipDeps ) {
|
|
|
+ Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
|
|
|
}
|
|
|
|
|
|
- (Get-Content -Path ${ProjectRoot}/CMakeLists.txt -Raw) `
|
|
|
- -replace "project\((.*) VERSION (.*)\)", "project(${ProductName} VERSION ${ProductVersion})" `
|
|
|
- | Out-File -Path ${ProjectRoot}/CMakeLists.txt -NoNewline
|
|
|
-
|
|
|
- Setup-Obs
|
|
|
-
|
|
|
Push-Location -Stack BuildTemp
|
|
|
if ( ! ( ( $SkipAll ) -or ( $SkipBuild ) ) ) {
|
|
|
Ensure-Location $ProjectRoot
|
|
|
|
|
|
- $DepsPath = "plugin-deps-${script:DepsVersion}-qt${script:QtVersion}-${script:Target}"
|
|
|
- $CmakeArgs = @(
|
|
|
- '-G', $CmakeGenerator
|
|
|
- "-DCMAKE_SYSTEM_VERSION=${script:PlatformSDK}"
|
|
|
- "-DCMAKE_GENERATOR_PLATFORM=$(if (${script:Target} -eq "x86") { "Win32" } else { "x64" })"
|
|
|
- "-DCMAKE_BUILD_TYPE=${Configuration}"
|
|
|
- "-DCMAKE_PREFIX_PATH:PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/${DepsPath}")"
|
|
|
- "-DQT_VERSION=${script:QtVersion}"
|
|
|
+ $CmakeArgs = @()
|
|
|
+ $CmakeBuildArgs = @()
|
|
|
+ $CmakeInstallArgs = @()
|
|
|
+
|
|
|
+ if ( $VerbosePreference -eq 'Continue' ) {
|
|
|
+ $CmakeBuildArgs += ('--verbose')
|
|
|
+ $CmakeInstallArgs += ('--verbose')
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( $DebugPreference -eq 'Continue' ) {
|
|
|
+ $CmakeArgs += ('--debug-output')
|
|
|
+ }
|
|
|
+
|
|
|
+ $Preset = "windows-$(if ( $Env:CI -ne $null ) { 'ci-' })${Target}"
|
|
|
+
|
|
|
+ $CmakeArgs += @(
|
|
|
+ '--preset', $Preset
|
|
|
)
|
|
|
|
|
|
- Log-Debug "Attempting to configure OBS with CMake arguments: $($CmakeArgs | Out-String)"
|
|
|
- Log-Information "Configuring ${ProductName}..."
|
|
|
- Invoke-External cmake -S . -B build_${script:Target} @CmakeArgs
|
|
|
+ $CmakeBuildArgs += @(
|
|
|
+ '--build'
|
|
|
+ '--preset', $Preset
|
|
|
+ '--config', $Configuration
|
|
|
+ '--parallel'
|
|
|
+ '--', '/consoleLoggerParameters:Summary', '/noLogo'
|
|
|
+ )
|
|
|
|
|
|
- $CmakeArgs = @(
|
|
|
- '--config', "${Configuration}"
|
|
|
+ $CmakeInstallArgs += @(
|
|
|
+ '--install', "build_${Target}"
|
|
|
+ '--prefix', "${ProjectRoot}/release/${Configuration}"
|
|
|
+ '--config', $Configuration
|
|
|
)
|
|
|
|
|
|
- if ( $VerbosePreference -eq 'Continue' ) {
|
|
|
- $CmakeArgs+=('--verbose')
|
|
|
- }
|
|
|
+ Log-Group "Configuring ${ProductName}..."
|
|
|
+ Invoke-External cmake @CmakeArgs
|
|
|
|
|
|
- Log-Information "Building ${ProductName}..."
|
|
|
- Invoke-External cmake --build "build_${script:Target}" @CmakeArgs
|
|
|
+ Log-Group "Building ${ProductName}..."
|
|
|
+ Invoke-External cmake @CmakeBuildArgs
|
|
|
}
|
|
|
- Log-Information "Install ${ProductName}..."
|
|
|
- Invoke-External cmake --install "build_${script:Target}" --prefix "${ProjectRoot}/release" @CmakeArgs
|
|
|
+ Log-Group "Install ${ProductName}..."
|
|
|
+ Invoke-External cmake @CmakeInstallArgs
|
|
|
|
|
|
Pop-Location -Stack BuildTemp
|
|
|
+ Log-Group
|
|
|
}
|
|
|
|
|
|
Build
|