Browse Source

Add `./build.ps1 -Dev`.

This will let you build just the C++ parts of Korman for local usage. It
probably needs to be paired with a batch file to supply the needed
arguments.
pull/277/head
Adam Johnson 3 years ago
parent
commit
a2d4d3f7e2
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 5
      CMakeLists.txt
  2. 61
      build.ps1

5
CMakeLists.txt

@ -32,6 +32,7 @@ set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "")
# That would indicate that we are installing Korman into the blender we found, so no need to install blender.
option(korman_INSTALL_BLENDER "Copy Blender as part of the INSTALL target" ON)
option(korman_INSTALL_SCRIPTS "Copy Korman python scripts as part of the INSTALL target" ON)
option(korman_INSTALL_PACKAGE "Buid Korman CPack installers" ON)
# While, yes, we could tie our build process into Blender's, Blender pulls in
# tons of dependencies and can be quite slow if you start trying to build
@ -51,7 +52,9 @@ set(Python3_FIND_STRATEGY VERSION)
find_package(Python3 ${Blender_PYTHON_VERSION} EXACT COMPONENTS Development REQUIRED)
include(Dependencies)
include(Packaging)
if(korman_INSTALL_PACKAGE)
include(Packaging)
endif()
if(korman_INSTALL_SCRIPTS)
set(korman_INSTALL_SCRIPTS_PATH "${Blender_VERSION}/scripts/addons" CACHE STRING "")

61
build.ps1

