-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-euphony.ps1
56 lines (41 loc) · 2.07 KB
/
install-euphony.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
$ErrorActionPreference = "Stop"
function Add-Directory {
param (
[Parameter(Mandatory=$true)]
$DirectoryPath
)
if (-not (Test-Path $DirectoryPath -Type Container)) {
Write-Host -ForegroundColor DarkGray "Creating directory: $DirectoryPath"
New-Item -Path $DirectoryPath -ItemType Directory | Out-Null
}
}
Write-Host -ForegroundColor Yellow "This script will compile euphony and install it into the ./bin directory."
# Check if rust is installed
$CargoExists = Get-Command cargo -ErrorAction SilentlyContinue
if ($null -eq $CargoExists) {
Write-Host -ForegroundColor Red "The command line tool `"cargo`" is not available! Please install Rust."
exit 1
}
# Build project
Write-Host -ForegroundColor DarkMagenta "Running ``cargo build --release``"
cargo build --release
if ($LASTEXITCODE -gt 0) {
Write-Host -ForegroundColor Red "cargo build exited with non-zero exit code."
exit $LASTEXITCODE
}
# Copy euphony.exe to ./bin/
Write-Host -ForegroundColor DarkMagenta "Copying release binary (./target/release/euphony.exe) to ./bin"
$TargetReleaseBinary = Join-Path $PSScriptRoot "target/release/euphony.exe"
$BinDirectory = Join-Path -Path $PSScriptRoot -ChildPath "bin"
Add-Directory -DirectoryPath $BinDirectory
Copy-Item -Path $TargetReleaseBinary -Destination $BinDirectory
# Copy configuration.TEMPLATE.toml to ./bin/data
Write-Host -ForegroundColor DarkMagenta "Copying configuration template to ./bin/data"
$SourceConfigurationTemplate = Join-Path $PSScriptRoot "data/configuration.TEMPLATE.toml"
$BinDataDirectory = Join-Path -Path $BinDirectory -ChildPath "data"
Add-Directory -DirectoryPath $BinDataDirectory
Copy-Item -Path $SourceConfigurationTemplate -Destination $BinDataDirectory
Write-Host ""
Write-Host -ForegroundColor Green "-- BUILD AND COPY COMPLETE --"
Write-Host -ForegroundColor DarkBlue "Make sure you rename ./bin/data/configuration.TEMLPLATE.toml to ./bin/data/configuration.toml and fill out the details."
Write-Host -ForegroundColor DarkMagenta "If you want euphony in your path, add $BinDirectory to your PATH."