-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
48 lines (43 loc) · 2.4 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
<#
.DESCRIPTION
Builds the FSC executable and prepares it for release. Final binaries will be copied to .\build and compressed to 7zip (LZMA) and zip archives.
.PARAMETER FileDescription <Description>
Optional; no metadata is set if unset. Specifies the value of FileDescription in the binary's manifest, which is what will displayed in Task Manager. Specifying this with something innocuous this is recommended in case a very suspicious scammer looks at Task Manager.
.PARAMETER AdditionalOutputDirs
Optional. An array of additional directories to copy binaries to. Must be absolute paths. Files copied to additional directories will not be packed into archives.
#>
param
(
[Parameter()][string]$FileDescription = '',
[Parameter()][System.Collections.Generic.HashSet[String]]$AdditionalOutputDirs
)
$name = 'Moo.FuckScreenConnect-rs'
$version = (cargo.exe read-manifest --manifest-path .\Cargo.toml | ConvertFrom-Json).version
$ErrorActionPreference = 'Stop'
$env:BINARY_FILE_DESCRIPTION=$FileDescription
if ($Clean) { cargo.exe clean }
if ($LASTEXITCODE -eq 0)
{
$new_path = '.\build'
$(Remove-Item -Recurse -Force -Path $new_path -ErrorAction SilentlyContinue) | Out-Null
$(New-Item -Force -Type Directory $new_path) | Out-Null
cargo.exe build
cargo.exe build --release
Copy-Item -Path '.\target\debug\moo_fuck_screen_connect.exe' -Destination '.\build\moo_fuck_screen_connect_debug.exe'
Copy-Item -Path '.\target\release\moo_fuck_screen_connect.exe' -Destination '.\build\moo_fuck_screen_connect.exe'
Copy-Item -Path '.\install.ps1' -Destination '.\build\install.ps1'
Copy-Item -Recurse -Path '.\install_modules' -Destination '.\build\'
}
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Push-Location -Path .\build
foreach ($additional_output_dir in $AdditionalOutputDirs)
{
if (![System.IO.Path]::IsPathRooted($additional_output_dir)) { Write-Error "'$($additional_output_dir)' is not an absolute path!" }
if (!(Test-Path $additional_output_dir)) { Out-Null $(New-Item -Type Directory $additional_output_dir) }
$(Remove-Item -Recurse -Path $additional_output_dir -ErrorAction SilentlyContinue) | Out-Null
Copy-Item -Recurse '.' $additional_output_dir
}
$(Remove-Item -Force -Path test.7z -ErrorAction SilentlyContinue) | Out-Null
7za a -t7z -m0=LZMA2 -mx9 -mmt8 -aoa "${name}.v${version}.7z" * | Out-Null
7za a -tzip -m0=Deflate64 -mpass=15 -mfb=256 -mx9 -mmt8 -aoa "${name}.v${version}.zip" * | Out-Null
Pop-Location