Compare commits

...

12 Commits

Author SHA1 Message Date
2ecef29aa4 Use PowerShell module and improved xtchain ps1 2025-09-26 13:56:40 +02:00
2d4dffe38f Fix WaitForSingleObject() argument type on MinGW
All checks were successful
Builds / XTchain (full, linux) (push) Successful in 2h18m45s
Builds / XTchain (full, windows) (push) Successful in 2h19m58s
Builds / XTchain (minimal, linux) (push) Successful in 1m41s
Builds / XTchain (minimal, windows) (push) Successful in 1m22s
2025-09-14 19:24:05 +02:00
124ef802b3 Update tools
Some checks failed
Builds / XTchain (full, windows) (push) Failing after 1h18m35s
Builds / XTchain (minimal, linux) (push) Successful in 1m51s
Builds / XTchain (minimal, windows) (push) Successful in 1m47s
Builds / XTchain (full, linux) (push) Successful in 1h54m25s
2025-09-14 10:49:11 +02:00
ad326019fd Update Ninja to v1.13.1
All checks were successful
Builds / XTchain (full, linux) (push) Successful in 1h33m55s
Builds / XTchain (full, windows) (push) Successful in 1h34m44s
Builds / XTchain (minimal, linux) (push) Successful in 3m7s
Builds / XTchain (minimal, windows) (push) Successful in 2m15s
2025-07-16 22:56:46 +02:00
079af46983 Always copy all scripts regardless of target platform
Some checks failed
Builds / XTchain (full, linux) (push) Has started running
Builds / XTchain (full, windows) (push) Has started running
Builds / XTchain (minimal, linux) (push) Has been cancelled
Builds / XTchain (minimal, windows) (push) Has been cancelled
2025-07-16 22:45:08 +02:00
17fb344798 Add PowerShell wrapper
Some checks failed
Builds / XTchain (full, linux) (push) Has started running
Builds / XTchain (full, windows) (push) Has started running
Builds / XTchain (minimal, linux) (push) Has been cancelled
Builds / XTchain (minimal, windows) (push) Has been cancelled
2025-07-16 22:32:48 +02:00
d5595e2a7f Improve MSYS2 compatibility and unify output with Windows version
Some checks failed
Builds / XTchain (full, linux) (push) Has been cancelled
Builds / XTchain (full, windows) (push) Has been cancelled
Builds / XTchain (minimal, linux) (push) Has been cancelled
Builds / XTchain (minimal, windows) (push) Has been cancelled
2025-07-16 22:27:49 +02:00
317fedec34 Fix script compatibility with MSYS2 environment
Some checks failed
Builds / XTchain (full, linux) (push) Has started running
Builds / XTchain (full, windows) (push) Has started running
Builds / XTchain (minimal, linux) (push) Has been cancelled
Builds / XTchain (minimal, windows) (push) Has been cancelled
2025-07-16 22:25:08 +02:00
703df71191 Upgrade LLVM and Wine to the latest available versions
All checks were successful
Builds / XTchain (full, linux) (push) Successful in 1h31m19s
Builds / XTchain (full, windows) (push) Successful in 1h31m41s
Builds / XTchain (minimal, windows) (push) Successful in 2m21s
Builds / XTchain (minimal, linux) (push) Successful in 2m53s
2025-07-12 21:52:09 +02:00
4f66ebfd88 Skip windres version check
All checks were successful
Builds / XTchain (full, linux) (push) Successful in 1h31m32s
Builds / XTchain (full, windows) (push) Successful in 1h31m57s
Builds / XTchain (minimal, linux) (push) Successful in 1m49s
Builds / XTchain (minimal, windows) (push) Successful in 2m19s
2025-07-12 21:47:34 +02:00
ba0a50682f Skip windres version check
Some checks failed
Builds / XTchain (full, linux) (push) Has started running
Builds / XTchain (full, windows) (push) Has started running
Builds / XTchain (minimal, linux) (push) Has been cancelled
Builds / XTchain (minimal, windows) (push) Has been cancelled
2025-07-12 21:41:41 +02:00
3b394fc175 Fix argument forwarding in xbuild function
Some checks failed
Builds / XTchain (full, linux) (push) Has started running
Builds / XTchain (full, windows) (push) Has started running
Builds / XTchain (minimal, linux) (push) Has been cancelled
Builds / XTchain (minimal, windows) (push) Has been cancelled
2025-07-12 21:31:35 +02:00
8 changed files with 422 additions and 211 deletions

