build.ps1 5.2 KB

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