From 6e77d5027f877d1de6c72340204ca12efc903cb5 Mon Sep 17 00:00:00 2001 From: Shadowtrance Date: Thu, 13 Feb 2025 21:08:16 +1000 Subject: [PATCH] Windows Build and release scripts (#220) --- Buildscripts/build.ps1 | 50 +++++++++++++++++++++++++ Buildscripts/release.ps1 | 79 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 Buildscripts/build.ps1 create mode 100644 Buildscripts/release.ps1 diff --git a/Buildscripts/build.ps1 b/Buildscripts/build.ps1 new file mode 100644 index 00000000..135e8465 --- /dev/null +++ b/Buildscripts/build.ps1 @@ -0,0 +1,50 @@ +<# +.SYNOPSIS + Usage: build.ps1 [boardname] + Example: build.ps1 lilygo-tdeck + Description: Makes a clean build for the specified board. +#> + +function EchoNewPhase { + param ( + [string]$message + ) + Write-Host "⏳ $message" -ForegroundColor Cyan +} + +function FatalError { + param ( + [string]$message + ) + Write-Host "⚠️ $message" -ForegroundColor Red + exit 0 +} + +$sdkconfig_file = "sdkconfig.board.$($args[0])" + +if ($args.Count -lt 1) { + FatalError "Must pass board name as first argument. (e.g. lilygo_tdeck)" +} + +if (-Not (Test-Path $sdkconfig_file)) { + FatalError "Board not found: $sdkconfig_file" +} + +EchoNewPhase "Cleaning build folder" +$BuildFolder = "build" +if (Test-Path $BuildFolder) { + Remove-Item -Path $BuildFolder -Recurse -Force + EchoNewPhase "Build folder deleted" +} else { + EchoNewPhase "Build folder doesn't exist." +} + +EchoNewPhase "Building $sdkconfig_file" + +Copy-Item -Path $sdkconfig_file -Destination "sdkconfig" + +try { + & idf.py build +} catch { + FatalError "Failed to build esp32s3 SDK" +} diff --git a/Buildscripts/release.ps1 b/Buildscripts/release.ps1 new file mode 100644 index 00000000..ec975733 --- /dev/null +++ b/Buildscripts/release.ps1 @@ -0,0 +1,79 @@ +<# +.SYNOPSIS +Releases the current build labeled as a release for the specified board name. + +.DESCRIPTION +Usage: .\release.ps1 [boardname] +Example: .\release.ps1 lilygo-tdeck + +.PARAMETER board +The name of the board to release. +#> + +function EchoNewPhase { + param( + [string]$Message + ) + Write-Host "⏳ $message" -ForegroundColor Cyan +} + +function FatalError { + param( + [string]$Message + ) + Write-Host "⚠️ $message" -ForegroundColor Red + exit 0 +} + +function Release-Symbols { + param( + [string]$TargetPath + ) + + EchoNewPhase "Making symbols release at '$TargetPath'" + New-Item -ItemType Directory -Path $TargetPath -Force | Out-Null + Copy-Item -Path "build\*.elf" -Destination $TargetPath -Force +} + +function Release-Build { + param( + [string]$TargetPath + ) + + EchoNewPhase "Making release at '$TargetPath'" + + $binPath = Join-Path $TargetPath "Binaries" + $partitionTablePath = Join-Path $binPath "partition_table" + $bootloaderPath = Join-Path $binPath "bootloader" + + New-Item -ItemType Directory -Path $binPath -Force | Out-Null + New-Item -ItemType Directory -Path $partitionTablePath -Force | Out-Null + New-Item -ItemType Directory -Path $bootloaderPath -Force | Out-Null + + Copy-Item -Path "build\*.bin" -Destination $binPath -Force + Copy-Item -Path "build\bootloader\*.bin" -Destination $bootloaderPath -Force + Copy-Item -Path "build\partition_table\*.bin" -Destination $partitionTablePath -Force + Copy-Item -Path "build\flash_args" -Destination $binPath -Force + Copy-Item -Path "build\flasher_args.json" -Destination $binPath -Force + + Copy-Item -Path "Buildscripts\Flashing\*" -Destination $TargetPath -Force +} + +# Script start +$releasePath = "release" +$sdkconfig_file = "sdkconfig.board.$($args[0])" +$board = "$($args[0])" + +if ($args.Count -lt 1) { + FatalError "Must pass board name as first argument. (e.g. lilygo_tdeck)" +} + +if (-not (Test-Path $sdkconfig_file)) { + FatalError "Board not found: $sdkconfig_file" +} + +$targetReleasePath = Join-Path $releasePath "Tactility-$board" +$targetSymbolsPath = Join-Path $releasePath "Tactility-$board-symbols" + +Release-Build $targetReleasePath +Release-Symbols $targetSymbolsPath