xtchain/scripts/xtchain.ps1
Aiken Harris 6463d50cd3
All checks were successful
Builds / XTchain (full, linux) (push) Successful in 1h30m39s
Builds / XTchain (full, windows) (push) Successful in 1h31m10s
Builds / XTchain (minimal, linux) (push) Successful in 2m44s
Builds / XTchain (minimal, windows) (push) Successful in 2m13s
Update PS1 prompt, thanks to perikiyoxd
2025-07-09 22:56:50 +02:00

58 lines
1.8 KiB
PowerShell

# PROJECT: XTchain
# LICENSE: See the COPYING.md in the top level directory
# FILE: scripts/xtchain.ps1
# DESCRIPTION: XTchain Entry Script
# DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
# Get the absolute path to the XTchain
$XTCDIR = (Get-Item -Path ".\").FullName
# Read the XTchain version
$env:XTCVER = Get-Content "${XTCDIR}\Version"
# Load the library (Make sure the xtclib.ps1 file is PowerShell compatible)
. "${XTCDIR}\lib\xtchain\xtclib.ps1"
# Set the target architecture
$env:TARGET = $args[0]
if (-not $env:TARGET) { $env:TARGET = "amd64" }
# Save the source directory
$SRCDIR = $args[1]
if (-not $SRCDIR) { $SRCDIR = (Get-Location).Path }
# Make sure the compiler flags are clean
$env:HOST = $null
$env:CFLAGS = $null
$env:CXXFLAGS = $null
$env:LDFLAGS = $null
# Update PATH
$env:PATH = "${XTCDIR}\bin;" + $env:PATH
# Display banner
version
# Invoke shell with fancy prompt
function global:prompt {
$PROMPT = " XT Toolchain "
$CWD = (Get-Location).Path
$CHEVRON = [char]0xE0B0
$SEGMENTS = @(
@{ TEXT = $PROMPT; BGCOLOR = "Blue"; FGCOLOR = "White" },
@{ TEXT = " $CWD "; BGCOLOR = "DarkCyan"; FGCOLOR = "White" }
)
for ($INDEX = 0; $INDEX -lt $SEGMENTS.Count; $INDEX++) {
$SEGMENT = $SEGMENTS[$INDEX]
$NEXTBG = if ($INDEX + 1 -lt $SEGMENTS.Count) { $SEGMENTS[$INDEX + 1].BGCOLOR } else { "Default" }
Write-Host $SEGMENT.TEXT -NoNewLine -ForegroundColor $SEGMENT.FGCOLOR -BackgroundColor $SEGMENT.BGCOLOR
if ($NEXTBG -ne "Default") {
Write-Host $CHEVRON -NoNewLine -ForegroundColor $SEGMENT.BGCOLOR -BackgroundColor $NEXTBG
} else {
Write-Host $CHEVRON -NoNewLine -ForegroundColor $SEGMENT.BGCOLOR
}
}
return " "
}
Set-Location -Path $SRCDIR