build.ps1 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. function Get-LatestDirectory {
  2. param (
  3. $Path
  4. )
  5. Get-ChildItem -Path $Path | Where-Object {$_.PSIsContainer} | Sort-Object LastWriteTime -Descending | Select-Object -First 1
  6. }
  7. $build_commands = @(
  8. [PSCustomObject]@{
  9. Name = "Official Dev \ Unleashed";
  10. FbtSwitch = "od";
  11. FirmwarePath = "flipperzero-firmware_official_dev";
  12. ArtifactName = "totp_official-dev_unleashed_fw{FEATURES_SUFFIX}.fap";
  13. }
  14. [PSCustomObject]@{
  15. Name = "Official Stable";
  16. FbtSwitch = "os";
  17. FirmwarePath = "flipperzero-firmware_official_stable";
  18. ArtifactName = "totp_official-stable_fw{FEATURES_SUFFIX}.fap";
  19. }
  20. [PSCustomObject]@{
  21. Name = "Xtreme";
  22. FbtSwitch = "x";
  23. FirmwarePath = "flipperzero-firmware_xtreme";
  24. ArtifactName = "totp_xtreme_fw{FEATURES_SUFFIX}.fap";
  25. }
  26. )
  27. Push-Location $PSScriptRoot
  28. if (!(Test-Path -PathType Container "build")) {
  29. New-Item -ItemType Directory -Path "build"
  30. } else {
  31. Remove-Item "build\*" -Recurse -Force
  32. }
  33. function Build-Run {
  34. param (
  35. [string]$FeaturesSuffix,
  36. [string[]]$CppDefine
  37. )
  38. foreach ($build_command in $build_commands) {
  39. Write-Host "Building $($build_command.Name)"
  40. $build_path = Join-Path -Path $build_command.FirmwarePath -ChildPath "build"
  41. $fbt_args = @($build_command.FbtSwitch, "COMPACT=1", "DEBUG=0", "VERBOSE=0", "fap_totp", "--clean")
  42. if ($CppDefine.Length -gt 0) {
  43. $CppDefine | ForEach-Object {
  44. $fbt_args += '-D'
  45. $fbt_args += $_
  46. }
  47. }
  48. Invoke-Expression -Command "./fbt.ps1 $fbt_args"
  49. $latest_dir = Get-LatestDirectory -Path $build_path
  50. $build_output_artifact = "build\$($build_command.ArtifactName -replace '{FEATURES_SUFFIX}',$FeaturesSuffix)"
  51. Copy-Item "$build_path\$latest_dir\.extapps\totp.fap" -Destination $build_output_artifact
  52. Write-Host "Artifacts for $($build_command.Name) stored at $build_output_artifact"
  53. }
  54. }
  55. Write-Information 'Building with all the features enables'
  56. Build-Run -FeaturesSuffix ''
  57. Write-Information 'Building with BadBT but without BadBT icon'
  58. Build-Run -FeaturesSuffix '_badbt-wo-icon' -CppDefine TOTP_NO_AUTOMATION_ICONS
  59. Write-Information 'Building without BadBT'
  60. Build-Run -FeaturesSuffix '_no-badbt' -CppDefine TOTP_NO_BADBT_TYPE,TOTP_NO_AUTOMATION_ICONS
  61. Pop-Location