scripts/build-godot.ps1 -Target editor construit l'éditeur du fork (exécutable, pas LibGodot), seul à savoir faire --dump-extension-api, et écrit build/godot/extension_api.json. godot-cpp s'appuie ainsi sur l'API réelle du fork plutôt que sur la liste officielle 4.7 (identiques tant que le fork ne touche pas à l'API : 1036 classes).
123 lines
4.5 KiB
PowerShell
123 lines
4.5 KiB
PowerShell
# SPDX-License-Identifier: MPL-2.0
|
|
# Messages en ASCII : compatible Windows PowerShell 5.1 sans BOM.
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Construit Godot en bibliotheque partagee (LibGodot) depuis le fork engines/godot/vendor/godot-src.
|
|
|
|
.DESCRIPTION
|
|
Cree au besoin un environnement Python isole (engines/godot/.venv) avec SCons, puis lance
|
|
SCons avec library_type=shared_library (ADR 0007). Pilote graphique Vulkan uniquement :
|
|
D3D12, AccessKit et ANGLE sont desactives (ADR 0007 : Vulkan sur Windows et Linux).
|
|
--path reste autorise : c'est l'hote qui indique a Godot le projet a charger.
|
|
SCons detecte MSVC lui-meme. Duree indicative : 10 a 20 min pour une premiere construction.
|
|
|
|
Sortie : engines/godot/vendor/godot-src/bin/godot.windows.<target>.x86_64.dll
|
|
|
|
-Target editor construit l'editeur du fork (executable, pas LibGodot) uniquement pour
|
|
extraire la liste de l'API (--dump-extension-api, reserve aux builds editeur) dans
|
|
build/godot/extension_api.json, que godot-cpp utilise a la place de la liste officielle.
|
|
A relancer a chaque modification du fork qui touche l'API.
|
|
|
|
.PARAMETER Target
|
|
template_debug (defaut), template_release, ou editor (extraction de l'API).
|
|
|
|
.PARAMETER Jobs
|
|
Nombre de compilations en parallele. Defaut : nombre de processeurs logiques.
|
|
|
|
.PARAMETER Log
|
|
Fichier ou copier la sortie de SCons (en plus de la console).
|
|
|
|
.PARAMETER Help
|
|
Affiche cette aide.
|
|
|
|
.EXAMPLE
|
|
.\scripts\build-godot.ps1
|
|
.EXAMPLE
|
|
Start-Process pwsh -ArgumentList '-NoExit','-File','scripts\build-godot.ps1','-Log','build\godot-build.log'
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
param(
|
|
[ValidateSet("template_debug", "template_release", "editor")]
|
|
[string]$Target = "template_debug",
|
|
[int]$Jobs = [Environment]::ProcessorCount,
|
|
[string]$Log,
|
|
[Alias("h", "?")]
|
|
[switch]$Help
|
|
)
|
|
|
|
if ($Help) {
|
|
Get-Help $PSCommandPath -Detailed
|
|
exit 0
|
|
}
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$godot = Join-Path $root "engines\godot\vendor\godot-src"
|
|
$venv = Join-Path $root "engines\godot\.venv"
|
|
$python = Join-Path $venv "Scripts\python.exe"
|
|
$sconsVersion = "4.9.1"
|
|
|
|
if (-not (Test-Path (Join-Path $godot "SConstruct"))) {
|
|
throw "Sources de Godot absentes : git submodule update --init engines/godot/vendor/godot-src"
|
|
}
|
|
|
|
if (-not (Test-Path $python)) {
|
|
Write-Host "==> venv $venv" -ForegroundColor Cyan
|
|
& python -m venv $venv
|
|
if ($LASTEXITCODE -ne 0) { throw "Echec : creation du venv (Python 3 requis dans le PATH)" }
|
|
}
|
|
|
|
& $python -c "import SCons, sys; sys.exit(0 if SCons.__version__ == '$sconsVersion' else 1)" 2>$null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "==> pip install scons==$sconsVersion" -ForegroundColor Cyan
|
|
& $python -m pip install --disable-pip-version-check --quiet "scons==$sconsVersion"
|
|
if ($LASTEXITCODE -ne 0) { throw "Echec : installation de SCons" }
|
|
}
|
|
|
|
$sconsArgs = @(
|
|
"-m", "SCons", "-C", $godot, "-j", $Jobs,
|
|
"platform=windows", "arch=x86_64", "target=$Target",
|
|
"d3d12=no", "accesskit=no", "angle=no"
|
|
)
|
|
if ($Target -ne "editor") {
|
|
# L'hote indique le projet a charger (--path), interdit par defaut dans les modeles 4.7.
|
|
$sconsArgs += @("library_type=shared_library", "disable_path_overrides=no")
|
|
}
|
|
|
|
Write-Host "==> scons $($sconsArgs[4..($sconsArgs.Length - 1)] -join ' ')" -ForegroundColor Cyan
|
|
$start = Get-Date
|
|
if ($Log) {
|
|
New-Item -ItemType Directory -Force (Split-Path -Parent $Log) | Out-Null
|
|
& $python @sconsArgs 2>&1 | Tee-Object -FilePath $Log
|
|
}
|
|
else {
|
|
& $python @sconsArgs
|
|
}
|
|
$code = $LASTEXITCODE
|
|
$elapsed = (Get-Date) - $start
|
|
if ($code -ne 0) { throw "Echec : scons (code $code) apres $([int]$elapsed.TotalMinutes) min" }
|
|
|
|
Write-Host ("==> termine en {0:N1} min" -f $elapsed.TotalMinutes) -ForegroundColor Green
|
|
Get-ChildItem (Join-Path $godot "bin") -Filter "godot.windows.$Target.x86_64*" | Select-Object Name, Length
|
|
|
|
if ($Target -eq "editor") {
|
|
$apiDir = Join-Path $root "build\godot"
|
|
New-Item -ItemType Directory -Force $apiDir | Out-Null
|
|
$editor = Join-Path $godot "bin\godot.windows.editor.x86_64.console.exe"
|
|
Write-Host "==> --dump-extension-api -> $apiDir\extension_api.json" -ForegroundColor Cyan
|
|
Push-Location $apiDir
|
|
try {
|
|
& $editor --headless --dump-extension-api
|
|
$code = $LASTEXITCODE
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
if ($code -ne 0 -or -not (Test-Path (Join-Path $apiDir "extension_api.json"))) {
|
|
throw "Echec : extraction de l'API (code $code)"
|
|
}
|
|
Write-Host "==> API extraite : reconfigurer CMake pour regenerer godot-cpp" -ForegroundColor Green
|
|
}
|