57 lines
2.8 KiB
PowerShell
57 lines
2.8 KiB
PowerShell
# Collect the files of a release into dist\release\v<version>\:
|
|||
|
|
#
|
||
|
|
# TangProgrammer-v<version>-win64.zip portable programmer (make_portable.ps1)
|
||
|
|
# TangProgrammer.exe the program alone
|
||
|
|
# tang25k_debugger_bl616.bin bridge firmware, @0x20000
|
||
|
|
# bl616_bootloader_0x20000_nano20k_signed.bin Sipeed loader, @0x0
|
||
|
|
# bl616_fpga_partner_25kDock.bin original Sipeed firmware, @0x0
|
||
|
|
# fpga_test_bitstreams-GW5A-25.zip fpga_test\*\impl\pnr\*.fs, if built
|
||
|
|
# SHA256SUMS.txt
|
||
|
|
#
|
||
|
|
# .\scripts\build.ps1
|
||
|
|
# .\scripts\make_release.ps1 version from FW_VERSION_STR in src\sys.h
|
||
|
|
param([string]$Version)
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
|
||
|
|
$root = Split-Path $PSScriptRoot -Parent
|
||
|
|
if (-not $Version) {
|
||
|
|
$m = Select-String -Path (Join-Path $root 'src\sys.h') -Pattern '#define\s+FW_VERSION_STR\s+"([^"]+)"'
|
||
|
|
if (-not $m) { throw 'FW_VERSION_STR not found in src\sys.h' }
|
||
|
|
$Version = $m.Matches[0].Groups[1].Value
|
||
|
|
}
|
||
|
|
$tag = 'v' + $Version.TrimStart('v')
|
||
|
|
|
||
|
|
$bridgeFw = Join-Path $root 'build\build_out\tang25k_debugger_bl616.bin'
|
||
|
|
if (-not (Test-Path $bridgeFw)) { throw 'bridge firmware is not built: run scripts\build.ps1' }
|
||
|
|
if (-not (Test-Path (Join-Path $root 'third_party\bouffalo_sdk\tools\bflb_tools\bouffalo_flash_cube\BLFlashCommand.exe'))) {
|
||
|
|
throw 'Bouffalo SDK is not installed (scripts\setup.ps1): the portable copy needs BLFlashCommand'
|
||
|
|
}
|
||
|
|
|
||
|
|
$out = Join-Path $root "dist\release\$tag"
|
||
|
|
if (Test-Path $out) { Remove-Item -Recurse -Force $out }
|
||
|
|
New-Item -ItemType Directory -Force $out | Out-Null
|
||
|
|
|
||
|
|
& (Join-Path $PSScriptRoot 'make_portable.ps1')
|
||
|
|
Copy-Item (Join-Path $root 'dist\TangProgrammer.zip') (Join-Path $out "TangProgrammer-$tag-win64.zip")
|
||
|
|
Copy-Item (Join-Path $root 'dist\TangProgrammer\TangProgrammer.exe') $out
|
||
|
|
|
||
|
|
Copy-Item $bridgeFw $out
|
||
|
|
Copy-Item (Join-Path $root 'bin\bl616_bootloader_0x20000_nano20k_signed.bin') $out
|
||
|
|
Copy-Item (Join-Path $root 'bin\bl616_fpga_partner_25kDock.bin') $out
|
||
|
|
|
||
|
|
$fs = @(Get-ChildItem (Join-Path $root 'fpga_test\*\impl\pnr\*.fs') -ErrorAction SilentlyContinue)
|
||
|
|
if ($fs.Count) {
|
||
|
|
Compress-Archive -Path ($fs | ForEach-Object { $_.FullName }) -DestinationPath (Join-Path $out 'fpga_test_bitstreams-GW5A-25.zip')
|
||
|
|
} else {
|
||
|
|
Write-Warning 'no test bitstreams: build them with gw_sh build.tcl in fpga_test\loopback and fpga_test\stream'
|
||
|
|
}
|
||
|
|
|
||
|
|
# sha256sum format, so that "sha256sum -c SHA256SUMS.txt" works
|
||
|
|
$sums = Get-ChildItem $out -File | Sort-Object Name | ForEach-Object {
|
||
|
|
(Get-FileHash -Algorithm SHA256 $_.FullName).Hash.ToLower() + ' ' + $_.Name
|
||
|
|
}
|
||
|
|
[IO.File]::WriteAllText((Join-Path $out 'SHA256SUMS.txt'), ($sums -join "`n") + "`n")
|
||
|
|
|
||
|
|
Get-ChildItem $out -File | Sort-Object Name | Format-Table Name, @{ n = 'KB'; e = { [math]::Ceiling($_.Length / 1KB) }; a = 'right' } -AutoSize
|
||
|
|
Write-Host "OK: $out" -ForegroundColor Green
|