Push-Location $PSScriptRoot $FW_CDEF = "" if (('official-dev', 'off-dev', 'od').Contains($args[0])) { $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_DEV" } elseif (('official-stable', 'off-stbl', 'os').Contains($args[0])) { $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_STABLE" } elseif (('xtreme', 'xt', 'x').Contains($args[0])) { $FW_CDEF = "TOTP_FIRMWARE_XTREME_UL" } else { throw "Unable to recognize which firmware to use" } $i = 1 $args_ls = @() $cpp_defines = @( "/*", "THIS FILE IS AUTOGENERATED BY UFBT WRAPPER APP", "DO NOT EDIT\REMOVE\COMMIT IT", "GO AWAY! LEAVE IT ALONE!", "*/", "#define TOTP_TARGET_FIRMWARE $FW_CDEF") $run_cleanup = $false while ($i -lt $args.Count) { if ($args[$i] -eq '-D') { $define = $args[$i + 1].Split('=') if ($define.Length -gt 1) { $cpp_defines += "#define $($define[0]) $($define[1])" } else { $cpp_defines += "#define $($define[0])" } $i = $i + 2 } elseif ($args[$i] -eq '--clean') { $run_cleanup = $true $i = $i + 1 } else { $args_ls += $args[$i] $i = $i + 1 } } ./ufbt-fm.ps1 use $args[0] Push-Location totp [System.IO.File]::WriteAllLines((Join-Path (Resolve-Path "config/app/") "ufbt_def.h"), $cpp_defines) if ($run_cleanup) { $ufbt_dist_dir = "dist" if (Test-Path -PathType Container $ufbt_dist_dir) { Remove-Item "$ufbt_dist_dir/*" -Recurse -Force } $ufbt_build_dir = Join-Path (Resolve-Path "~/") ".ufbt/build" if (Test-Path -PathType Container $ufbt_build_dir) { Remove-Item "$ufbt_build_dir/*" -Recurse -Force } } ufbt $args_ls Pop-Location Pop-Location