View File

@@ -26,22 +26,22 @@ TARGET_SYSTEM=linux
# CMake Settings
CMAKEDIR="${SRCDIR}/cmake"
CMAKETAG="v4.0.3"
CMAKETAG="v4.1.1"
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
# LLVM Settings
LLVMDIR="${SRCDIR}/llvm"
LLVMTAG="llvmorg-20.1.7"
LLVMTAG="llvmorg-21.1.1"
LLVMVCS="https://github.com/llvm/llvm-project.git"
# Ninja Settings
NINJADIR="${SRCDIR}/ninja"
NINJATAG="v1.13.0"
NINJATAG="v1.13.1"
NINJAVCS="https://github.com/ninja-build/ninja.git"
# Wine Settings
WINEDIR="${SRCDIR}/wine"
WINETAG="wine-10.11"
WINETAG="wine-10.15"
WINEVCS="https://github.com/wine-mirror/wine.git"
@@ -352,11 +352,9 @@ xtchain_build()
case "${SYSTEM_NAME}" in
Windows)
CCOMPILER="${SYSTEM_HOST}-gcc"
EXTENSION=".ps1"
;;
*)
CCOMPILER="clang"
EXTENSION=""
esac
# Build XTchain tools
@@ -368,8 +366,8 @@ xtchain_build()
${CCOMPILER} ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}
fi
done
cp ${WRKDIR}/scripts/xtclib${EXTENSION} ${BINDIR}/lib/xtchain/
cp ${WRKDIR}/scripts/xtchain${EXTENSION} ${BINDIR}/
cp ${WRKDIR}/scripts/xtclib* ${BINDIR}/lib/xtchain/
cp ${WRKDIR}/scripts/xtchain* ${BINDIR}/
}
# This function generates XTCHAIN version file and produces tarball archive

View File

@@ -0,0 +1,13 @@
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp
index c0b10797e..e971b8cfd 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -58,7 +58,7 @@ public:
// Keep trying to cancel ReadFile() until the thread exits.
do {
CancelIoEx(m_handle, /*lpOverlapped=*/NULL);
- } while (WaitForSingleObject(m_monitor_thread.native_handle(), 1) ==
+ } while (WaitForSingleObject((HANDLE)m_monitor_thread.native_handle(), 1) ==
WAIT_TIMEOUT);
m_monitor_thread.join();
}

View File

@@ -7,13 +7,13 @@
# Get the absolute path to the XTchain
export XTCDIR="$(realpath $(dirname ${0}))"
export XTCDIR="$(realpath $(dirname "${0}"))"
# Read the XTchain version
export XTCVER="$(cat ${XTCDIR}/Version)"
export XTCVER="$(cat "${XTCDIR}/Version")"
# Load the library
source ${XTCDIR}/lib/xtchain/xtclib
source "${XTCDIR}/lib/xtchain/xtclib"
# Set the target architecture
: ${TARGET:=${1}}
@@ -41,4 +41,4 @@ export PFMAT3="\[\033[0;1;97;104m\]"
export PFMAT4="\[\033[0;94;49m\]"
export PFMAT5="\[\033[1;38;5;74m\]"
export PROMPT="\n${PFMAT1} XT Toolchain ${PFMAT2}${PFMAT3} \w ${PFMAT4}${PFMAT5} "
bash --rcfile <(echo 'source ~/.bashrc && export PS1="${PROMPT}" && cd ${SRCDIR}')
bash --rcfile <(echo 'export PS1="${PROMPT}" && cd "${SRCDIR}"')

2
scripts/xtchain.cmd Normal file
View File

@@ -0,0 +1,2 @@
@echo off
powershell.exe -ExecutionPolicy Bypass -NoExit -File "%~dp0xtchain.ps1"

View File