@ -16,11 +16,13 @@
param(
[Parameter(ParameterSetName="classic", Mandatory=$false)]
[Parameter(ParameterSetName="modern", Mandatory=$false)]
[Parameter(ParameterSetName="dev", Mandatory=$false)]
[ValidateSet("Visual Studio 2013", "Visual Studio 2015", "Visual Studio 2017", "Visual Studio 2019", "Visual Studio 2022")]
[string]$Generator,
[Parameter(ParameterSetName="classic", Mandatory=$false)]
[Parameter(ParameterSetName="modern", Mandatory=$false)]
[Parameter(ParameterSetName="dev", Mandatory=$false)]
[string]$BuildDir = "$(Get-Location)/build",
[Parameter(ParameterSetName="modern", Mandatory=$true)]
@ -43,7 +45,11 @@ param(
})]
[switch]$Classic,
[Parameter(ParameterSetName="dev", Mandatory=$true)]
[switch]$Dev,
[Parameter(ParameterSetName="classic", Mandatory=$true)]
[Parameter(ParameterSetName="dev", Mandatory=$false)]
[string]$PythonVersion,
[Parameter(ParameterSetName="modern")]
@ -51,6 +57,7 @@ param(
[string]$Platform,
[Parameter(ParameterSetName="modern")]
[Parameter(ParameterSetName="dev")]
[string]$BlenderDir,
[Parameter(ParameterSetName="modern")]
@ -80,6 +87,11 @@ $Platform_LUT = @{
"x64" = "x64"
}
# Fixup -NoBlender for dev and classic modes.
if ($Classic -Or $Dev) {
$NoBlender = $true
}
function Find-CMakeArgument($UserInput, $EnvValue, $LUT, $Default) {
if ($UserInput) {
return $LUT[$UserInput]
@ -99,19 +111,25 @@ function Convert-BoolToCMake($Value) {
}
function Start-KormanBuild($HostGenerator, $TargetPlatform, $OutputDir, $StagingDir) {
# Only pass the -G and -A arguments for new build directories.
if (!(Test-Path "$OutputDir/CMakeCache.txt")) {
Write-Host -ForegroundColor Cyan "Configuring Korman with $HostGenerator for $TargetPlatform..."
$InstallBlender = Convert-BoolToCMake $(if ($NoBlender -Or $Classic) { $false } else { $true })
$GeneratorArg = "-G$HostGenerator"
$PlatformArg = "-A$TargetPlatform"
} else {
Write-Host -ForegroundColor Cyan "Re-Configuring Korman..."
}
$InstallBlender = Convert-BoolToCMake $(if ($NoBlender) { $false } else { $true })
$HarvestPython22 = Convert-BoolToCMake $(if ($NoInstaller) { $false } else { $true })
cmake `
-G "$HostGenerator" `
-A "$TargetPlatform" `
$GeneratorArg $PlatformArg `
-S "$PSScriptRoot" `
-B "$OutputDir" `
-DBlender_ROOT="$BlenderDir" `
-DBlender_PYTHON_VERSION="$PythonVersion" `
-Dkorman_EXTERNAL_STAGING_DIR="$StagingDir" `
-Dkorman_HARVEST_PYTHON22="$HarvestPython22" `
-Dkorman_INSTALL_BLENDER="$InstallBlender" | Write-Host
-Dkorman_INSTALL_BLENDER="$InstallBlender"
if ($LASTEXITCODE -Ne 0) { throw "Configure failed!" }
}
@ -125,9 +143,27 @@ function Set-KormanClassicBuild($OutputDir, $Arch) {
if ($LASTEXITCODE -Ne 0) { throw "Configure failed!" }
}
function Complete-KormanBuild($OutputDir) {
function Set-KormanDevBuild($OutputDir) {
Write-Host -ForegroundColor Cyan "Setting up development build..."
if ($BlenderDir) { $InstallDest = $BlenderDir } else { $InstallDest = "$OutputDir/install" }
cmake `
-B "$OutputDir" `
-DCMAKE_INSTALL_PREFIX="$InstallDest" `
-Dkorman_HARVEST_PYTHON22=OFF `
-Dkorman_HARVEST_VCREDIST=OFF `
-Dkorman_INSTALL_BLENDER=OFF `
-Dkorman_INSTALL_SCRIPTS=OFF `
-Dkorman_INSTALL_PACKAGE=OFF
}
function Complete-KormanBuild($OutputDir, $Install = $false) {
Write-Host -ForegroundColor Cyan "Aaaand they're off!!!"
cmake --build "$OutputDir" --config Release --parallel
# Don't even ask.
if ($Install) {
cmake --build `"$OutputDir`" --target INSTALL --config Release --parallel
} else {
cmake --build `"$OutputDir`" @($InstallArg) --config Release --parallel
}
if ($LASTEXITCODE -Ne 0) { throw "Build failed!" }
}
@ -180,6 +216,12 @@ function Build-KormanClassicInstaller() {
}
}
function Build-KormanDev($HostGenerator, $TargetPlatform, $OutputDir) {
Start-KormanBuild "$HostGenerator" "$TargetPlatform" "$OutputDir" "$OutputDir/external"
Set-KormanDevBuild "$OutputDir"
Complete-KormanBuild "$OutputDir" -Install $true
}
function Build-KormanModern($HostGenerator, $TargetPlatform, $OutputDir) {
$CheckBuildDir = Test-Path $OutputDir
Start-KormanBuild "$HostGenerator" "$TargetPlatform" "$OutputDir" "$OutputDir/external"
@ -217,7 +259,12 @@ if ($Classic) {
Build-KormanClassicSingleArch "$MyGenerator" x86 "$BuildDir"
Build-KormanClassicSingleArch "$MyGenerator" x64 "$BuildDir"
Build-KormanClassicInstaller
} else {
} elseif($Modern) {
$MyPlatform = Find-CMakeArgument $Platform $Env:CMAKE_GENERATOR_PLATFORM $Platform_LUT x64
Build-KormanModern "$MyGenerator" "$MyPlatform" "$BuildDir"
} elseif($Dev) {
$MyPlatform = Find-CMakeArgument $Platform $Env:CMAKE_GENERATOR_PLATFORM $Platform_LUT x64
Build-KormanDev "$MyGenerator" "$MyPlatform" "$BuildDir"
} else {
throw "Unknown build type"
}

Loading…
Cancel
Save