Skip to content

Commit

Permalink
Implemented #28 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov authored Nov 17, 2022
1 parent 7419a1e commit 68f0a34
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 21 deletions.
15 changes: 10 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[submodule "flipperzero-firmware_official"]
path = flipperzero-firmware_official
url = https://github.com/flipperdevices/flipperzero-firmware.git
branch = dev
ignore = dirty
[submodule "flipperzero-firmware_unleashed"]
path = flipperzero-firmware_unleashed
url = https://github.com/Eng1n33r/flipperzero-firmware.git
branch = dev
ignore = dirty
[submodule "flipperzero-firmware_official_dev"]
path = flipperzero-firmware_official_dev
url = https://github.com/flipperdevices/flipperzero-firmware.git
branch = dev
ignore = dirty
[submodule "flipperzero-firmware_official_stable"]
path = flipperzero-firmware_official_stable
url = https://github.com/flipperdevices/flipperzero-firmware.git
branch = release
ignore = dirty
48 changes: 35 additions & 13 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,49 @@ function Get-LatestDirectory {
Get-ChildItem -Path $Path | Where-Object {$_.PSIsContainer} | Sort-Object LastWriteTime -Descending | Select-Object -First 1
}

Push-Location $PSScriptRoot

$official_build_path = "flipperzero-firmware_official\build"
$unleashed_build_path = "flipperzero-firmware_unleashed\build"
$build_commands = @(
[PSCustomObject]@{
Name = "Official Dev";
FbtSwitch = "od";
FirmwarePath = "flipperzero-firmware_official_dev";
ArtifactName = "totp_official-dev-fw.fap"
}
[PSCustomObject]@{
Name = "Official Stable";
FbtSwitch = "os";
FirmwarePath = "flipperzero-firmware_official_stable";
ArtifactName = "totp_official-stable-fw.fap"
}
[PSCustomObject]@{
Name = "Unleashed";
FbtSwitch = "u";
FirmwarePath = "flipperzero-firmware_unleashed";
ArtifactName = "totp_unleashed-fw.fap"
}
)

Remove-Item "$official_build_path\*" -Recurse -Force
Remove-Item "$unleashed_build_path\*" -Recurse -Force

./fbt u COMPACT=1 DEBUG=0 VERBOSE=0 fap_totp
./fbt o COMPACT=1 DEBUG=0 VERBOSE=0 fap_totp
Push-Location $PSScriptRoot

if (!(Test-Path -PathType Container "build")) {
New-Item -ItemType Directory -Path "build"
} else {
Remove-Item "build\*" -Recurse -Force
}

$official_latest_dir = Get-LatestDirectory -Path $official_build_path
Copy-Item "$official_build_path\$official_latest_dir\.extapps\totp.fap" -Destination "build\totp_official-fw.fap"
foreach ($build_command in $build_commands) {
Write-Host "Building $($build_command.Name)"
$build_path = Join-Path -Path $build_command.FirmwarePath -ChildPath "build"
if (Test-Path -PathType Container $build_path) {
Remove-Item "$build_path\*" -Recurse -Force
}

$unleashed_latest_dir = Get-LatestDirectory -Path $unleashed_build_path
Copy-Item "$unleashed_build_path\$unleashed_latest_dir\.extapps\totp.fap" -Destination "build\totp_unleashed-fw.fap"
./fbt $build_command.FbtSwitch COMPACT=1 DEBUG=0 VERBOSE=0 fap_totp

$latest_dir = Get-LatestDirectory -Path $build_path
$build_output_artifact = "build\$($build_command.ArtifactName)"
Copy-Item "$build_path\$latest_dir\.extapps\totp.fap" -Destination $build_output_artifact

Write-Host "Artifacts for $($build_command.Name) stored at $build_output_artifact"
}

Pop-Location
10 changes: 7 additions & 3 deletions fbt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ Push-Location $PSScriptRoot

$firmware_path = ""
$firmware_name = ""
if (('official', 'off', 'o').Contains($args[0])) {
$firmware_path = "flipperzero-firmware_official"
$firmware_name = "Official"
if (('official-dev', 'off-dev', 'od').Contains($args[0])) {
$firmware_path = "flipperzero-firmware_official_dev"
$firmware_name = "Official Dev"
}
elseif (('official-stable', 'off-stbl', 'os').Contains($args[0])) {
$firmware_path = "flipperzero-firmware_official_stable"
$firmware_name = "Official Stable"
}
elseif (('unleashed', 'un', 'u').Contains($args[0])) {
$firmware_path = "flipperzero-firmware_unleashed"
Expand Down
1 change: 1 addition & 0 deletions flipperzero-firmware_official_stable

0 comments on commit 68f0a34

Please sign in to comment.