-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbuild.ps1
109 lines (89 loc) · 3.5 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
param (
[Parameter(Mandatory)][string[]]$FbtSwitch,
[switch]$doNotClearBuildFolder = $false
)
$build_commands = @{
od = [PSCustomObject]@{
Name = "Official Dev";
ArtifactName = "totp_official-dev_fw{FEATURES_SUFFIX}.zip";
}
os = [PSCustomObject]@{
Name = "Official Stable";
ArtifactName = "totp_official-stable_fw{FEATURES_SUFFIX}.zip";
}
ul = [PSCustomObject]@{
Name = "Unleashed";
ArtifactName = "totp_unleashed_fw{FEATURES_SUFFIX}.zip";
}
ud = [PSCustomObject]@{
Name = "Unleashed (dev)";
ArtifactName = "totp_unleashed_dev_fw{FEATURES_SUFFIX}.zip";
}
ms = [PSCustomObject]@{
Name = "Momentum (stable)";
ArtifactName = "totp_momentum_fw{FEATURES_SUFFIX}.zip";
}
md = [PSCustomObject]@{
Name = "Momentum (dev)";
ArtifactName = "totp_momentum_dev_fw{FEATURES_SUFFIX}.zip";
}
}
Push-Location $PSScriptRoot
if (!(Test-Path -PathType Container "build")) {
New-Item -ItemType Directory -Path "build"
}
elseif (!$doNotClearBuildFolder) {
Remove-Item "build/*" -Recurse -Force
}
function Build-Run {
param (
[string]$FeaturesSuffix,
[string[]]$CppDefine,
[string]$Subfolder,
[string]$FbtSwitch
)
$build_command = $build_commands[$FbtSwitch]
Write-Host "Building $($build_command.Name)"
$build_path = Join-Path -Path $PSScriptRoot -ChildPath "totp/dist"
$fbt_args = @($FbtSwitch, "--clean")
if ($CppDefine.Length -gt 0) {
$CppDefine | ForEach-Object {
$fbt_args += '-D'
$fbt_args += $_
}
}
Invoke-Expression -Command "./ufbt.ps1 $fbt_args"
$build_output_folder = "build"
if ($Subfolder -ne $null -and $Subfolder -ne '') {
$build_output_folder = Join-Path $build_output_folder $Subfolder
if (!(Test-Path -PathType Container $build_output_folder)) {
New-Item -ItemType Directory -Path $build_output_folder
}
}
$build_output_artifact = Join-Path $build_output_folder "$($build_command.ArtifactName -replace '{FEATURES_SUFFIX}',$FeaturesSuffix)"
$zip_folder = Join-Path $build_output_folder ".zip"
if (!(Test-Path -PathType Container $zip_folder)) {
New-Item -ItemType Directory -Path $zip_folder
}
elseif (!$doNotClearBuildFolder) {
Remove-Item "$zip_folder/*" -Recurse -Force
}
$zip_app_folder = Join-Path $zip_folder "apps/Tools"
New-Item $zip_app_folder -ItemType Directory -Force
Copy-Item "$build_path/totp.fap" -Destination $zip_app_folder
$zip_plugins_folder = Join-Path $zip_folder "apps_data/totp/plugins"
New-Item $zip_plugins_folder -ItemType Directory -Force
Copy-Item "$build_path/*.fal" -Destination $zip_plugins_folder
Compress-Archive -Path "$zip_folder/*" -DestinationPath $build_output_artifact
Remove-Item $zip_folder -Recurse -Force
Write-Host "Artifacts for `"$($build_command.Name)`" stored at `"$build_output_artifact`""
}
foreach ($fbts in $FbtSwitch) {
Write-Information 'Building with all the features enables'
Build-Run -FeaturesSuffix '' -FbtSwitch $fbts
Write-Information 'Building without BadBT'
Build-Run -FeaturesSuffix '_no-badbt' -CppDefine TOTP_NO_BADBT_AUTOMATION -FbtSwitch $fbts
Write-Information 'Building with CryptoV1 support'
Build-Run -FeaturesSuffix '_old-crypto-support' -CppDefine TOTP_OBSOLETE_CRYPTO_V1_COMPATIBILITY_ENABLED -FbtSwitch $fbts
}
Pop-Location