| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- $ErrorActionPreference = "Stop"
- try {
- if ([string]::IsNullOrWhiteSpace($env:OSS_CAD_SUITE_ROOT)) {
- throw "OSS_CAD_SUITE_ROOT is not set"
- }
- if ([string]::IsNullOrWhiteSpace($env:VERILATOR)) {
- throw "VERILATOR is not set"
- }
- if (-not [System.IO.Path]::IsPathRooted($env:OSS_CAD_SUITE_ROOT)) {
- throw "OSS_CAD_SUITE_ROOT must be absolute"
- }
- if (-not [System.IO.Path]::IsPathRooted($env:VERILATOR)) {
- throw "VERILATOR must be absolute"
- }
- $ExpectedBin = [System.IO.Path]::GetFullPath(
- (Join-Path $env:OSS_CAD_SUITE_ROOT "bin")
- ).TrimEnd("\")
- $Native = [System.IO.Path]::GetFullPath($env:VERILATOR)
- $NativeItem = Get-Item -LiteralPath $Native -ErrorAction Stop
- if ($NativeItem.PSIsContainer) {
- throw "VERILATOR must name a file"
- }
- if (($NativeItem.Attributes -band [System.IO.FileAttributes]::ReparsePoint) -ne 0) {
- throw "VERILATOR cannot be a reparse point"
- }
- if ($NativeItem.Name -notin @("verilator_bin.exe", "verilator.exe")) {
- throw "VERILATOR must name verilator_bin.exe or verilator.exe"
- }
- if (-not [string]::Equals(
- $NativeItem.DirectoryName.TrimEnd("\"),
- $ExpectedBin,
- [System.StringComparison]::OrdinalIgnoreCase
- )) {
- throw "VERILATOR must be under OSS_CAD_SUITE_ROOT\bin"
- }
- } catch {
- [Console]::Error.WriteLine("Unsafe Verilator configuration: $($_.Exception.Message)")
- exit 126
- }
- & $Native @args
- exit $LASTEXITCODE
|