ufbt.ps1 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Push-Location $PSScriptRoot
  2. $FW_CDEF = ""
  3. if (('official-dev', 'off-dev', 'od').Contains($args[0])) {
  4. $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_DEV"
  5. }
  6. elseif (('official-stable', 'off-stbl', 'os').Contains($args[0])) {
  7. $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_STABLE"
  8. }
  9. elseif (('xtreme', 'xt', 'x').Contains($args[0])) {
  10. $FW_CDEF = "TOTP_FIRMWARE_XTREME_UL"
  11. }
  12. else {
  13. throw "Unable to recognize which firmware to use"
  14. }
  15. $i = 1
  16. $args_ls = @()
  17. $cpp_defines = @(
  18. "/* THIS FILE IS AUTOGENERATED BY UFBT WRAPPER APP",
  19. "DO NOT EDIT\REMOVE\COMMIT IT",
  20. "GO AWAY! LEAVE IT ALONE! */",
  21. "#define TOTP_TARGET_FIRMWARE $FW_CDEF")
  22. $run_cleanup = $false
  23. while ($i -lt $args.Count) {
  24. if ($args[$i] -eq '-D') {
  25. $define = $args[$i + 1].Split('=')
  26. if ($define.Length -gt 1) {
  27. $cpp_defines += "#define $($define[0]) $($define[1])"
  28. }
  29. else {
  30. $cpp_defines += "#define $($define[0])"
  31. }
  32. $i = $i + 2
  33. }
  34. elseif ($args[$i] -eq '--clean') {
  35. $run_cleanup = $true
  36. $i = $i + 1
  37. }
  38. else {
  39. $args_ls += $args[$i]
  40. $i = $i + 1
  41. }
  42. }
  43. ./ufbt-fm.ps1 use $args[0]
  44. Push-Location totp
  45. [System.IO.File]::WriteAllLines((Join-Path (Resolve-Path "config/app/") "ufbt_def.h"), $cpp_defines)
  46. if ($run_cleanup) {
  47. $ufbt_dist_dir = "dist"
  48. if (Test-Path -PathType Container $ufbt_dist_dir) {
  49. Remove-Item "$ufbt_dist_dir/*" -Recurse -Force
  50. }
  51. $ufbt_build_dir = Join-Path (Resolve-Path "~/") ".ufbt/build"
  52. if (Test-Path -PathType Container $ufbt_build_dir) {
  53. Remove-Item "$ufbt_build_dir/*" -Recurse -Force
  54. }
  55. }
  56. ufbt $args_ls
  57. Pop-Location
  58. Pop-Location