72 lines
2.7 KiB
PowerShell
72 lines
2.7 KiB
PowerShell
# SPDX-License-Identifier: MPL-2.0
|
|
# Messages en ASCII : compatible Windows PowerShell 5.1 sans BOM.
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Installe flatc (compilateur FlatBuffers) dans tools\flatc\<plateforme>\ (ADR 0013).
|
|
|
|
.DESCRIPTION
|
|
flatc n'est necessaire que pour modifier le contrat (contract\) et regenerer le code
|
|
(tools\contract-gen). Le build C++ n'en a pas besoin : le code genere est versionne.
|
|
|
|
Version figee, identique aux en-tetes C++ (cmake\SequaDependencies.cmake) et au
|
|
paquet npm flatbuffers (studio\ui\package.json). L'archive officielle est verifiee
|
|
par SHA256 avant extraction. Sans effet si la bonne version est deja installee.
|
|
|
|
.PARAMETER Force
|
|
Reinstalle meme si flatc est deja present.
|
|
#>
|
|
param([switch]$Force)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
Set-StrictMode -Version Latest
|
|
. (Join-Path $PSScriptRoot "lib\SequaDownload.ps1")
|
|
|
|
$Version = '25.9.23'
|
|
$Assets = @{
|
|
'windows-x64' = @{ Name = 'Windows.flatc.binary.zip'; Sha256 = '3d6383193ecd274f5de544a6e03464a87f581befb9fc1dda9cf508fa3cce3127'; Exe = 'flatc.exe' }
|
|
'linux-x64' = @{ Name = 'Linux.flatc.binary.g++-13.zip'; Sha256 = 'de0c6ad114a5a686ecf64322528c602c7d4512446a93f290f54f00ee5abea487'; Exe = 'flatc' }
|
|
}
|
|
|
|
$onLinux = (Test-Path variable:IsLinux) -and $IsLinux
|
|
$platform = if ($onLinux) { 'linux-x64' } else { 'windows-x64' }
|
|
$asset = $Assets[$platform]
|
|
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$dest = Join-Path $root "tools\flatc\$platform"
|
|
$exe = Join-Path $dest $asset.Exe
|
|
|
|
if ((Test-Path $exe) -and -not $Force) {
|
|
$current = (& $exe --version) -replace '^flatc version\s*', ''
|
|
if ($current.Trim() -eq $Version) {
|
|
Write-Host "flatc $Version deja installe : $exe"
|
|
exit 0
|
|
}
|
|
Write-Host "flatc $current present, remplacement par $Version"
|
|
}
|
|
|
|
$tmp = Join-Path ([System.IO.Path]::GetTempPath()) "sequa-flatc-$Version"
|
|
New-Item -ItemType Directory -Force $tmp | Out-Null
|
|
$zip = Join-Path $tmp $asset.Name
|
|
$url = "https://github.com/google/flatbuffers/releases/download/v$Version/$($asset.Name)"
|
|
|
|
Write-Step "Telechargement $url"
|
|
& curl.exe -L --fail --retry 3 -sS -o $zip $url
|
|
if ($LASTEXITCODE -ne 0) { throw "Telechargement impossible : $url (code $LASTEXITCODE)" }
|
|
|
|
$hash = (Get-FileDigest $zip).ToLowerInvariant()
|
|
if ($hash -ne $asset.Sha256) {
|
|
Remove-Item $zip -Force
|
|
throw "Empreinte SHA256 inattendue pour $($asset.Name) : $hash (attendu $($asset.Sha256))"
|
|
}
|
|
|
|
if (Test-Path $dest) { Remove-Item $dest -Recurse -Force }
|
|
New-Item -ItemType Directory -Force $dest | Out-Null
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
[System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $dest)
|
|
Remove-Item $tmp -Recurse -Force
|
|
if ($onLinux) { & chmod +x $exe }
|
|
|
|
$installed = & $exe --version
|
|
Write-Host "Installe : $exe ($installed)"
|