From debc7725817a175aa2bad8ac6c1c07dc8fb2bc45 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 24 Jun 2016 09:41:03 +0200 Subject: Reworked standard libraries compile flow (std, ieee, ...). Fixed GHDL version test issue. Extended .gitignore to exclude generated files on Windows and Linux. --- .gitignore | 23 +- dist/mcode/winbuild.ps1 | 39 +- dist/mcode/windows/compile-ghdl.ps1 | 250 ++++++++++ dist/mcode/windows/compile-libraries.ps1 | 800 +++++++++++++++++++++++++++++++ dist/mcode/windows/compile.ps1 | 249 ---------- dist/mcode/windows/complib.ps1 | 741 ---------------------------- dist/mcode/windows/shared.psm1 | 249 +++++++++- dist/mcode/windows/targets.psm1 | 16 +- libraries/vendors/shared.psm1 | 21 +- 9 files changed, 1344 insertions(+), 1044 deletions(-) create mode 100644 dist/mcode/windows/compile-ghdl.ps1 create mode 100644 dist/mcode/windows/compile-libraries.ps1 delete mode 100644 dist/mcode/windows/compile.ps1 delete mode 100644 dist/mcode/windows/complib.ps1 diff --git a/.gitignore b/.gitignore index ea40cf1c5..a962850ed 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,30 @@ b~*.ad? *.v87 *.v93 *.v08 +*.cf + +testsuite/get_entities # Generated files on windows. +build/ dist/mcode/build/ dist/mcode/lib/ -testsuite/get_entities +# Generated directories on Linux +lib/ + +# Generated files on Linux +Makefile +config.status +default_pathes.ads +elf_arch.ads +ghdl.gpr +ghdl1-* +ghdl_llvm +grt-backtraces-impl.ads +grt-files +grt-files.in +grt.lst +libgrt.a +run-bind.adb +run-bind.ads diff --git a/dist/mcode/winbuild.ps1 b/dist/mcode/winbuild.ps1 index 19accd514..0c4c83d44 100644 --- a/dist/mcode/winbuild.ps1 +++ b/dist/mcode/winbuild.ps1 @@ -3,12 +3,12 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== -# PowerShell Script: Script to compile GHDL for Windows -# # Authors: Patrick Lehmann (ported batch file to PowerShell) # Brian Davis (contributions to the batch file) # Tristan Gingold (initial batch file for compilations on Windows) # +# PowerShell Script: Script to compile GHDL for Windows +# # Description: # ------------------------------------ # This is a PowerShell script (executable) which: @@ -18,6 +18,7 @@ # # ============================================================================== # Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold +# Copyright (C) 2015-2016 Patrick Lehmann # # GHDL is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -66,8 +67,6 @@ Param( [switch]$CreatePackage, # creates a zip-file for xcopy deployment [switch]$Zip, - # creates a exe-file (installer generated by NSIS) - [switch]$Nsis, # install all files into a directory (xcopy deployment) [switch]$Install, @@ -215,19 +214,19 @@ else Write-Host "Removing all created files and directories..." if ($Script_ExitCode -eq 0) - { $Script_Path = $GHDLWindowsDir + "\compile.ps1" + { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" $Script_Parameters = @('-Clean') #$Script_Parameters += '-Clean' if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' } if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' } - Write-Host "Running compile.ps1 ..." + Write-Host "Running compile-ghdl.ps1 ..." Write-Host "--------------------------------------------------------------------------------" Invoke-Expression "$Script_Path $($Script_Parameters -join " ")" if ($LastExitCode -ne 0) { $Script_ExitCode = 1 Write-Host "--------------------------------------------------------------------------------" - Write-Host "ERROR while executing 'compile.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red + Write-Host "ERROR while executing 'compile-ghdl.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red } else { Write-Host "--------------------------------------------------------------------------------" @@ -238,19 +237,19 @@ else } if ($Script_ExitCode -eq 0) - { $Script_Path = $GHDLWindowsDir + "\compile.ps1" + { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" $Script_Parameters = @() $Script_Parameters += '-Clean' if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' } if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' } - Write-Host "Running complib.ps1 ..." + Write-Host "Running compile-libraries.ps1 ..." Write-Host "--------------------------------------------------------------------------------" Invoke-Expression "$Script_Path $($Script_Parameters -join " ")" if ($LastExitCode -ne 0) { $Script_ExitCode = 1 Write-Host "--------------------------------------------------------------------------------" - Write-Host "ERROR while executing 'complib.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red + Write-Host "ERROR while executing 'compile-libraries.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red } else { Write-Host "--------------------------------------------------------------------------------" @@ -282,19 +281,19 @@ else Write-Host "Compiling GHDL $GHDLVersion for Windows" if ($Script_ExitCode -eq 0) - { $Script_Path = $GHDLWindowsDir + "\compile.ps1" + { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" $Script_Parameters = @() $Script_Parameters += '-All' if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' } if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' } - Write-Host "Running compile.ps1 ..." + Write-Host "Running compile-ghdl.ps1 ..." Write-Host "--------------------------------------------------------------------------------" Invoke-Expression "$Script_Path $($Script_Parameters -join " ")" if ($LastExitCode -ne 0) { $Script_ExitCode = 1 Write-Host "--------------------------------------------------------------------------------" - Write-Host "ERROR while executing 'compile.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red + Write-Host "ERROR while executing 'compile-ghdl.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red } else { Write-Host "--------------------------------------------------------------------------------" @@ -305,19 +304,21 @@ else } if ($Script_ExitCode -eq 0) - { $Script_Path = $GHDLWindowsDir + "\complib.ps1" + { $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1" $Script_Parameters = @() $Script_Parameters += '-Compile' if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' } if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' } - Write-Host "Running complib.ps1 ..." + $env:GHDL = "$GHDLBuildDir\ghdl.exe" + + Write-Host "Running compile-libraries.ps1 ..." Write-Host "--------------------------------------------------------------------------------" Invoke-Expression "$Script_Path $($Script_Parameters -join " ")" if ($LastExitCode -ne 0) { $Script_ExitCode = 1 Write-Host "--------------------------------------------------------------------------------" - Write-Host "ERROR while executing 'complib.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red + Write-Host "ERROR while executing 'compile-libraries.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red } else { Write-Host "--------------------------------------------------------------------------------" @@ -373,12 +374,6 @@ else $file = Get-ChildItem $GHDLZipPackageDir -Recurse | Write-Zip -IncludeEmptyDirectories -EntryPathRoot $GHDLZipPackageDir -OutputPath $GHDLZipPackageFile Write-Host " $([math]::round(($file.Length / 1MB), 3)) MiB written to disk" } - elseif (($Script_ExitCode -eq 0) -and $Nsis) - { Write-Host "Output format: exe-file (created by NSIS)" - - $Script_ExitCode = 1 - Write-Host "ERROR: Not Implemented." -ForegroundColor RED - } else { $Script_ExitCode = 1 Write-Host "No package format selected." -ForegroundColor Red diff --git a/dist/mcode/windows/compile-ghdl.ps1 b/dist/mcode/windows/compile-ghdl.ps1 new file mode 100644 index 000000000..7bfa62fbb --- /dev/null +++ b/dist/mcode/windows/compile-ghdl.ps1 @@ -0,0 +1,250 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann (ported batch file to PowerShell) +# Brian Davis (contributions to the batch file) +# Tristan Gingold (initial batch file for compilations on Windows) +# +# PowerShell Script: Script to compile GHDL for Windows +# +# Description: +# ------------------------------------ +# This is a PowerShell script (executable) which: +# - sets up a compilation environment +# - test all dependencies +# - compiles GHDL with GNAT +# +# ============================================================================== +# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold +# Copyright (C) 2015-2016 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== +<# + .SYNOPSIS + GHDL for Windows - GHDL compile script + Use 'compile.ps1 -Help' to see the integrated help page + + .EXAMPLE + C:\PS> .\compile.ps1 -Clean -Compile +#> + +# define script parameters +[CmdletBinding()] +Param( + # compile ALL + [switch]$All = $false, + + # compile main targets + [switch]$Compile = $false, + # compile GHDL (simulator) + [switch]$GHDL = $false, + [switch]$Test = $false, + + # compile TOOLS + [switch]$Tools = $false, + # compile Filter (helper) + [switch]$Filter = $false, + + # build options + [switch]$Release = $false, + + # clean up all files and directories + [switch]$Clean = $false, + + # display this help" + [switch]$Help = $false +) + +# configure script here +$Script_RelPathToRoot = "..\..\.." + +# save parameters and current working directory +$Script_Parameters = $args +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $Script_RelPathToRoot)) + +# set default values +$Script_ExitCode = 0 +$BuildRelease = "Development" # "Release" + +if ($All) +{ $Compile = $true + $Tools = $true +} +if ($Compile) +{ $GHDL = $true + $Test = $true +} +if ($Tools) +{ $Filter = $true +} + +if ($Release) +{ $BuildRelease = "Release" } +else +{ $BuildRelease = "Development" } + +$NoCommand = -not ($Clean -or $All -or $Compile -or $Tools -or $GHDL -or $Test -or $Filter) +if ($NoCommand) +{ $Help = $true } + +Write-Host "================================================================================" -ForegroundColor Magenta +Write-Host "GHDL for Windows - GHDL and tools compile script" -ForegroundColor Magenta +Write-Host "================================================================================" -ForegroundColor Magenta + +# if command is help or no command was given => display help page(s) +if ($Help) +{ Write-Host "Usage:" + Write-Host " compile.ps1 (-Help|-Clean|-All|-Compile|-Tools|-GHDL|-Test|-Filter)" -ForegroundColor Gray + Write-Host + Write-Host "Options:" + Write-Host " -Release build in release mode" + # Write-Host " -Debug enable debug messages" + # Write-Host + Write-Host "Commands:" + Write-Host " -Help display this help" + Write-Host " -All compile all targets" + Write-Host " -Compile compile all main targets" + Write-Host " -Tools compile all tool targets" + Write-Host " -GHDL compile ghdl.exe" + Write-Host " -Filter compile filter.exe" + Write-Host " -Clean clean up all files and directories" + Write-Host + + exit 0 +} # Help + +# load modules +Import-Module $PSScriptRoot\shared.psm1 +Import-Module $PSScriptRoot\targets.psm1 + +# grep GHDL version string from Ada source file +$GHDLVersion = Get-GHDLVersion $GHDLRootDir + +# gather git information +$Git_IsGitRepo = Test-GitRepository +if ($Git_IsGitRepo) +{ $Git_Branch_Name = & git rev-parse --abbrev-ref HEAD + $Git_Commit_DataString = & git log -1 --format=%cd --date=short + $Git_Commit_ShortHash = & git rev-parse --short HEAD +} + +Write-Host " Version: $GHDLVersion" +Write-Host " Release: $BuildRelease" +if ($Git_IsGitRepo) +{ Write-Host " Git branch: $Git_Branch_Name" + Write-Host " Git commit: $Git_Commit_DataString ($Git_Commit_ShortHash)" +} +Write-Host + +function Write-TargetResult($error) +{ if ($error) + { Write-Host " [FAILED]" -ForegroundColor Red } + # else + # { Write-Host " [DONE]" -ForegroundColor Green } +} + +if ($BuildRelease -eq "Release") +{ $BuildDir = $GHDLRootDir + "\dist\mcode\build" } +elseif ($BuildRelease -eq "Development") +{ $BuildDir = $GHDLRootDir + "\dist\mcode\build" } +else +{ Write-Host "[ERROR]: Unknown build setting '$BuildRelease'." -ForegroundColor Red + exit 1 +} + +# ============================================================================== +# Main Target: Clean +# ============================================================================== +if ($Clean) +{ $error = Invoke-Clean $BuildDir + Write-TargetResult $error +} # Clean + + +# ============================================================================== +# Main Target: GHDL +# ============================================================================== +if ($GHDL) +{ # create a build directory + $error = Invoke-CreateBuildDirectory $BuildDir + Write-TargetResult $error + + # patch the version file if it's no release build + if ((-not $error) -and ($BuildRelease -eq "Development") -and $Git_IsGitRepo) + { $error = Invoke-PatchVersionFile $GHDLRootDir $Git_Branch_Name $Git_Commit_DataString $Git_Commit_ShortHash + Write-TargetResult $error + } + + # build C source files + if (-not $error) + { $error = Invoke-CompileCFiles $GHDLRootDir $BuildDir + Write-TargetResult $error + } + + # build Ada source files + if (-not $error) + { $error = Invoke-CompileGHDLAdaFiles $GHDLRootDir $BuildDir + Write-TargetResult $error + } + + # strip result + if (-not $error) + { $error = Invoke-StripGHDLExecutable $BuildDir + Write-TargetResult $error + } + + # restore the version file if it was patched + if ((-not $error) -and ($BuildRelease -eq "Development") -and $Git_IsGitRepo) + { $error = Restore-PatchedVersionFile $GHDLRootDir + Write-TargetResult $error + } +} # Compile + +if ($Test) +{ # running ghdl + $error = Test-GHDLVersion $BuildDir + Write-TargetResult $error +} # Test + +# ============================================================================== +# Tool Target: Filter +# ============================================================================== +if ($Filter) +{ # create a build directory + $error = Invoke-CreateBuildDirectory $BuildDir + Write-TargetResult $error + + # build Ada source files + if (-not $error) + { $error = Invoke-CompileFilterAdaFiles $GHDLRootDir $BuildDir + Write-TargetResult $error + } +} # Tools + + +# unload PowerShell modules +Remove-Module shared +Remove-Module targets + +# restore working directory if changed +Set-Location $Script_WorkingDir + +# return exit status +exit $Script_ExitCode diff --git a/dist/mcode/windows/compile-libraries.ps1 b/dist/mcode/windows/compile-libraries.ps1 new file mode 100644 index 000000000..dc7cbb57e --- /dev/null +++ b/dist/mcode/windows/compile-libraries.ps1 @@ -0,0 +1,800 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann (ported batch file to PowerShell) +# Brian Davis (contributions to the batch file) +# Tristan Gingold (initial batch file for compilations on Windows) +# +# PowerShell Script: Script to compile VHDL libraries for GHDL +# +# Description: +# ------------------------------------ +# This is a PowerShell script (executable) which: +# - sets up a compilation environment +# - test all dependencies +# - pre processes VHDL files with GHDLFilter +# - analyses VHDL files with GHDL +# +# ============================================================================== +# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold +# Copyright (C) 2015-2016 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== + +# .SYNOPSIS +# GHDL for Windows - Library compile script +# Use 'complib.ps1 -Help' to see the integrated help page +# +# .EXAMPLE +# C:\PS> .\complib.ps1 -Verbose -Compile +# .EXAMPLE +# C:\PS> .\complib.ps1 -Verbose -Clean +# +[CmdletBinding()] +param( + # Display this help" + [switch]$Help = $false, + + # Clean up all files and directories + [switch]$Clean = $false, + + # Compile all library files + [switch]$Compile = $false, + + # Set VHDL Standard to '87 + [switch]$VHDL87 = $false, + # Set VHDL Standard to '93 + [switch]$VHDL93 = $false, + # Set VHDL Standard to '08 + [switch]$VHDL2008 = $false, + + # Skip warning messages. (Show errors only.) + [switch]$SuppressWarnings = $false, + # Halt on errors + [switch]$HaltOnError = $false, + + # Set GHDL executable + [string]$GHDL = "" +) + +# configure script here +$Script_RelPathToRoot = "..\..\.." + +# --------------------------------------------- +# save parameters and working directory +$Script_Parameters = $args +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $Script_RelPathToRoot)) + +# set default values +$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent +$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -ArgumentList "$Script_WorkingDir" + +# Display help if no command was selected +$Help = $Help -or (-not ($Compile -or $VHDL87 -or $VHDL93 -or $VHDL2008 -or $Clean)) + +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} +if ($Compile) +{ $VHDL87 = $true + $VHDL93 = $true + $VHDL2008 = $true +} + +# configure some variables: paths, executables, directory names, ... +$VHDLLibrariesSourceDirectoryName = "libraries" +$VHDLLibrariesDestinationDirectoryName = "lib" +$BuildDirectoryName = "build" +$Backend = "mcode" + +# construct directories +$VHDLSourceLibraryDirectory = "$GHDLRootDir\$VHDLLibrariesSourceDirectoryName" +$VHDLDestinationLibraryDirectory = "$GHDLRootDir\$BuildDirectoryName\$Backend\$VHDLLibrariesDestinationDirectoryName" +# construct executables +$GHDLNewExecutable = "$GHDLRootDir\$BuildDirectoryName\$Backend\bin\ghdl.exe" + +# get GHDL executable +if ($GHDL -ne "") +{ $GHDLExecutable = $GHDL } +elseif (Test-Path env:GHDL) +{ $GHDLExecutable = $env:GHDL } +elseif (Test-Path $GHDLNewExecutable -PathType Leaf) +{ $GHDLExecutable = $GHDLNewExecutable } +else +{ $GHDLExecutable = "ghdl.exe" } + +if (-not (Test-Path $GHDLExecutable -PathType Leaf)) +{ Write-Host "GHDL executable 'ghdl.exe' not found." -ForegroundColor Red + Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Yellow + Exit-CompileScript -1 +} + + +# Library sources +$SourceFiles = @{ + "std" = @( + "textio", "textio_body" + ); + "ieee" = @( + "std_logic_1164", "std_logic_1164_body", + "numeric_std", "numeric_std-body", + "numeric_bit", "numeric_bit-body" + ); + "math" = @( + "math_real", "math_real-body", + "math_complex", "math_complex-body" + ); + "std08" = @( + "textio", "textio_body", + "env", "env_body" + ); + "ieee2008" = @( + "std_logic_1164", "std_logic_1164-body", + "std_logic_textio", + "math_real", "math_real-body", + "math_complex", "math_complex-body", + "numeric_bit", "numeric_bit-body", + "numeric_bit_unsigned", "numeric_bit_unsigned-body", + "numeric_std", "numeric_std-body", + "numeric_std_unsigned", "numeric_std_unsigned-body", + "fixed_float_types", + "fixed_generic_pkg", "fixed_generic_pkg-body", + "fixed_pkg", + "float_generic_pkg", "float_generic_pkg-body", + "float_pkg", + "ieee_std_context", + "ieee_bit_context" + ); + "vital95" = @( + "vital_timing", "vital_timing_body", + "vital_primitives", "vital_primitives_body" + ); + "vital2000" = @( + "timing_p", "timing_b", + "prmtvs_p", "prmtvs_b", + "memory_p", "memory_b" + ); + "synopsys" = @( + "std_logic_arith", + "std_logic_unsigned", + "std_logic_signed" + ); + "synopsys8793" = @( + "std_logic_textio", + "std_logic_misc", "std_logic_misc-body" + ); + "mentor" = @( + "std_logic_arith", "std_logic_arith_body" + ) +} + +Write-Host "================================================================================" -ForegroundColor Yellow +Write-Host "GHDL ($Backend) for Windows - Library compile script" -ForegroundColor Yellow +Write-Host "================================================================================" -ForegroundColor Yellow + +if ($Clean) +{ Write-Host "Removing all created files and directories..." + Write-Host " rmdir $VHDLDestinationLibraryDirectory" + + Remove-Item $VHDLDestinationLibraryDirectory -Force -Recurse -ErrorAction SilentlyContinue + + Exit-CompileScript +} + + +$ErrorCount = 0 +if ($VHDL87 -or $VHDL93 -or $VHDL2008) +{ Write-Host "Compiling VHDL Libraries..." + Write-Host "Preparing..." + + # create lib directory if it does not exist + if (Test-Path -Path $VHDLDestinationLibraryDirectory) + { Write-Host " Directory '$VHDLDestinationLibraryDirectory' already exists." + + # change working directory to VHDLDestinationLibraryDirectory + Write-Host " cd $VHDLDestinationLibraryDirectory" + Set-Location $VHDLDestinationLibraryDirectory + + Write-Host " Cleaning up directory..." + Remove-Item ./* -Force -Recurse -ErrorAction SilentlyContinue + } + else + { Write-Host " Creating directory '$VHDLDestinationLibraryDirectory'." + New-Item -ItemType Directory -Path $VHDLDestinationLibraryDirectory -ErrorAction SilentlyContinue | Out-Null + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: Cannot create destination directory '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red + Exit-CompileScript -1 + } + + # change working directory to VHDLDestinationLibraryDirectory + Write-Host " Change working directory to $VHDLDestinationLibraryDirectory" + Set-Location $VHDLDestinationLibraryDirectory + } + + Write-Host + Write-Host "Start compilation..." +} + + + + +# ============================================================================ +# v87 +# ============================================================================ +if ($VHDL87) +{ $VHDLVersion = "87" + $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" + Write-Host "VHDL-$VHDLVersion" -ForegroundColor Cyan + + # ---------------------------------------------------------------------- + # v87\std + # ---------------------------------------------------------------------- + $VHDLLibrary = "std" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLLibrary" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "std" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v87\ieee + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "ieee" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLFlavor" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v87\synopsys + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "synopsys" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLFlavor" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles["synopsys"] + $SourceFiles["synopsys8793"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital95" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } +} +# ============================================================================ +# v93 +# ============================================================================ +if ($VHDL93) +{ $VHDLVersion = "93" + $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" + Write-Host "VHDL-$VHDLVersion" -ForegroundColor Cyan + + # ---------------------------------------------------------------------- + # v93\std + # ---------------------------------------------------------------------- + $VHDLLibrary = "std" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLLibrary" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "std" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v93\ieee + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "ieee" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLFlavor" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v93\synopsys + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "synopsys" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLFlavor" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles[$VHDLFlavor] + $SourceFiles["synopsys8793"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v93\mentor + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "mentor" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLFlavor" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles[$VHDLFlavor]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } +} +# ============================================================================== +# v08 +# ============================================================================== +if ($VHDL2008) +{ $VHDLVersion = "08" + $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" + Write-Host "VHDL-$VHDLVersion" -ForegroundColor Cyan + + # ---------------------------------------------------------------------- + # v08\std + # ---------------------------------------------------------------------- + $VHDLLibrary = "std" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLLibrary" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "std08" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLLibrary\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v08\ieee + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "ieee" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLFlavor" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee2008" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" -frelaxed-rules --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v08\synopsys + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "synopsys" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VersionedDirectory\$VHDLFlavor" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee2008" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles[$VHDLFlavor]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" -frelaxed-rules --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + +} # $VHDL2008 + + +Write-Host "--------------------------------------------------------------------------------" +Write-Host "Compiling VHDL libraries " -NoNewline +if ($ErrorCount -gt 0) +{ Write-Host "[FAILED]" -ForegroundColor Red } +else +{ Write-Host "[SUCCESSFUL]" -ForegroundColor Green } + +Exit-CompileScript diff --git a/dist/mcode/windows/compile.ps1 b/dist/mcode/windows/compile.ps1 deleted file mode 100644 index 5021d01fc..000000000 --- a/dist/mcode/windows/compile.ps1 +++ /dev/null @@ -1,249 +0,0 @@ -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# -# ============================================================================== -# PowerShell Script: Script to compile GHDL for Windows -# -# Authors: Patrick Lehmann (ported batch file to PowerShell) -# Brian Davis (contributions to the batch file) -# Tristan Gingold (initial batch file for compilations on Windows) -# -# Description: -# ------------------------------------ -# This is a PowerShell script (executable) which: -# - sets up a compilation environment -# - test all dependencies -# - compiles GHDL with GNAT -# -# ============================================================================== -# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold -# -# GHDL is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2, or (at your option) any later -# version. -# -# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with GHDL; see the file COPYING. If not, write to the Free -# Software Foundation, 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. -# ============================================================================== -<# - .SYNOPSIS - GHDL for Windows - GHDL compile script - Use 'compile.ps1 -Help' to see the integrated help page - - .EXAMPLE - C:\PS> .\compile.ps1 -Clean -Compile -#> - -# define script parameters -[CmdletBinding()] -Param( - # compile ALL - [switch]$All = $false, - - # compile main targets - [switch]$Compile = $false, - # compile GHDL (simulator) - [switch]$GHDL = $false, - [switch]$Test = $false, - - # compile TOOLS - [switch]$Tools = $false, - # compile Filter (helper) - [switch]$Filter = $false, - - # build options - [switch]$Release = $false, - - # clean up all files and directories - [switch]$Clean = $false, - - # display this help" - [switch]$Help = $false -) - -# configure script here -$Script_RelPathToRoot = "..\..\.." - -# save parameters and current working directory -$Script_Parameters = $args -$Script_WorkingDir = Get-Location -$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $Script_RelPathToRoot)) - -# set default values -$Script_ExitCode = 0 -$BuildRelease = "Development" # "Release" - -if ($All) -{ $Compile = $true - $Tools = $true -} -if ($Compile) -{ $GHDL = $true - $Test = $true -} -if ($Tools) -{ $Filter = $true -} - -if ($Release) -{ $BuildRelease = "Release" } -else -{ $BuildRelease = "Development" } - -$NoCommand = -not ($Clean -or $All -or $Compile -or $Tools -or $GHDL -or $Test -or $Filter) -if ($NoCommand) -{ $Help = $true } - -Write-Host "================================================================================" -ForegroundColor Magenta -Write-Host "GHDL for Windows - GHDL and tools compile script" -ForegroundColor Magenta -Write-Host "================================================================================" -ForegroundColor Magenta - -# if command is help or no command was given => display help page(s) -if ($Help) -{ Write-Host "Usage:" - Write-Host " compile.ps1 (-Help|-Clean|-All|-Compile|-Tools|-GHDL|-Test|-Filter)" -ForegroundColor Gray - Write-Host - Write-Host "Options:" - Write-Host " -Release build in release mode" - # Write-Host " -Debug enable debug messages" - # Write-Host - Write-Host "Commands:" - Write-Host " -Help display this help" - Write-Host " -All compile all targets" - Write-Host " -Compile compile all main targets" - Write-Host " -Tools compile all tool targets" - Write-Host " -GHDL compile ghdl.exe" - Write-Host " -Filter compile filter.exe" - Write-Host " -Clean clean up all files and directories" - Write-Host - - exit 0 -} # Help - -# load modules -Import-Module $PSScriptRoot\shared.psm1 -Import-Module $PSScriptRoot\targets.psm1 - -# grep GHDL version string from Ada source file -$GHDLVersion = Get-GHDLVersion $GHDLRootDir - -# gather git information -$Git_IsGitRepo = Test-GitRepository -if ($Git_IsGitRepo) -{ $Git_Branch_Name = & git rev-parse --abbrev-ref HEAD - $Git_Commit_DataString = & git log -1 --format=%cd --date=short - $Git_Commit_ShortHash = & git rev-parse --short HEAD -} - -Write-Host " Version: $GHDLVersion" -Write-Host " Release: $BuildRelease" -if ($Git_IsGitRepo) -{ Write-Host " Git branch: $Git_Branch_Name" - Write-Host " Git commit: $Git_Commit_DataString ($Git_Commit_ShortHash)" -} -Write-Host - -function Write-TargetResult($error) -{ if ($error) - { Write-Host " [FAILED]" -ForegroundColor Red } - # else - # { Write-Host " [DONE]" -ForegroundColor Green } -} - -if ($BuildRelease -eq "Release") -{ $BuildDir = $GHDLRootDir + "\dist\mcode\build" } -elseif ($BuildRelease -eq "Development") -{ $BuildDir = $GHDLRootDir + "\dist\mcode\build" } -else -{ Write-Host "[ERROR]: Unknown build setting '$BuildRelease'." -ForegroundColor Red - exit 1 -} - -# ============================================================================== -# Main Target: Clean -# ============================================================================== -if ($Clean) -{ $error = Invoke-Clean $BuildDir - Write-TargetResult $error -} # Clean - - -# ============================================================================== -# Main Target: GHDL -# ============================================================================== -if ($GHDL) -{ # create a build directory - $error = Invoke-CreateBuildDirectory $BuildDir - Write-TargetResult $error - - # patch the version file if it's no release build - if ((-not $error) -and ($BuildRelease -eq "Development") -and $Git_IsGitRepo) - { $error = Invoke-PatchVersionFile $GHDLRootDir $Git_Branch_Name $Git_Commit_DataString $Git_Commit_ShortHash - Write-TargetResult $error - } - - # build C source files - if (-not $error) - { $error = Invoke-CompileCFiles $GHDLRootDir $BuildDir - Write-TargetResult $error - } - - # build Ada source files - if (-not $error) - { $error = Invoke-CompileGHDLAdaFiles $GHDLRootDir $BuildDir - Write-TargetResult $error - } - - # strip result - if (-not $error) - { $error = Invoke-StripGHDLExecutable $BuildDir - Write-TargetResult $error - } - - # restore the version file if it was patched - if ((-not $error) -and ($BuildRelease -eq "Development") -and $Git_IsGitRepo) - { $error = Restore-PatchedVersionFile $GHDLRootDir - Write-TargetResult $error - } -} # Compile - -if ($Test) -{ # running ghdl - $error = Test-GHDLVersion $BuildDir - Write-TargetResult $error -} # Test - -# ============================================================================== -# Tool Target: Filter -# ============================================================================== -if ($Filter) -{ # create a build directory - $error = Invoke-CreateBuildDirectory $BuildDir - Write-TargetResult $error - - # build Ada source files - if (-not $error) - { $error = Invoke-CompileFilterAdaFiles $GHDLRootDir $BuildDir - Write-TargetResult $error - } -} # Tools - - -# unload PowerShell modules -Remove-Module shared -Remove-Module targets - -# restore working directory if changed -Set-Location $Script_WorkingDir - -# return exit status -exit $Script_ExitCode diff --git a/dist/mcode/windows/complib.ps1 b/dist/mcode/windows/complib.ps1 deleted file mode 100644 index 7bdcd00c3..000000000 --- a/dist/mcode/windows/complib.ps1 +++ /dev/null @@ -1,741 +0,0 @@ -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# -# ============================================================================== -# PowerShell Script: Script to compile VHDL libraries for GHDL -# -# Authors: Patrick Lehmann (ported batch file to PowerShell) -# Brian Davis (contributions to the batch file) -# Tristan Gingold (initial batch file for compilations on Windows) -# -# Description: -# ------------------------------------ -# This is a PowerShell script (executable) which: -# - sets up a compilation environment -# - test all dependencies -# - pre processes VHDL files with GHDLFilter -# - analyses VHDL files with GHDL -# -# ============================================================================== -# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold -# -# GHDL is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2, or (at your option) any later -# version. -# -# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with GHDL; see the file COPYING. If not, write to the Free -# Software Foundation, 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. -# ============================================================================== -<# - .SYNOPSIS - GHDL for Windows - Library compile script - Use 'complib.ps1 -Help' to see the integrated help page - - .EXAMPLE - C:\PS> .\complib.ps1 -Verbose -Compile - .EXAMPLE - C:\PS> .\complib.ps1 -Verbose -Clean -#> - -# define script parameters -[CmdletBinding()] -Param( - # compile all library files - [switch]$Compile, - - # clean up all files and directories - [switch]$Clean, - - # display this help" - [switch]$Help -) - -# configure script here -$Script_RelPathToRoot = "..\..\.." - -# set default values -$Script_ExitCode = 0 -if ($PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent) { $Script_EnableDebug = $true } -if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) { $Script_EnableVerbose = $true } - -# save parameters and current working directory -$Script_Parameters = $args -$Script_ScriptDir = $PSScriptRoot -$Script_WorkingDir = Get-Location -$GHDLRootDir_AbsPath = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $Script_RelPathToRoot)) - -# configure some variables: paths, executables, directory names, ... -#$VHDLSourceLibraryDirName = "libraries" -#$VHDLDestLibraryDirName = "lib" - -$GHDLExecutable = $GHDLRootDir_AbsPath + "\dist\mcode\build\ghdl.exe" -$GHDLFilterExecutable = $GHDLRootDir_AbsPath + "\dist\mcode\build\filter.exe" - -# construct directories -$VHDLSourceLibraryDir = $GHDLRootDir_AbsPath + "\libraries" # + $VHDLSourceLibraryDirName -$VHDLDestLibraryDir = $GHDLRootDir_AbsPath + "\dist\mcode\lib" # + $VHDLDestLibraryDirName - - -Write-Host "GHDL for Windows - Library compile script" -ForegroundColor Yellow -Write-Host - -if ($Help) - { Write-Host "Usage:" - Write-Host " complib.ps1 [-Verbose] [-Debug] (-Help|-Compile|-Clean)" -ForegroundColor Gray - Write-Host - Write-Host "Options:" - Write-Host " -Verbose enable detailed messages" - Write-Host " -Debug enable debug messages" - Write-Host - Write-Host "Commands:" - Write-Host " -Help display this help" - Write-Host " -Compile compile all library files" - Write-Host " -Clean clean up all files and directories" - } -elseif ($Clean) - { Write-Host "Removing all created files and directories..." - Write-Host " rmdir $VHDLDestLibraryDir" - - Remove-Item $VHDLDestLibraryDir -Force -Recurse -ErrorAction SilentlyContinue - } -elseif ($Compile) - { Write-Host "Compiling VHDL Libraries..." - Write-Host "Preparing..." - - # create lib directory if it does not exist - if (Test-Path -Path $VHDLDestLibraryDir) - { Write-Host " Directory '$VHDLDestLibraryDir' already exists." - - # change working directory to VHDLDestLibraryDir - Write-Host " cd $VHDLDestLibraryDir" - Set-Location $VHDLDestLibraryDir - - Write-Host " cleaning up directory..." - Remove-Item ./* -Force -Recurse -ErrorAction SilentlyContinue - } - else - { Write-Host " Creating directory '$VHDLDestLibraryDir'." - [void](New-Item -ItemType directory -Path $VHDLDestLibraryDir -ErrorAction SilentlyContinue) - - # change working directory to VHDLDestLibraryDir - Write-Host " cd $VHDLDestLibraryDir" - Set-Location $VHDLDestLibraryDir - } - - - # Library sources - $SourceFiles = @{ - "std" = @( - "textio", - "textio_body" - ); - "ieee" = @( - "std_logic_1164", - "std_logic_1164_body", - "numeric_std", - "numeric_std-body", - "numeric_bit", - "numeric_bit-body" - ); - "math" = @( - "math_real", - "math_real-body", - "math_complex", - "math_complex-body" - ); - "std08" = @( - "textio", - "textio_body", - "env", - "env_body" - ); - "ieee2008" = @( - "std_logic_1164", - "std_logic_1164-body", - "std_logic_textio", - "math_real", - "math_real-body", - "math_complex", - "math_complex-body", - "numeric_bit", - "numeric_bit-body", - "numeric_bit_unsigned", - "numeric_bit_unsigned-body", - "numeric_std", - "numeric_std-body", - "numeric_std_unsigned", - "numeric_std_unsigned-body", - "fixed_float_types", - "fixed_generic_pkg", - "fixed_generic_pkg-body", - "fixed_pkg", - "float_generic_pkg", - "float_generic_pkg-body", - "float_pkg", - "ieee_std_context", - "ieee_bit_context" - ); - "vital95" = @( - "vital_timing", - "vital_timing_body", - "vital_primitives", - "vital_primitives_body" - ); - "vital2000" = @( - "timing_p", - "timing_b", - "prmtvs_p", - "prmtvs_b", - "memory_p", - "memory_b" - ); - "synopsys" = @( - "std_logic_arith", - "std_logic_textio", - "std_logic_unsigned", - "std_logic_signed", - "std_logic_misc", - "std_logic_misc-body" - ); - "mentor" = @( - "std_logic_arith", - "std_logic_arith_body" - ) - } - - Write-Host - Write-Host "Start compilation..." - -# ============================================================================== -# v87 -# ============================================================================== - # create 'v87' directory if it does not exist - $LocalDirName = "v87" - $LocalDir = $VHDLDestLibraryDir + "\" + $LocalDirName - if (Test-Path -Path $LocalDir) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDirName' already exists." } } - else - { Write-Host " Creating directory '$LocalDirName'." - [void](New-Item -ItemType directory -Path $LocalDir -ErrorAction SilentlyContinue) - } - - Write-Host " compiling into $LocalDirName" - - # ---------------------------------------------------------------------- - # v87\std - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "std" - - # create 'std' directory if it does not exist - $LocalDir2Name = $VHDLDestLibrary - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType Directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "std" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v87\$SourceFile.v87" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v87)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v87') ` - | Out-File "$SourceFile.v87" -Encoding Ascii - - #Write-Host "Press any key to continue..." - #[void]($Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")) - #$Host.UI.RawUI.FlushInputBuffer() - - $GHDLParameters = @("-a", "-C", "--std=87", "--bootstrap", "--work=$VHDLDestLibrary", "$SourceFile.v87") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - - #$Script_ExitCode = 1 - - # ---------------------------------------------------------------------- - # v87\ieee - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "ieee" - - # create 'ieee' directory if it does not exist - $LocalDir2Name = $VHDLDestLibrary - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v87\$SourceFile.v87" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v87)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v87') ` - | Out-File "$SourceFile.v87" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=87", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.v87") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "vital95" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v87\$SourceFile.v87" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=87", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - - # ---------------------------------------------------------------------- - # v87\synopsys - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "ieee" - - # create 'synopsys' directory if it does not exist - $LocalDir2Name = "synopsys" - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v87\$SourceFile.v87" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v87)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v87') ` - | Out-File "$SourceFile.v87" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=87", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.v87") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "vital95" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v87\$SourceFile.v87" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=87", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "synopsys" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v87\$SourceFile.v87" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=87", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - -# ============================================================================== -# v93 -# ============================================================================== - # create 'v93' directory if it does not exist - $LocalDirName = "v93" - $LocalDir = $VHDLDestLibraryDir + "\" + $LocalDirName - if (Test-Path -Path $LocalDir) - { Write-Host " Directory '$LocalDirName' already exists."} - else - { Write-Host " Creating directory '$LocalDirName'." - [void](New-Item -ItemType directory -Path $LocalDir -ErrorAction SilentlyContinue) - } - - Write-Host " compiling into $LocalDirName" - - # ---------------------------------------------------------------------- - # v93\std - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "std" - - # create 'std' directory if it does not exist - $LocalDir2Name = $VHDLDestLibrary - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "std" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v93)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v93') ` - | Out-File "$SourceFile.v93" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=93", "--bootstrap", "--work=$VHDLDestLibrary", "$SourceFile.v93") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - - # ---------------------------------------------------------------------- - # v93\ieee - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "ieee" - - # create 'ieee' directory if it does not exist - $LocalDir2Name = $VHDLDestLibrary - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v93)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v93') ` - | Out-File "$SourceFile.v93" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.v93") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles['math']) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "vital2000" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - - # ---------------------------------------------------------------------- - # v93\synopsys - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "ieee" - - # create 'synopsys' directory if it does not exist - $LocalDir2Name = "synopsys" - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v93)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v93') ` - | Out-File "$SourceFile.v93" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.v93") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles['math']) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "vital2000" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "synopsys" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - - # ---------------------------------------------------------------------- - # v93\mentor - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "ieee" - - # create 'mentor' directory if it does not exist - $LocalDir2Name = "mentor" - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v93)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v93') ` - | Out-File "$SourceFile.v93" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.v93") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "ieee" - foreach ($SourceFile in $SourceFiles['math']) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "vital2000" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.vhd" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "mentor" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v93\$SourceFile.v93" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "--std=93", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - -# ============================================================================== -# v08 -# ============================================================================== - # create 'v08' directory if it does not exist - $LocalDirName = "v08" - $LocalDir = $VHDLDestLibraryDir + "\" + $LocalDirName - if (Test-Path -Path $LocalDir) - { Write-Host " Directory '$LocalDirName' already exists."} - else - { Write-Host " Creating directory '$LocalDirName'." - [void](New-Item -ItemType directory -Path $LocalDir -ErrorAction SilentlyContinue) - } - - Write-Host " compiling into $LocalDirName" - - # ---------------------------------------------------------------------- - # v08\std - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "std" - - # create 'std' directory if it does not exist - $LocalDir2Name = $VHDLDestLibrary - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "std" - $VHDLSrcLibraryFiles = "std08" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibraryFiles]) - { Write-Host " file: v08\$SourceFile.v08" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v08)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v08') ` - | Out-File "$SourceFile.v08" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=08", "--bootstrap", "--work=$VHDLDestLibrary", "$SourceFile.v08") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } - - # ---------------------------------------------------------------------- - # v08\ieee - # ---------------------------------------------------------------------- - if ($Script_ExitCode -eq 0) - { $VHDLDestLibrary = "ieee" - - # create 'ieee' directory if it does not exist - $LocalDir2Name = $VHDLDestLibrary - $LocalDir2 = $LocalDir + "\" + $LocalDir2Name - - Write-Host " compiling library $VHDLDestLibrary" -ForegroundColor DarkCyan - if (Test-Path -Path $LocalDir2) - { if ($Script_EnableVerbose) { Write-Host " Directory '$LocalDir2Name' already exists." } } - else - { Write-Host " Creating directory '$LocalDir2Name'." - [void](New-Item -ItemType directory -Path $LocalDir2 -ErrorAction SilentlyContinue) - } - - # change working directory to LocalDir2 - Write-Host " cd $LocalDir2" - Set-Location $LocalDir2 - - $VHDLSrcLibrary = "ieee2008" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v08\$SourceFile.v08" - if ($Script_EnableVerbose) { Write-Host " ghdlfilter (-v08)" } - Get-Content "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" -Encoding Ascii -Raw ` - | & $GHDLFilterExecutable @('-v08') ` - | Out-File "$SourceFile.v08" -Encoding Ascii - - $GHDLParameters = @("-a", "-C", "--std=08", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.v08") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - - $VHDLSrcLibrary = "vital2000" - foreach ($SourceFile in $SourceFiles[$VHDLSrcLibrary]) - { Write-Host " file: v08\$SourceFile.vhd" - if ($Script_EnableVerbose) { Write-Host " copy: $SourceFile" } - Copy-Item "$VHDLSourceLibraryDir\$VHDLSrcLibrary\$SourceFile.vhdl" "$SourceFile.vhd" - - $GHDLParameters = @("-a", "-C", "-frelaxed-rules", "--std=08", "-P..\std", "--work=$VHDLDestLibrary", "$SourceFile.vhd") - if ($Script_EnableVerbose) { Write-Host (" ghdl analyse (" + ($GHDLParameters -join " ") + ")") } - & $GHDLExecutable $GHDLParameters - } - } -# ============================================================================== -# vXX -# ============================================================================== - } # Compile -else - { Write-Host "ERROR: missing argument(s)" -ForegroundColor Red - Write-Host - Write-Host "Usage:" - Write-Host " complib.ps1 [-Verbose] [-Debug] (-Help|-Compile|-Clean)" -ForegroundColor Gray - Write-Host - } # Unknown - -# restore working directory if changed -Set-Location $Script_WorkingDir - -# return exit status -exit $Script_ExitCode \ No newline at end of file diff --git a/dist/mcode/windows/shared.psm1 b/dist/mcode/windows/shared.psm1 index 13ec46ada..5e00b74cf 100644 --- a/dist/mcode/windows/shared.psm1 +++ b/dist/mcode/windows/shared.psm1 @@ -3,10 +3,10 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== -# PowerShell Module: The module provides common CmdLets for ... -# # Authors: Patrick Lehmann # +# PowerShell Module: The module provides common CmdLets for ... +# # Description: # ------------------------------------ # This PowerShell module provides CommandLets (CmdLets) to ... @@ -29,6 +29,129 @@ # Software Foundation, 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # ============================================================================== + +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$WorkingDir +) + +$Module_WorkingDir = $WorkingDir + +function Exit-CompileScript +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER ExitCode + ExitCode of this script run + #> + [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + + cd $Module_WorkingDir + + # unload modules + Remove-Module shared + + exit $ExitCode +} + +function New-LibraryDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER Directory + Undocumented + #> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)][string]$Directory #, + # [Parameter(Mandatory=$true)][bool]$EnableVerbose + ) + $EnableVerbose = $false + if (Test-Path -Path $Directory) + { $EnableVerbose -and (Write-Host " Directory '$Directory' already exists." ) | Out-Null } + else + { Write-Host " Creating directory '$Directory'." + New-Item -ItemType directory -Path $Directory -ErrorAction SilentlyContinue | Out-Null + } +} + +function Format-VHDLSourceFile +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER Version + Undocumented + .PARAMETER InputObject + A object stream is required as an input. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)][string]$Version, + [Parameter(ValueFromPipeline=$true)]$InputObject + ) + + begin + { $State = 1 + $Version = switch ($Version) + { "87" { 87 } + "93" { 93 } + "02" { 2 } + "08" { 8 } + } + } + + process + { if ($InputObject -is [String]) + { $Line = $InputObject.ToString() + if ($Line.StartsWith("--START-V")) + { $State = switch ($Line.Substring(9, 2)) + { "87" { 87 } + "93" { 93 } + "02" { 2 } + "08" { 8 } + } + } + elseif ($Line.StartsWith("--START-!V")) + { if ($Line.Substring(10, 2) -eq $Version) + { $State = 2 } + } + elseif ($Line.StartsWith("--END-V") -or $Line.StartsWith("--END-!V")) + { $State = 1 } + else + { if ($State -eq 1) + { if ($Line.EndsWith("--V$Version")) + { Write-Output $Line } + elseif (-not (($Line -like "*--V??") -or ($Line.EndsWith("--!V$Version")))) + { Write-Output $Line } + } + elseif ($State -eq $Version) + { Write-Output $Line } + } + } + else + { Write-Host "Unknown pipeline object type." -ForegroundColor Red } + } + + end + { + } +} + function Restore-NativeCommandStream { <# .SYNOPSIS @@ -38,9 +161,10 @@ function Restore-NativeCommandStream .DESCRIPTION This CmdLet collects multiple ErrorRecord objects and emits one String object per line. - .PARAMETER InputObject A object stream is required as an input. + .PARAMETER Indent + Indentation string. #> [CmdletBinding()] param( @@ -52,9 +176,7 @@ function Restore-NativeCommandStream { $LineRemainer = "" } process - { if (-not $InputObject) - { Write-Host "Empty pipeline!" } - elseif ($InputObject -is [System.Management.Automation.ErrorRecord]) + { if ($InputObject -is [System.Management.Automation.ErrorRecord]) { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") { Write-Output $InputObject.ToString() } elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") @@ -78,6 +200,60 @@ function Restore-NativeCommandStream } } +function Write-ColoredGCCLine +{ <# + .SYNOPSIS + This CmdLet colors GHDL output lines. + + .DESCRIPTION + This CmdLet colors GHDL output lines. Warnings are prefixed with 'WARNING: ' + in yellow and errors are prefixed with 'ERROR: ' in red. + + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER SuppressWarnings + Skip warning messages. (Show errors only.) + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject, + + [Parameter(Position=1)] + [switch]$SuppressWarnings = $false, + [Parameter(Position=2)] + [string]$Indent = "" + ) + + begin + { $ErrorRecordFound = $false } + + process + { if ($InputObject -is [String]) + { if ($InputObject -match ":\d+:\d+:\swarning:\s") + { if (-not $SuppressWarnings) + { Write-Host "${Indent}WARNING: " -NoNewline -ForegroundColor Yellow + Write-Host $InputObject + } + } + elseif ($InputObject -match ":\d+:\d+:\s") + { $ErrorRecordFound = $true + Write-Host "${Indent}ERROR: " -NoNewline -ForegroundColor Red + Write-Host $InputObject + } + else + { Write-Host "${Indent}$InputObject" } + } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { $ErrorRecordFound } +} + function Write-ColoredGHDLLine { <# .SYNOPSIS @@ -99,29 +275,29 @@ function Write-ColoredGHDLLine $InputObject, [Parameter(Position=1)] - [switch]$SuppressWarnings = $false + [switch]$SuppressWarnings = $false, + [Parameter(Position=2)] + [string]$Indent = "" ) begin { $ErrorRecordFound = $false } process - { if (-not $InputObject) - { Write-Host "Empty pipeline!" } - elseif ($InputObject -is [String]) - { if ($InputObject -match ":\d+:\d+:\swarning:") + { if ($InputObject -is [String]) + { if ($InputObject -match ":\d+:\d+:warning:\s") { if (-not $SuppressWarnings) - { Write-Host "WARNING: " -NoNewline -ForegroundColor Yellow + { Write-Host "${Indent}WARNING: " -NoNewline -ForegroundColor Yellow Write-Host $InputObject } } elseif ($InputObject -match ":\d+:\d+:\s") { $ErrorRecordFound = $true - Write-Host "ERROR: " -NoNewline -ForegroundColor Red + Write-Host "${Indent}ERROR: " -NoNewline -ForegroundColor Red Write-Host $InputObject } else - { Write-Host $InputObject } + { Write-Host "${Indent}$InputObject" } } else { Write-Host "Unsupported object in pipeline stream" } @@ -131,6 +307,43 @@ function Write-ColoredGHDLLine { $ErrorRecordFound } } +function Write-HostExtended +{ <# + .SYNOPSIS + This CmdLet colors GHDL output lines. + + .DESCRIPTION + This CmdLet colors GHDL output lines. Warnings are prefixed with 'WARNING: ' + in yellow and errors are prefixed with 'ERROR: ' in red. + + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject, + + [Parameter(Position=1)] + [string]$Indent = "" + ) + + begin + { } + + process + { if ($InputObject -is [String]) + { Write-Host "${Indent}$InputObject" } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { } +} + function Test-GitRepository { <# .SYNOPSIS @@ -142,6 +355,14 @@ function Test-GitRepository } # export functions +Export-ModuleMember -Function 'Exit-CompileScript' + +Export-ModuleMember -Function 'New-LibraryDirectory' +Export-ModuleMember -Function 'Format-VHDLSourceFile' + Export-ModuleMember -Function 'Restore-NativeCommandStream' +Export-ModuleMember -Function 'Write-ColoredGCCLine' Export-ModuleMember -Function 'Write-ColoredGHDLLine' +Export-ModuleMember -Function 'Write-HostExtended' + Export-ModuleMember -Function 'Test-GitRepository' diff --git a/dist/mcode/windows/targets.psm1 b/dist/mcode/windows/targets.psm1 index db6f970a8..502305a90 100644 --- a/dist/mcode/windows/targets.psm1 +++ b/dist/mcode/windows/targets.psm1 @@ -3,10 +3,10 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== -# PowerShell Module: The module provides build targets for GHDL. -# # Authors: Patrick Lehmann # +# PowerShell Module: The module provides build targets for GHDL. +# # Description: # ------------------------------------ # This PowerShell module provides build targets for GHDL. @@ -271,7 +271,7 @@ function Invoke-CompileCFiles Write-Host (" compiling: " + $SourceFile.File) Write-Debug " call: $InvokeExpr" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " if ($LastExitCode -ne 0) { return $true } } @@ -342,7 +342,7 @@ function Invoke-CompileGHDLAdaFiles Write-Host " compiling with GNAT" Write-Debug " call: $InvokeExpr" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " return ($LastExitCode -ne 0) } # Invoke-CompileGHDLAdaFiles @@ -388,7 +388,7 @@ function Invoke-CompileFilterAdaFiles Write-Host " compiling with GNAT" Write-Debug " call: $InvokeExpr" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " return ($LastExitCode -ne 0) } # Invoke-CompileFilterAdaFiles @@ -445,9 +445,9 @@ function Test-GHDLVersion Write-Host " executing '$GHDLExecutableName'" Write-Host " call: $InvokeExpr" - Write-Host "----------------------------------------" - Invoke-Expression $InvokeExpr | Restore-NativeCommandStream - Write-Host "----------------------------------------" + Write-Host " ----------------------------------------" + Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-HostExtended " " + Write-Host " ----------------------------------------" return ($LastExitCode -ne 0) } # Test-GHDLVersion diff --git a/libraries/vendors/shared.psm1 b/libraries/vendors/shared.psm1 index 97a196fd3..d3b93c43e 100644 --- a/libraries/vendors/shared.psm1 +++ b/libraries/vendors/shared.psm1 @@ -400,9 +400,10 @@ function Write-ColoredGHDLLine .PARAMETER InputObject A object stream is required as an input. - .PARAMETER SuppressWarnings Skip warning messages. (Show errors only.) + .PARAMETER Indent + Indentation string. #> [CmdletBinding()] param( @@ -410,27 +411,29 @@ function Write-ColoredGHDLLine $InputObject, [Parameter(Position=1)] - [switch]$SuppressWarnings = $false + [switch]$SuppressWarnings = $false, + [Parameter(Position=2)] + [string]$Indent = "" ) begin { $ErrorRecordFound = $false } process - { if (-not $InputObject) - { Write-Host "Empty pipeline!" } - elseif ($InputObject -is [String]) - { if ($InputObject.Contains("warning")) + { if ($InputObject -is [String]) + { if ($InputObject -match ":\d+:\d+:warning:\s") { if (-not $SuppressWarnings) - { Write-Host "WARNING: " -NoNewline -ForegroundColor Yellow + { Write-Host "${Indent}WARNING: " -NoNewline -ForegroundColor Yellow Write-Host $InputObject } } - else + elseif ($InputObject -match ":\d+:\d+:\s") { $ErrorRecordFound = $true - Write-Host "ERROR: " -NoNewline -ForegroundColor Red + Write-Host "${Indent}ERROR: " -NoNewline -ForegroundColor Red Write-Host $InputObject } + else + { Write-Host "${Indent}$InputObject" } } else { Write-Host "Unsupported object in pipeline stream" } -- cgit v1.2.3