@@ -1,57 +1,156 @@
#
# 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
[CmdletBinding()]
param(
[Parameter(Position = 0)]
[string]$TargetArchitecture = "amd64",
# Read the XTchain version
$env:XTCVER = Get-Content "${XTCDIR}\Version"
[Parameter(Position = 1)]
[string]$SourceDirectory = $PWD.Path
)
# 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" }
# Initialize XTchain environment
function Initialize-XTChain {
[CmdletBinding()]
param(
[string]$Architecture,
[string]$SourcePath
)
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
# Get the absolute path to XTchain
$script:XTCDIR = (Get-Item -Path ".\").FullName
# Read XTchain version
$versionFile = Join-Path $script:XTCDIR "Version"
if (Test-Path $versionFile) {
$env:XTCVER = Get-Content $versionFile -Raw | ForEach-Object { $_.Trim() }
} else {
Write-Warning "Version file not found at $versionFile"
$env:XTCVER = "Unknown"
}
# Set XTchain directory environment variable
$env:XTCDIR = $script:XTCDIR
# Import XTchain module
$modulePath = Join-Path $script:XTCDIR "lib\xtchain\xtclib.psm1"
if (Test-Path $modulePath) {
Import-Module $modulePath -Force -Global
} else {
Write-Error "XTchain module not found at $modulePath"
return $false
}
# Set target architecture
$env:TARGET = $Architecture
# Validate source directory
if (-not (Test-Path $SourcePath)) {
Write-Error "Source directory does not exist: $SourcePath"
return $false
}
# Clean compiler environment variables
$env:HOST = $null
$env:CFLAGS = $null
$env:CXXFLAGS = $null
$env:LDFLAGS = $null
# Update PATH to include XTchain binaries
$xtcBinPath = Join-Path $script:XTCDIR "bin"
if (Test-Path $xtcBinPath) {
$env:PATH = "$xtcBinPath;" + $env:PATH
} else {
Write-Warning "XTchain bin directory not found at $xtcBinPath"
}
return $true
}
# Create fancy PowerLine-style prompt
function Set-XTChainPrompt {
[CmdletBinding()]
param()
function global:prompt {
try {
$promptText = " XT Toolchain "
$currentPath = (Get-Location).Path
$chevron = [char]0xE0B0
# Define prompt segments
$segments = @(
@{
Text = $promptText
BackgroundColor = "Blue"
ForegroundColor = "White"
},
@{
Text = " $currentPath "
BackgroundColor = "DarkCyan"
ForegroundColor = "White"
}
)
# Render segments
for ($index = 0; $index -lt $segments.Count; $index++) {
$segment = $segments[$index]
$nextBackground = if ($index + 1 -lt $segments.Count) {
$segments[$index + 1].BackgroundColor
} else {
"Default"
}
# Write segment text
Write-Host $segment.Text -NoNewLine -ForegroundColor $segment.ForegroundColor -BackgroundColor $segment.BackgroundColor
# Write separator
if ($nextBackground -ne "Default") {
Write-Host $chevron -NoNewLine -ForegroundColor $segment.BackgroundColor -BackgroundColor $nextBackground
} else {
Write-Host $chevron -NoNewLine -ForegroundColor $segment.BackgroundColor
}
}
return " "
}
catch {
# Fallback to simple prompt if PowerLine fails
return "XTC> "
}
}
return " "
}
Set-Location -Path $SRCDIR
# Main execution
try {
Write-Host "Initializing XTchain environment..." -ForegroundColor Green
if (-not (Initialize-XTChain -Architecture $TargetArchitecture -SourcePath $SourceDirectory)) {
Write-Error "Failed to initialize XTchain environment"
exit 1
}
# Display version information
Show-XTCVersion
# Set up the fancy prompt
Set-XTChainPrompt
# Change to source directory
Set-Location -Path $SourceDirectory
Write-Host "XTchain environment ready!" -ForegroundColor Green
Write-Host "Current directory: $(Get-Location)" -ForegroundColor Cyan
Write-Host "Target architecture: $env:TARGET" -ForegroundColor Cyan
Write-Host "Type 'Show-XTCHelp' or 'help' for available commands" -ForegroundColor Yellow
}
catch {
Write-Error "Failed to initialize XTchain: $_"
exit 1
}

View File

@@ -13,8 +13,8 @@ banner()
local XTC_BANNER="XT Toolchain v${XTCVER} for Linux"
printf "###############################################################################\n\n"
printf "%*s\n\n" $(( (${#XTC_BANNER} + 80) / 2)) "${XTC_BANNER}"
printf "###############################################################################\n\n\n"
printf "\033[33m%*s\033[00m\n\n" $(( (${#XTC_BANNER} + 80) / 2)) "${XTC_BANNER}"
printf "###############################################################################\n\n"
}
export -f banner
@@ -82,7 +82,7 @@ version()
{
local XTCHAIN_EXTTOOLS=false
if [ ! -f ${XTCDIR}/bin/clang ] || [ "$(which clang)" != "${XTCDIR}/bin/clang" ] || [ $(echo ${XTCVER} | grep "min") ]; then
if [ ! -f "${XTCDIR}/bin/clang" ] || [ "$(which clang)" != "${XTCDIR}/bin/clang" ] || [ $(echo ${XTCVER} | grep "min") ]; then
XTCHAIN_EXTTOOLS=true
for TOOL in {clang,clang++,cmake,lld-link,ninja}; do
which ${TOOL} &> /dev/null
@@ -97,7 +97,6 @@ version()
banner
echo -en "\nLLVM/Clang Compiler: $(clang --version | grep 'clang version' | cut -d' ' -f3) ($(which clang))"
echo -en "\nLLVM/LLD Linker: $(lld-link --version | cut -d' ' -f2) ($(which lld-link))"
echo -en "\nLLVM Resource Compiler: $(windres --version | grep version | cut -d' ' -f5) ($(which windres))"
echo -en "\nWine IDL Compiler: $(widl -V | grep 'version' | cut -d' ' -f5) ($(which widl))"
echo -en "\nWine Message Compiler: $(wmc -V | grep 'version' | cut -d' ' -f5) ($(which wmc))"
echo -en "\nWine Resource Compiler: $(wrc --version | grep 'version' | cut -d' ' -f5) ($(which wrc))"
@@ -110,7 +109,7 @@ version()
chbuild ${BUILD_TYPE:-DEBUG}
echo -en "\n\nFor a list of all supported commands, type 'help'"
echo -en "\n-------------------------------------------------\n\n"
echo -en "\n-------------------------------------------------\n\n\n"
}
export -f version

View File

@@ -1,148 +0,0 @@
# PROJECT: XTchain
# LICENSE: See the COPYING.md in the top level directory
# FILE: scripts/xtclib.ps1
# DESCRIPTION: XTchain library
# DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
# Prints XTChain banner
function banner {
param()
$XTC_BANNER = "XT Toolchain v${Env:XTCVER} for Windows"
Write-Host "################################################################################"
Write-Host
Write-Host (' ' * [math]::Floor((80 - $XTC_BANNER.Length) / 2) + $XTC_BANNER) -ForegroundColor Yellow
Write-Host
Write-Host "################################################################################"
Write-Host
}
# Sets the target architecture
function charch {
param (
[string]$arch
)
if ([string]::IsNullOrWhiteSpace($arch)) {
Write-Host "Syntax: charch [architecture]"
return
}
switch -Regex ($arch) {
"aarch64|arm64" {
$Env:TARGET = "aarch64"
}
"arm|armv7" {
$Env:TARGET = "armv7"
}
"i386|i486|i586|i686|x86" {
$Env:TARGET = "i686"
}
"amd64|x64|x86_64" {
$Env:TARGET = "amd64"
}
default {
$Env:TARGET = "UNKNOWN"
}
}
Write-Host "Target Architecture: $($Env:TARGET)"
}
# Sets the build type
function chbuild {
param (
[string]$buildType
)
if ([string]::IsNullOrWhiteSpace($buildType)) {
Write-Host "Syntax: chbuild [DEBUG|RELEASE]"
return
}
switch -Regex ($buildType.ToUpper()) {
"RELEASE" {
$Env:BUILD_TYPE = "RELEASE"
}
default {
$Env:BUILD_TYPE = "DEBUG"
}
}
Write-Host "Target build type: $($Env:BUILD_TYPE)"
}
# Prints help
function help {
banner
Write-Host "XTChain defines an internal list of commands:"
Write-Host " * banner - prints XTChain banner"
Write-Host " * charch [arch] - sets the target CPU architecture [aarch64/armv7/i686/amd64]"
Write-Host " * chbuild [type] - sets build type [debug/release]"
Write-Host " * help - prints this message"
Write-Host " * version - prints XTChain and its components version"
Write-Host " * xbuild - builds an application with a Ninja build system"
}
# Displays version banner
function version {
param()
[bool]$XTCHAIN_EXTTOOLS = $false
if ((Test-Path "${Env:XTCDIR}/bin/clang") -and
((Get-Command clang).Source -eq "${Env:XTCDIR}/bin/clang") -and
($Env:XTCVER -match "min")) {
$XTCHAIN_EXTTOOLS = $true
foreach ($TOOL in @("clang", "clang++", "cmake", "lld-link", "ninja")) {
if (!(Get-Command $TOOL -ErrorAction SilentlyContinue)) {
Write-Error "You are using minimal version of XTChain and '${TOOL}' has been not found in your system!"
Write-Error "Please install all required tools."
return
}
}
}
banner
Write-Host
Write-Host "LLVM/Clang Compiler: $(clang --version | Select-String -Pattern "version (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command clang).Source))"
Write-Host "LLVM/LLD Linker: $(lld-link --version | Select-String -Pattern "(\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command lld-link).Source))"
Write-Host "LLVM Resource Compiler: $(windres --version | Select-String -Pattern "version (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command windres).Source))"
Write-Host "Wine IDL Compiler: $(widl -V | Select-String -Pattern "version (\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command widl).Source))"
Write-Host "Wine Message Compiler: $(wmc -V | Select-String -Pattern "version (\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command wmc).Source))"
Write-Host "Wine Resource Compiler: $(wrc --version | Select-String -Pattern "version (\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command wrc).Source))"
Write-Host "XT SPEC Compiler: $(xtcspecc --help | Select-String -Pattern "Version (\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command xtcspecc).Source))"
Write-Host "CMake Build System: $(cmake --version | Select-String -Pattern "version (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }) ($($(Get-Command cmake).Source))"
Write-Host "Ninja Build System: $(ninja --version) ($($(Get-Command ninja).Source))"
Write-Host
$BUILD_TYPE = if ($null -eq $env:BUILD_TYPE -or $env:BUILD_TYPE -eq '') { 'DEBUG' } else { $env:BUILD_TYPE }
$TARGET = if ($null -eq $env:TARGET -or $env:TARGET -eq '') { 'amd64' } else { $env:TARGET }
charch $TARGET
chbuild $BUILD_TYPE
Write-Host
Write-Host
Write-Host "For a list of all supported commands, type 'help'"
Write-Host "-------------------------------------------------"
Write-Host
Write-Host
Write-Host
}
# Builds application (wrapper to Ninja)
function xbuild {
param(
[string[]]$args
)
if (-not (Test-Path build.arch)) {
& ninja @args
} else {
$ARCH = Get-Content build.arch
if ($ARCH -ne $Env:TARGET) {
Write-Host "Build is configured for '$ARCH' while current target set to '$($Env:TARGET)'!"
Write-Host "Cannot continue until conflict is resolved ..."
return 1
}
& ninja @args
}
}

