-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdepcheck.ps1
66 lines (59 loc) · 2.27 KB
/
depcheck.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
57
58
59
60
61
62
63
64
65
66
# check_prerequisites.ps1
# Function to check if a command is available
function Test-Command($command) {
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = 'stop'
try { if (Get-Command $command) { return $true } }
catch { return $false }
finally { $ErrorActionPreference = $oldPreference }
}
# Function to check .NET SDK version
function Check-DotNetSDK {
if (Test-Command "dotnet") {
$version = (dotnet --version)
if ([version]$version -ge [version]"8.0") {
Write-Host ".NET SDK $version is installed." -ForegroundColor Green
} else {
Write-Host ".NET SDK 8.0 or later is required. Current version: $version" -ForegroundColor Red
}
} else {
Write-Host ".NET SDK is not installed." -ForegroundColor Red
}
}
# Function to check Go version
function Check-Go {
if (Test-Command "go") {
$version = (go version) -replace "go version go" -split " " | Select-Object -First 1
if ([version]$version -ge [version]"1.22.2") {
Write-Host "Go $version is installed." -ForegroundColor Green
} else {
Write-Host "Go 1.22.2 or later is required. Current version: $version" -ForegroundColor Red
}
} else {
Write-Host "Go is not installed." -ForegroundColor Red
}
}
# Function to check 64-bit GCC
function Check-GCC64 {
if (Test-Command "gcc") {
$gccOutput = gcc --version
$versionLine = $gccOutput | Select-Object -First 1
if ($versionLine -match "tdm64") {
$version = $versionLine -replace "gcc\.exe \(tdm64-\d+\) "
Write-Host "64-bit TDM-GCC $version is installed." -ForegroundColor Green
} elseif ($gccOutput | Select-String "Target: x86_64") {
$version = $versionLine -replace "gcc \(.*\) "
Write-Host "64-bit GCC $version is installed." -ForegroundColor Green
} else {
Write-Host "64-bit GCC is required. Found: $versionLine" -ForegroundColor Red
}
} else {
Write-Host "GCC is not installed." -ForegroundColor Red
}
}
# Main script
Write-Host "Checking prerequisites for D2Sharp project..." -ForegroundColor Cyan
Check-DotNetSDK
Check-Go
Check-GCC64
Write-Host "`nPrerequisite check completed." -ForegroundColor Cyan