ufbt.ps1 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. "/*",
  19. "THIS FILE IS AUTOGENERATED BY UFBT WRAPPER APP",
  20. "DO NOT EDIT\REMOVE\COMMIT IT",
  21. "GO AWAY! LEAVE IT ALONE!",
  22. "*/",
  23. "#define TOTP_TARGET_FIRMWARE $FW_CDEF")
  24. $run_cleanup = $false
  25. while ($i -lt $args.Count) {
  26. if ($args[$i] -eq '-D') {
  27. $define = $args[$i + 1].Split('=')
  28. if ($define.Length -gt 1) {
  29. $cpp_defines += "#define $($define[0]) $($define[1])"
  30. }
  31. else {
  32. $cpp_defines += "#define $($define[0])"
  33. }
  34. $i = $i + 2
  35. }
  36. elseif ($args[$i] -eq '--clean') {
  37. $run_cleanup = $true
  38. $i = $i + 1
  39. }
  40. else {
  41. $args_ls += $args[$i]
  42. $i = $i + 1
  43. }
  44. }
  45. ./ufbt-fm.ps1 use $args[0]
  46. Push-Location totp
  47. [System.IO.File]::WriteAllLines((Join-Path (Resolve-Path "config/app/") "ufbt_def.h"), $cpp_defines)
  48. if ($run_cleanup) {
  49. $ufbt_dist_dir = "dist"
  50. if (Test-Path -PathType Container $ufbt_dist_dir) {
  51. Remove-Item "$ufbt_dist_dir/*" -Recurse -Force
  52. }
  53. $ufbt_build_dir = Join-Path (Resolve-Path "~/") ".ufbt/build"
  54. if (Test-Path -PathType Container $ufbt_build_dir) {
  55. Remove-Item "$ufbt_build_dir/*" -Recurse -Force
  56. }
  57. }
  58. ufbt $args_ls
  59. Pop-Location
  60. Pop-Location