248
scripts/xtclib.psm1 Normal file
View File

@@ -0,0 +1,248 @@
#
# MODULE: XTchain
# LICENSE: See the COPYING.md in the top level directory
# FILE: xtclib.psm1
# DESCRIPTION: XTchain PowerShell module
# DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
#
# Module variables
$script:XTCVersion = $env:XTCVER
$script:XTCDirectory = $env:XTCDIR
<#
.SYNOPSIS
Prints XTChain banner
.DESCRIPTION
Displays the XTChain version banner with formatting
#>
function Show-XTCBanner {
[CmdletBinding()]
param()
$XTC_BANNER = "XT Toolchain v$script:XTCVersion for Windows"
Write-Host "################################################################################"
Write-Host
Write-Host (' ' * [math]::Floor((80 - $XTC_BANNER.Length) / 2) + $XTC_BANNER) -ForegroundColor Yellow
Write-Host
Write-Host "################################################################################"
Write-Host
}
<#
.SYNOPSIS
Sets the target architecture
.DESCRIPTION
Configures the TARGET environment variable based on the specified architecture
.PARAMETER Architecture
The target architecture (aarch64, arm64, arm, armv7, i386, i486, i586, i686, x86, amd64, x64, x86_64)
#>
function Set-XTCArchitecture {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$Architecture
)
switch -Regex ($Architecture.ToLower()) {
"aarch64|arm64" {
$env:TARGET = "aarch64"
}
"arm|armv7" {
$env:TARGET = "armv7"
}
"i386|i486|i586|i686|x86" {
$env:TARGET = "i686"
}
"amd64|x64|x86_64" {
$env:TARGET = "amd64"
}
default {
$env:TARGET = "UNKNOWN"
Write-Warning "Unknown architecture '$Architecture'. Set to UNKNOWN."
}
}
Write-Host "Target Architecture: $($env:TARGET)"
}
<#
.SYNOPSIS
Sets the build type
.DESCRIPTION
Configures the BUILD_TYPE environment variable
.PARAMETER BuildType
The build type (DEBUG or RELEASE)
#>
function Set-XTCBuildType {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateSet("DEBUG", "RELEASE")]
[string]$BuildType
)
$env:BUILD_TYPE = $BuildType.ToUpper()
Write-Host "Target build type: $($env:BUILD_TYPE)"
}
<#
.SYNOPSIS
Shows XTChain help information
.DESCRIPTION
Displays available XTChain commands and their usage
#>
function Show-XTCHelp {
[CmdletBinding()]
param()
Show-XTCBanner
Write-Host "XTChain PowerShell Module Commands:"
Write-Host " * Show-XTCBanner - prints XTChain banner"
Write-Host " * Set-XTCArchitecture - sets the target CPU architecture"
Write-Host " * Set-XTCBuildType - sets build type [DEBUG/RELEASE]"
Write-Host " * Show-XTCHelp - prints this message"
Write-Host " * Show-XTCVersion - prints XTChain and its components version"
Write-Host " * Invoke-XTCBuild - builds an application with Ninja build system"
Write-Host
Write-Host "Legacy command aliases:"
Write-Host " * banner, charch, chbuild, help, version, xbuild"
}
<#
.SYNOPSIS
Displays version information for XTChain components
.DESCRIPTION
Shows version information for all XTChain tools and components
#>
function Show-XTCVersion {
[CmdletBinding()]
param()
# Check for minimal XTChain version with external tools
$XTCHAIN_EXTTOOLS = $false
if ((Test-Path "$script:XTCDirectory/bin/clang") -and
((Get-Command clang -ErrorAction SilentlyContinue).Source -eq "$script:XTCDirectory/bin/clang") -and
($script:XTCVersion -match "min")) {
$XTCHAIN_EXTTOOLS = $true
$requiredTools = @("clang", "clang++", "cmake", "lld-link", "ninja")
foreach ($tool in $requiredTools) {
if (!(Get-Command $tool -ErrorAction SilentlyContinue)) {
Write-Error "You are using minimal version of XTChain and '$tool' has been not found in your system!"
Write-Error "Please install all required tools."
return
}
}
}
Show-XTCBanner
Write-Host
# Display tool versions
try {
$clangVersion = (clang --version | Select-String -Pattern "version (\d+\.\d+\.\d+)").Matches.Groups[1].Value
$clangPath = (Get-Command clang).Source
Write-Host "LLVM/Clang Compiler: $clangVersion ($clangPath)"
} catch { Write-Warning "Could not retrieve Clang version" }
try {
$lldVersion = (lld-link --version | Select-String -Pattern "(\d+\.\d+\.\d+)").Matches.Groups[1].Value
$lldPath = (Get-Command lld-link).Source
Write-Host "LLVM/LLD Linker: $lldVersion ($lldPath)"
} catch { Write-Warning "Could not retrieve LLD version" }
try {
$widlVersion = (widl -V | Select-String -Pattern "version (\d+\.\d+)").Matches.Groups[1].Value
$widlPath = (Get-Command widl).Source
Write-Host "Wine IDL Compiler: $widlVersion ($widlPath)"
} catch { Write-Warning "Could not retrieve WIDL version" }
try {
$wmcVersion = (wmc -V | Select-String -Pattern "version (\d+\.\d+)").Matches.Groups[1].Value
$wmcPath = (Get-Command wmc).Source
Write-Host "Wine Message Compiler: $wmcVersion ($wmcPath)"
} catch { Write-Warning "Could not retrieve WMC version" }
try {
$wrcVersion = (wrc --version | Select-String -Pattern "version (\d+\.\d+)").Matches.Groups[1].Value
$wrcPath = (Get-Command wrc).Source
Write-Host "Wine Resource Compiler: $wrcVersion ($wrcPath)"
} catch { Write-Warning "Could not retrieve WRC version" }
try {
$xtcspeccVersion = (xtcspecc --help | Select-String -Pattern "Version (\d+\.\d+)").Matches.Groups[1].Value
$xtcspeccPath = (Get-Command xtcspecc).Source
Write-Host "XT SPEC Compiler: $xtcspeccVersion ($xtcspeccPath)"
} catch { Write-Warning "Could not retrieve XTCSPECC version" }
try {
$cmakeVersion = (cmake --version | Select-String -Pattern "version (\d+\.\d+\.\d+)").Matches.Groups[1].Value
$cmakePath = (Get-Command cmake).Source
Write-Host "CMake Build System: $cmakeVersion ($cmakePath)"
} catch { Write-Warning "Could not retrieve CMake version" }
try {
$ninjaVersion = (ninja --version)
$ninjaPath = (Get-Command ninja).Source
Write-Host "Ninja Build System: $ninjaVersion ($ninjaPath)"
} catch { Write-Warning "Could not retrieve Ninja version" }
Write-Host
# Set default values and display current configuration
$BUILD_TYPE = if ([string]::IsNullOrEmpty($env:BUILD_TYPE)) { 'DEBUG' } else { $env:BUILD_TYPE }
$TARGET = if ([string]::IsNullOrEmpty($env:TARGET)) { 'amd64' } else { $env:TARGET }
Set-XTCArchitecture -Architecture $TARGET
Set-XTCBuildType -BuildType $BUILD_TYPE
Write-Host
Write-Host
Write-Host "For a list of all supported commands, type 'Show-XTCHelp' or 'help'"
Write-Host "--------------------------------------------------------"
Write-Host
}
<#
.SYNOPSIS
Builds application using Ninja build system
.DESCRIPTION
Wrapper around ninja command with architecture validation
.PARAMETER Arguments
Arguments to pass to ninja
#>
function Invoke-XTCBuild {
[CmdletBinding()]
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Arguments
)
if (Test-Path "build.arch") {
$buildArch = Get-Content "build.arch" -Raw
$buildArch = $buildArch.Trim()
if ($buildArch -ne $env:TARGET) {
Write-Host "Build is configured for '$buildArch' while current target set to '$($env:TARGET)'!" -ForegroundColor Red
Write-Host "Cannot continue until conflict is resolved..." -ForegroundColor Red
return 1
}
}
& ninja @Arguments
return $LASTEXITCODE
}
# Legacy function aliases for backwards compatibility
Set-Alias -Name banner -Value Show-XTCBanner
Set-Alias -Name charch -Value Set-XTCArchitecture
Set-Alias -Name chbuild -Value Set-XTCBuildType
Set-Alias -Name help -Value Show-XTCHelp
Set-Alias -Name version -Value Show-XTCVersion
Set-Alias -Name xbuild -Value Invoke-XTCBuild
# Export functions and aliases
Export-ModuleMember -Function Show-XTCBanner, Set-XTCArchitecture, Set-XTCBuildType, Show-XTCHelp, Show-XTCVersion, Invoke-XTCBuild
Export-ModuleMember -Alias banner, charch, chbuild, help, version, xbuild