build.ps1 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. param (
  2. [switch]$doNotBuildBaseFap = $false,
  3. [switch]$buildCustomFontFap = $false
  4. )
  5. function Get-LatestDirectory {
  6. param (
  7. $Path
  8. )
  9. Get-ChildItem -Path $Path | Where-Object {$_.PSIsContainer} | Sort-Object LastWriteTime -Descending | Select-Object -First 1
  10. }
  11. $build_commands = @(
  12. [PSCustomObject]@{
  13. Name = "Official Dev";
  14. FbtSwitch = "od";
  15. FirmwarePath = "flipperzero-firmware_official_dev";
  16. ArtifactName = "totp_official-dev_fw{FEATURES_SUFFIX}.fap";
  17. }
  18. [PSCustomObject]@{
  19. Name = "Official Stable";
  20. FbtSwitch = "os";
  21. FirmwarePath = "flipperzero-firmware_official_stable";
  22. ArtifactName = "totp_official-stable_fw{FEATURES_SUFFIX}.fap";
  23. }
  24. [PSCustomObject]@{
  25. Name = "Xtreme \ Unleashed";
  26. FbtSwitch = "x";
  27. FirmwarePath = "flipperzero-firmware_xtreme";
  28. ArtifactName = "totp_xtreme_unleashed_fw{FEATURES_SUFFIX}.fap";
  29. }
  30. )
  31. Push-Location $PSScriptRoot
  32. if (!(Test-Path -PathType Container "build")) {
  33. New-Item -ItemType Directory -Path "build"
  34. } else {
  35. Remove-Item "build\*" -Recurse -Force
  36. }
  37. function Build-Run {
  38. param (
  39. [string]$FeaturesSuffix,
  40. [string[]]$CppDefine,
  41. [string]$Subfolder
  42. )
  43. foreach ($build_command in $build_commands) {
  44. Write-Host "Building $($build_command.Name)"
  45. $build_path = Join-Path -Path $build_command.FirmwarePath -ChildPath "build"
  46. $fbt_args = @($build_command.FbtSwitch, "COMPACT=1", "DEBUG=0", "VERBOSE=0", "fap_totp", "--clean")
  47. if ($CppDefine.Length -gt 0) {
  48. $CppDefine | ForEach-Object {
  49. $fbt_args += '-D'
  50. $fbt_args += $_
  51. }
  52. }
  53. Invoke-Expression -Command "./fbt.ps1 $fbt_args"
  54. $latest_dir = Get-LatestDirectory -Path $build_path
  55. $build_output_folder = "build"
  56. if ($Subfolder -ne $null -and $Subfolder -ne '') {
  57. $build_output_folder = Join-Path $build_output_folder $Subfolder
  58. if (!(Test-Path -PathType Container $build_output_folder)) {
  59. New-Item -ItemType Directory -Path $build_output_folder
  60. }
  61. }
  62. $build_output_artifact = Join-Path $build_output_folder "$($build_command.ArtifactName -replace '{FEATURES_SUFFIX}',$FeaturesSuffix)"
  63. Copy-Item "$build_path\$latest_dir\.extapps\totp.fap" -Destination $build_output_artifact
  64. Write-Host "Artifacts for $($build_command.Name) stored at $build_output_artifact"
  65. }
  66. }
  67. if ($doNotBuildBaseFap -eq $false) {
  68. Write-Information 'Building with all the features enables'
  69. Build-Run -FeaturesSuffix ''
  70. Write-Information 'Building with BadBT but without BadBT icon'
  71. Build-Run -FeaturesSuffix '_badbt-wo-icon' -CppDefine TOTP_NO_AUTOMATION_ICONS
  72. Write-Information 'Building without BadBT'
  73. Build-Run -FeaturesSuffix '_no-badbt' -CppDefine TOTP_NO_BADBT_TYPE,TOTP_NO_AUTOMATION_ICONS
  74. }
  75. if ($buildCustomFontFap -eq $true) {
  76. $custom_fonts = @(
  77. [PSCustomObject]@{
  78. CDEF = "TOTP_FONT_REDHATMONO";
  79. Subfolder = 'Redhat_Mono'
  80. },
  81. [PSCustomObject]@{
  82. CDEF = "TOTP_FONT_BEDSTEAD";
  83. Subfolder = 'Bedstead'
  84. },
  85. [PSCustomObject]@{
  86. CDEF = "TOTP_FONT_ZECTOR";
  87. Subfolder = 'Zector'
  88. },
  89. [PSCustomObject]@{
  90. CDEF = "TOTP_FONT_712SERIF";
  91. Subfolder = '7-12_Serif'
  92. },
  93. [PSCustomObject]@{
  94. CDEF = "TOTP_FONT_GRAPH35PIX";
  95. Subfolder = 'Graph35_pix'
  96. },
  97. [PSCustomObject]@{
  98. CDEF = "TOTP_FONT_KARMAFUTURE";
  99. Subfolder = 'Karma_future'
  100. },
  101. [PSCustomObject]@{
  102. CDEF = "TOTP_FONT_FUNCLIMBING";
  103. Subfolder = 'Funclimbing'
  104. },
  105. [PSCustomObject]@{
  106. CDEF = "TOTP_FONT_DPCOMIC";
  107. Subfolder = 'DPComic'
  108. },
  109. [PSCustomObject]@{
  110. CDEF = "TOTP_FONT_PIXELFLAG";
  111. Subfolder = 'Pixel_flag'
  112. }
  113. )
  114. foreach ($custom_font in $custom_fonts) {
  115. Write-Information "Custom font ($($custom_font.Subfolder)): Building with all the features enables"
  116. Build-Run -FeaturesSuffix '' -CppDefine TOTP_FONT=$($custom_font.CDEF) -Subfolder $($custom_font.Subfolder)
  117. Write-Information "Custom font ($($custom_font.Subfolder)): Building with BadBT but without BadBT icon"
  118. Build-Run -FeaturesSuffix '_badbt-wo-icon' -CppDefine TOTP_NO_AUTOMATION_ICONS,TOTP_FONT=$($custom_font.CDEF) -Subfolder $($custom_font.Subfolder)
  119. Write-Information "Custom font ($($custom_font.Subfolder)): Building without BadBT"
  120. Build-Run -FeaturesSuffix '_no-badbt' -CppDefine TOTP_NO_BADBT_TYPE,TOTP_NO_AUTOMATION_ICONS,TOTP_FONT=$($custom_font.CDEF) -Subfolder $($custom_font.Subfolder)
  121. }
  122. }
  123. Pop-Location