-
Notifications
You must be signed in to change notification settings - Fork 15
/
build_agent.ps1
49 lines (40 loc) · 1.38 KB
/
build_agent.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
Param(
[Parameter(Mandatory=$false)]
[Switch] $release,
[Parameter(Mandatory=$false)]
[Switch] $timing
)
$TARGET = "aarch64-linux-android"
$OutputDirectory = "$PSScriptRoot/mbf-site/public"
$AgentDetailsOutputPath = "$PSScriptRoot/mbf-site/src/agent_manifest.ts"
$OutputPath = "$OutputDirectory/mbf-agent"
$CargoManifestPath = "$PSScriptRoot/mbf-agent/Cargo.toml"
$Command = "cargo build --manifest-path $CargoManifestPath --target $TARGET"
if ( $release -eq $true )
{
$Command += " --release"
$Configuration = "release"
}
else
{
$Configuration = "debug"
}
if( $timing -eq $true )
{
$Command += " --features request_timing"
}
Invoke-Expression $Command
$ExecutablePath = "$PSScriptRoot/target/$TARGET/$Configuration/mbf-agent"
Copy-Item $ExecutablePath $OutputPath
$SHA1Hash = Get-FileHash -Algorithm SHA1 -Path $ExecutablePath | select -ExpandProperty Hash
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
$AgentLength = (Get-Item $OutputPath).Length;
$AgentDetailsContents = @'
// THIS FILE IS AUTOMATICALLY GENERATED
// The uncompressed length of the MBF agent in bytes.
export const AGENT_LENGTH: number =
'@ + $AgentLength + @'
// The SHA1 hash of the MBF agent, as a string base64 encoded.
export const AGENT_SHA1: string = "
'@ + $SHA1Hash + '"';
[System.IO.File]::WriteAllLines($AgentDetailsOutputPath, $AgentDetailsContents, $Utf8NoBomEncoding)