From 330ea6732666779dcadaf8936805acefa4eadc0a Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 17 Feb 2017 04:53:59 +0100 Subject: Fixed Windows compile flow (PowerShell scripts) for GHDL and library compilations. --- dist/windows/compile-ghdl.ps1 | 246 ++++++ dist/windows/compile-libraries.ps1 | 868 +++++++++++++++++++++ dist/windows/compile.ps1 | 692 ++++++++++++++++ dist/windows/mcode/compile.bat | 31 + dist/windows/mcode/complib.bat | 119 +++ dist/windows/mcode/ghdl.nsi | 458 +++++++++++ dist/windows/mcode/ghdlfilter.adb | 132 ++++ dist/windows/mcode/ghdlversion.adb | 30 + dist/windows/mcode/grt-modules.adb | 39 + dist/windows/mcode/ortho_code-x86-flags.ads | 2 + dist/windows/mcode/winbuild.ps1 | 692 ---------------- dist/windows/mcode/windows/compile-ghdl.ps1 | 246 ------ dist/windows/mcode/windows/compile-libraries.ps1 | 868 --------------------- dist/windows/mcode/windows/compile.bat | 31 - dist/windows/mcode/windows/complib.bat | 119 --- dist/windows/mcode/windows/default_pathes.ads | 10 - dist/windows/mcode/windows/elf_arch.ads | 2 - dist/windows/mcode/windows/ghdl.nsi | 458 ----------- dist/windows/mcode/windows/ghdlfilter.adb | 132 ---- dist/windows/mcode/windows/ghdlversion.adb | 30 - dist/windows/mcode/windows/grt-backtraces-impl.ads | 3 - dist/windows/mcode/windows/grt-modules.adb | 39 - .../windows/mcode/windows/ortho_code-x86-flags.ads | 2 - dist/windows/mcode/windows/shared.psm1 | 370 --------- dist/windows/mcode/windows/targets.psm1 | 411 ---------- .../windows/mcode/windows/windows_default_path.adb | 68 -- .../windows/mcode/windows/windows_default_path.ads | 30 - dist/windows/mcode/windows_default_path.adb | 68 ++ dist/windows/mcode/windows_default_path.ads | 30 + dist/windows/shared.psm1 | 370 +++++++++ dist/windows/targets.psm1 | 411 ++++++++++ 31 files changed, 3496 insertions(+), 3511 deletions(-) create mode 100644 dist/windows/compile-ghdl.ps1 create mode 100644 dist/windows/compile-libraries.ps1 create mode 100644 dist/windows/compile.ps1 create mode 100644 dist/windows/mcode/compile.bat create mode 100644 dist/windows/mcode/complib.bat create mode 100644 dist/windows/mcode/ghdl.nsi create mode 100644 dist/windows/mcode/ghdlfilter.adb create mode 100644 dist/windows/mcode/ghdlversion.adb create mode 100644 dist/windows/mcode/grt-modules.adb create mode 100644 dist/windows/mcode/ortho_code-x86-flags.ads delete mode 100644 dist/windows/mcode/winbuild.ps1 delete mode 100644 dist/windows/mcode/windows/compile-ghdl.ps1 delete mode 100644 dist/windows/mcode/windows/compile-libraries.ps1 delete mode 100644 dist/windows/mcode/windows/compile.bat delete mode 100644 dist/windows/mcode/windows/complib.bat delete mode 100644 dist/windows/mcode/windows/default_pathes.ads delete mode 100644 dist/windows/mcode/windows/elf_arch.ads delete mode 100644 dist/windows/mcode/windows/ghdl.nsi delete mode 100644 dist/windows/mcode/windows/ghdlfilter.adb delete mode 100755 dist/windows/mcode/windows/ghdlversion.adb delete mode 100644 dist/windows/mcode/windows/grt-backtraces-impl.ads delete mode 100644 dist/windows/mcode/windows/grt-modules.adb delete mode 100644 dist/windows/mcode/windows/ortho_code-x86-flags.ads delete mode 100644 dist/windows/mcode/windows/shared.psm1 delete mode 100644 dist/windows/mcode/windows/targets.psm1 delete mode 100644 dist/windows/mcode/windows/windows_default_path.adb delete mode 100644 dist/windows/mcode/windows/windows_default_path.ads create mode 100644 dist/windows/mcode/windows_default_path.adb create mode 100644 dist/windows/mcode/windows_default_path.ads create mode 100644 dist/windows/shared.psm1 create mode 100644 dist/windows/targets.psm1 (limited to 'dist/windows') diff --git a/dist/windows/compile-ghdl.ps1 b/dist/windows/compile-ghdl.ps1 new file mode 100644 index 000000000..45e1d7c50 --- /dev/null +++ b/dist/windows/compile-ghdl.ps1 @@ -0,0 +1,246 @@ +# 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-2017 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-ghdl.ps1 -Help' to see the integrated help page +# +# .EXAMPLE +# C:\PS> .\compile-ghdl.ps1 -Clean -Compile +# +[CmdletBinding()] +param( + # Display this help" + [switch]$Help = $false, + + # Slean up all files and directories + [switch]$Clean = $false, + [switch]$Clean_GHDL = $false, + + # Compile all targets + [switch]$All = $false, + + # Compile main targets + [switch]$Compile = $false, + # Compile GHDL (simulator) + [switch]$Compile_GHDL = $false, + # Undocumented + [switch]$Test = $false, + # Undocumented + [switch]$Test_GHDL = $false, + + # Build options + # Build a release version + [switch]$Release = $false, + # Set the back-end + [string]$Backend = "mcode", + + # Reduced messages + [switch]$Quiet = $false, + # Skip warning messages. (Show errors only.) + [switch]$SuppressWarnings = $false, + # Halt on errors + [switch]$HaltOnError = $false, + # Undocumented + [switch]$Hosted = $false +) + +# configure script here +$RelPathToRoot = "..\.." + +# --------------------------------------------- +# save parameters and working directory +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) + +# set default values +$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"] +$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"] +if ($EnableVerbose -eq $null) { $EnableVerbose = $false } +if ($EnableDebug -eq $null) { $EnableDebug = $false } +if ($EnableDebug -eq $true) { $EnableVerbose = $true } + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosted +Import-Module $PSScriptRoot\targets.psm1 -Verbose:$false -Debug:$false + +# Display help if no command was selected +$Help = $Help -or (-not ( + $All -or + $Clean -or $Clean_GHDL -or + $Compile -or $Compile_GHDL -or + $Test -or $Test_GHDL + )) + +if (-not $Hosted) +{ Write-Host "================================================================================" -ForegroundColor Magenta + Write-Host "GHDL for Windows - GHDL compile script" -ForegroundColor Magenta + Write-Host "================================================================================" -ForegroundColor Magenta +} + +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} + +if ($Clean) +{ $Clean_GHDL = $true +} +if ($All) +{ $Compile = $true +} +if ($Compile) +{ $Compile_GHDL = $true +} +if ($Test) +{ $Test_GHDL = $true +} + +# configure some variables: paths, executables, directory names, ... +$BuildDirectoryName = "build" + +# Parameter checks +if ($Backend -ne "mcode") +{ Write-Host "[ERROR]: Back-end '$Backend' is not supported on Windows." -ForegroundColor Red + Exit-CompileScript -1 +} + +# construct directories +$BinaryDestinationDirectory = "$GHDLRootDir\$BuildDirectoryName\$Backend" +# construct executables +$GHDLNewExecutable = "$GHDLRootDir\$BuildDirectoryName\$Backend\bin\ghdl.exe" + +# grep GHDL version string from Ada source file +$GHDLVersion = Get-GHDLVersion $GHDLRootDir +# compute some variables +$BuildRelease = if ($Release) { "Release" } else { "Development" } +if (-not $Hosted) +{ Write-Host " Version: $GHDLVersion" + Write-Host " Release: $BuildRelease" +} + +$Git_IsGitRepo = Test-GitRepository +# gather git information +if ($Git_IsGitRepo) +{ $Git_Branch_Name = & git rev-parse --abbrev-ref HEAD + $Git_Commit_DateString = & git log -1 --format=%cd --date=short + $Git_Commit_ShortHash = & git rev-parse --short HEAD + + if (-not $Hosted) + { Write-Host " Git branch: $Git_Branch_Name" + Write-Host " Git commit: $Git_Commit_DataString ($Git_Commit_ShortHash)" + } +} +if (-not $Hosted) +{ Write-Host "" } + +if ($Release) +{ $BuildDirectory = $BinaryDestinationDirectory } +else +{ $BuildDirectory = $BinaryDestinationDirectory } + + +# ============================================================================== +# Main Target: Clean +# ============================================================================== +if ($Clean_GHDL) +{ $error = Invoke-Clean $BuildDirectory -Quiet:$Quiet -Verbose:$EnableVerbose -Debug:$EnableDebug + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } +} # Clean + + +# ============================================================================== +# Main Target: GHDL +# ============================================================================== +if ($Compile_GHDL) +{ # create a build directory + $error = New-BuildDirectory $BuildDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + + # patch the version file if it's no release build + if (-not $Release -and $Git_IsGitRepo) + { $error = Invoke-PatchVersionFile $GHDLRootDir $Git_Branch_Name $Git_Commit_DateString $Git_Commit_ShortHash + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + } + + # build C source files + $error = Invoke-CompileCFiles $GHDLRootDir $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + + # build Ada source files + $error = Invoke-CompileGHDLAdaFiles $GHDLRootDir $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + + # strip result + $error = Invoke-StripGHDLExecutable $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } +} + + +# ============================================================================== +# Main Target: GHDL +# ============================================================================== +if ($Test_GHDL) +{ # running ghdl + $error = Test-GHDLVersion $BuildDir + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } +} # Test + +Exit-CompileScript 0 diff --git a/dist/windows/compile-libraries.ps1 b/dist/windows/compile-libraries.ps1 new file mode 100644 index 000000000..6579f2ace --- /dev/null +++ b/dist/windows/compile-libraries.ps1 @@ -0,0 +1,868 @@ +# 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-2017 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 'compile-libraries.ps1 -Help' to see the integrated help page +# +# .EXAMPLE +# C:\PS> .\compile-libraries.ps1 -Clean +# .EXAMPLE +# C:\PS> .\compile-libraries.ps1 -Compile -Verbose +# .EXAMPLE +# C:\PS> .\compile-libraries.ps1 -VHDL2008 -SuppressWarnings +# +[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 = "", + # Undocumented + [switch]$Hosted = $false +) + +# configure script here +$RelPathToRoot = "..\.." + +# --------------------------------------------- +# save parameters and working directory +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) + +# set default values +$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"] +$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"] +if ($EnableVerbose -eq $null) { $EnableVerbose = $false } +if ($EnableDebug -eq $null) { $EnableDebug = $false } +if ($EnableDebug -eq $true) { $EnableVerbose = $true } + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosted + +# 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" + + +# 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" + ); + "synopsys8793" = @( + "std_logic_textio" + ); + "synopsys" = @( + "std_logic_arith", + "std_logic_unsigned", + "std_logic_signed", + "std_logic_misc", "std_logic_misc-body" + ); + "mentor" = @( + "std_logic_arith", "std_logic_arith_body" + ) +} + +if (-not $Hosted) +{ 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..." -ForegroundColor Yellow + if (Test-Path -Path $VHDLDestinationLibraryDirectory) + { $EnableVerbose -and (Write-Host " rmdir $VHDLDestinationLibraryDirectory") | Out-Null + Remove-Item $VHDLDestinationLibraryDirectory -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: Cannot remove '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red + Exit-CompileScript -1 + } + } + if (-not ($VHDL87 -or $VHDL93 -or $VHDL2008)) + { Exit-CompileScript } +} + +# 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 +} + + +$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) + { $EnableVerbose -and (Write-Host " Directory '$VHDLDestinationLibraryDirectory' already exists.") | Out-Null + + # change working directory to VHDLDestinationLibraryDirectory + $EnableVerbose -and (Write-Host " cd $VHDLDestinationLibraryDirectory") | Out-Null + Set-Location $VHDLDestinationLibraryDirectory + + $EnableVerbose -and (Write-Host " Cleaning up directory...") | Out-Null + Remove-Item ./* -Force -Recurse -ErrorAction SilentlyContinue + } + else + { $EnableVerbose -and (Write-Host " Creating directory '$VHDLDestinationLibraryDirectory'.") | Out-Null + New-Item -ItemType Directory -Path $VHDLDestinationLibraryDirectory -ErrorAction SilentlyContinue | Out-Null + if (-not $?) + { Write-Host "[ERROR]: Cannot create destination directory '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red + Exit-CompileScript -1 + } + + # change working directory to VHDLDestinationLibraryDirectory + $EnableVerbose -and (Write-Host " Change working directory to $VHDLDestinationLibraryDirectory") | Out-Null + Set-Location $VHDLDestinationLibraryDirectory + } + + Write-Host + Write-Host "Start compilation..." +} +# ============================================================================ +# v87 +# ============================================================================ +if ($VHDL87) +{ $VHDLVersion = "87" + $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" + Write-Host "Compiling libraries for 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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } +} +# ============================================================================ +# v93 +# ============================================================================ +if ($VHDL93) +{ $VHDLVersion = "93" + $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" + Write-Host "Compiling libraries for 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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } +} +# ============================================================================== +# v08 +# ============================================================================== +if ($VHDL2008) +{ $VHDLVersion = "08" + $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" + Write-Host "Compiling libraries for 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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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 VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $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/windows/compile.ps1 b/dist/windows/compile.ps1 new file mode 100644 index 000000000..2835a4e58 --- /dev/null +++ b/dist/windows/compile.ps1 @@ -0,0 +1,692 @@ +# 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: +# - compiles GHDL and GHDLFilter +# - analyses VHDL libraries +# - installs GHDL into a directory (xcopy deploiment) +# +# ============================================================================== +# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold +# Copyright (C) 2015-2017 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 +# # +# # Normal flow +# PS> .\compile.ps1 -Clean +# PS> .\compile.ps1 -Compile +# PS> .\compile.ps1 -Install +# +# # Combine all commands in a single call +# PS>.\compile.ps1 -Clean -Compile -Install "C:\Tools\GHDL" +# +# # Install to user defined dir +# PS> .\compile.ps1 -Install "C:\Tools\GHDL" +# +# # Update or Uninstall +# PS> .\compile.ps1 -Update +# PS> .\compile.ps1 -Uninstall +# +# # Create a Zip-file +# PS>.\compile.ps1 -CreatePackage -Zip +# +[CmdletBinding()] +Param( + # clean up all files and directories + [switch]$Clean, + [switch]$Clean_GHDL, + [switch]$Clean_Libraries, + + # compile GHDL + [switch]$Compile, + [switch]$Compile_GHDL, + [switch]$Compile_Libraries, + + # create an installer package + [switch]$CreatePackage, + # creates a zip-file for xcopy deployment + [switch]$Zip, + + # install all files into a directory (xcopy deployment) + [switch]$Install = $false, + [parameter(mandatory=$false, ValueFromRemainingArguments=$true)] + [string]$InstallDir = "", + # update files + [switch]$Update, + # uninstall all files from a directory + [switch]$Uninstall, + + # display this help" + [switch]$Help +) + +# configure script here +$RelPathToRoot = "..\.." + +# save parameters and current working directory +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) + +# set default values +$Hosting = $true +$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"] +$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"] +if ($EnableVerbose -eq $null) { $EnableVerbose = $false } +if ($EnableDebug -eq $null) { $EnableDebug = $false } +if ($EnableDebug -eq $true) { $EnableVerbose = $true } + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosting +Import-Module $PSScriptRoot\targets.psm1 -Verbose:$false -Debug:$false + +# Display help if no command was selected +$Help = $Help -or (-not ( + $All -or + $Clean -or $Clean_GHDL -or $Clean_Libraries -or $Clean_Package_Zip -or + $Compile -or $Compile_GHDL -or $Compile_Libraries -or + $CreatePackage -or + $Install -or $Update -or $Uninstall + )) + +Write-Host "================================================================================" -ForegroundColor Magenta +Write-Host "GHDL for Windows - GHDL compile and bundle script" -ForegroundColor Magenta +Write-Host "================================================================================" -ForegroundColor Magenta + +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} + +if ($All) +{ $Clean = $true + $Compile = $true + $CreatePackage = $true +} +if ($Clean) +{ $Clean_GHDL = $true + $Clean_Libraries = $true + $Clean_Package_Zip = $true +} +if ($Compile) +{ $Compile_GHDL = $true + $Compile_Libraries = $true +} + +# configure some variables: paths, executables, directory names, ... +$GHDLVersion = Get-GHDLVersion $GHDLRootDir +$Backend = "mcode" +$WindowsDirName = "dist\windows" #\$Backend" +$BuildDirectoryName = "build" +$BuildBackendDirectoryName = "$BuildDirectoryName\$Backend" +$VHDLLibrariesDirectoryName = "lib" +$PackageDirectoryName = "build\zip\$Backend" +$ZipPackageFileName = "ghdl-$Backend-$GHDLVersion.zip" +$DefaultInstallPath = "C:\Program Files (x86)\GHDL" # This is the default path for 32-bit applications (x86-32) + +# construct directories +$GHDLWindowsDir = "$GHDLRootDir\$WindowsDirName" +$GHDLBuildDir = "$GHDLRootDir\$BuildBackendDirectoryName" +$GHDLVendorLibraryDir = "$GHDLRootDir\libraries\vendors" +$GHDLCompiledLibraryDir = "$GHDLRootDir\$BuildBackendDirectoryName\$VHDLLibrariesDirectoryName" +$GHDLZipPackageDir = "$GHDLRootDir\$PackageDirectoryName" +$GHDLZipPackageFile = "$GHDLZipPackageDir\$ZipPackageFileName" + +# construct files +$InstallDirFile = "$BuildDirectoryName\InstallDir.conf" + +$EnvPath_ContainerMapping = @{ + Machine = [EnvironmentVariableTarget]::Machine + User = [EnvironmentVariableTarget]::User +} + +function Exit-Script +{ [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + cd $Script_WorkingDir + # unload modules + Remove-Module shared -Verbose:$false -Debug:$false + Remove-Module targets -Verbose:$false -Debug:$false + exit $ExitCode +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Add-EnvPath +{ param( + [Parameter(Mandatory=$true)] + [string] $Path, + + [ValidateSet("Machine", "User", "Session")] + [string] $Container = "Session" + ) + + if ($Container -ne "Session") + { $containerType = $EnvPath_ContainerMapping[$Container] + $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" + if ($persistedPaths -notcontains $Path) + { $persistedPaths = $persistedPaths + $Path | where { $_ } + [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) + } + } + + $envPaths = $env:Path -split ";" + if ($envPaths -notcontains $Path) + { $envPaths = $envPaths + $Path | where { $_ } + $env:Path = $envPaths -join ";" + } +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Remove-EnvPath +{ param ( + [Parameter(Mandatory=$true)] + [string] $Path, + + [ValidateSet("Machine", "User", "Session")] + [string] $Container = "Session" + ) + + if ($Container -ne "Session") + { $containerType = $EnvPath_ContainerMapping[$Container] + $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" + if ($persistedPaths -contains $Path) + { $persistedPaths = $persistedPaths | where { $_ -and $_ -ne $Path } + [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) + } + } + + $envPaths = $env:Path -split ";" + if ($envPaths -contains $Path) + { $envPaths = $envPaths | where { $_ -and $_ -ne $Path } + $env:Path = $envPaths -join ";" + } +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Get-EnvPath +{ param ( + [Parameter(Mandatory=$true)] + [ValidateSet("Machine", "User")] + [string] $Container + ) + + $containerType = $EnvPath_ContainerMapping[$Container] + [Environment]::GetEnvironmentVariable('Path', $containerType) -split ";" | where { $_ } +} + + +if ($false) +{ # Write-Host "Uninstalling GHDL $GHDLVersion for Windows..." + + # Write-Host "[ERROR]: This command is not implemented." -ForegroundColor Red + Exit-Script -1 +} # Uninstall +else +{ # ============================================================================ + # Clean tasks + # ============================================================================ + if ($Clean) + { Write-Host "Removing all created files and directories..." } + + if ($Clean_GHDL) + { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" + $Script_Parameters = @( + '-Clean', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + Write-Host "Running compile-ghdl.ps1 -Clean ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-ghdl.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Clean_GHDL + if ($Clean_Libraries) + { if ($Clean_GHDL) + { Write-Host } + + $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1" + $Script_Parameters = @( + '-Clean', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + Write-Host "Running compile-libraries.ps1 -Clean ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-libraries.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Clean_Libraries + if ($Clean_Package_Zip) + { if ($Clean_GHDL -or $Clean_Libraries) + { Write-Host } + + Write-Host "Running more clean-up tasks..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Removing installer packages and temporary directories..." -ForegroundColor Yellow + if (Test-Path -Path $GHDLZipPackageDir) + { Write-Host " rmdir $GHDLZipPackageDir" + Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageDir'." -ForegroundColor Red + Exit-Script -1 + } + } + + if (Test-Path -Path $GHDLZipPackageFile) + { Write-Host " rm $GHDLZipPackageFile" + Remove-Item $GHDLZipPackageFile -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageFile'." -ForegroundColor Red + Exit-Script -1 + } + } + + Write-Host + Write-Host "Clean " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } # Clean_Package_Zip + + # ============================================================================ + # Compile tasks + # ============================================================================ + if ($Compile_GHDL) + { if ($Clean) + { Write-Host } + + $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" + $Script_Parameters = @() + $Script_Parameters = @( + '-All', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + # Write-Host "Compiling GHDL $GHDLVersion for Windows..." -ForegroundColor DarkCyan + # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + + Write-Host + Write-Host "Running compile-ghdl.ps1 -All ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-ghdl.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Compile_GHDL + if ($Compile_Libraries) + { if ($Compile_GHDL) + { Write-Host } + + $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1" + $Script_Parameters = @() + $Script_Parameters = @( + '-Compile', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + # Write-Host "Compiling GHDL's libraries ..." -ForegroundColor DarkCyan + # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + + $env:GHDL = "$GHDLBuildDir\ghdl.exe" + Write-Host ("Setting env:GHDL to '" + $env:GHDL + "'") + + Write-Host + Write-Host "Running compile-libraries.ps1 -Compile ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-libraries.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Compile_GHDL + + # ============================================================================ + # Package tasks + # ============================================================================ + if ($CreatePackage) + { Write-Host "Creating an installation package for GHDL $GHDLVersion for Windows" + + if ($Zip) + { Write-Host "Loading PowerShell Community Extensions (PSCX) " -NoNewline + if ((Get-Module -ListAvailable | Where {$_.Name -like "PSCX"}).Version -ge "3.1.0.0") + { Import-Module Pscx -Verbose:$false + Write-Host "[Done]" -ForegroundColor Green + } + else + { Write-Host "[FAILED]" -ForegroundColor RED + Exit-Script -1 + } + + Write-Host "Output format: zip-file" + Write-Host " Removing old directory '$GHDLZipPackageDir'." + if (Test-Path -Path $GHDLZipPackageDir) + { Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageDir'." -ForegroundColor Red + Exit-Script -1 + } + } + if (Test-Path -Path $GHDLZipPackageFile) + { Remove-Item $GHDLZipPackageFile -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageFile'." -ForegroundColor Red + Exit-Script -1 + } + } + + Write-Host " Creating directory '$GHDLZipPackageDir' and sub-directories..." + New-Item -ItemType directory -Path "$GHDLZipPackageDir" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$GHDLZipPackageDir\bin" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$GHDLZipPackageDir\include" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$GHDLZipPackageDir\lib" -ErrorAction SilentlyContinue | Out-Null + + Write-Host " Gathering files..." + # executables + Copy-Item "$GHDLBuildDir\ghdl.exe" "$GHDLZipPackageDir\bin\ghdl.exe" -ErrorAction SilentlyContinue + # include files + Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$GHDLZipPackageDir\include" -ErrorAction SilentlyContinue + # pre-compile scripts + Copy-Item $GHDLVendorLibraryDir -Recurse "$GHDLZipPackageDir\lib\vendors" -ErrorAction SilentlyContinue + # pre-compiled libraries + Copy-Item $GHDLCompiledLibraryDir -Recurse "$GHDLZipPackageDir" -ErrorAction SilentlyContinue + + Write-Host " Compressing all files into '$GHDLZipPackageFile'..." + $file = Get-ChildItem $GHDLZipPackageDir -Recurse | Write-Zip -IncludeEmptyDirectories -EntryPathRoot $GHDLZipPackageDir -OutputPath $GHDLZipPackageFile + Write-Host " $([math]::round(($file.Length / 1MB), 3)) MiB written to disk" + + Write-Host + Write-Host "Creating package " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + else + { Write-Host "[ERROR]: No package format selected." -ForegroundColor Red + Write-Host "Possible formats:" + Write-Host " - Zip-file (-Zip)" + Write-Host + } + } + # ============================================================================ + # Compile tasks + # ============================================================================ + if ($Install) + { Write-Host "Installing GHDL $GHDLVersion for Windows..." + if ($InstallDir -eq "") + { if (Test-Path $InstallDirFile -PathType Leaf) + { Write-Host " Reading installation path from '$InstallDirFile' ..." + $InstallPath = Get-Content $InstallDirFile -Encoding Ascii + } + else + { $InstallPath = $DefaultInstallPath } + } + else + { $InstallPath = $InstallDir } + $InstallPath = $InstallPath.TrimEnd("\") + + if ($Zip) + { Write-Host "Loading PowerShell Community Extensions (PSCX) " -NoNewline + if ((Get-Module -ListAvailable | Where {$_.Name -like "PSCX"}).Version -ge "3.1.0.0") + { Import-Module Pscx -Verbose:$false + Write-Host "[Done]" -ForegroundColor Green + } + else + { Write-Host "[FAILED]" -ForegroundColor RED + Exit-Script -1 + } + + Write-Host " Installing from Zip-file..." + + Write-Host "[ERROR]: This command is not implemented." -ForegroundColor Red + } + else + { Write-Host " Writing installation path to '$InstallDirFile'..." + $InstallPath | Out-File -FilePath $InstallDirFile -Encoding Ascii + + if (Test-Path -Path $InstallPath) + { Write-Host "[ERROR]: Directory '$InstallPath' already exists." -ForegroundColor Red + Exit-Script -1 + } + Write-Host " Install directory: $InstallPath" + Write-Host " Creating directory '$InstallPath' and sub-directories..." + New-Item -ItemType directory -Path "$InstallPath" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\bin" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\include" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\lib" -ErrorAction SilentlyContinue | Out-Null + + Write-Host " Copying files..." + # executables + Copy-Item "$GHDLBuildDir\ghdl.exe" "$InstallPath\bin\ghdl.exe" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # include files + Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$InstallPath\include" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compile scripts + Copy-Item $GHDLVendorLibraryDir -Recurse "$InstallPath\lib" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compiled libraries + Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + + Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan + Write-Host "M" -NoNewline -ForegroundColor Cyan + Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan + Write-Host "u" -NoNewline -ForegroundColor Cyan + Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan + Write-Host "s" -NoNewline -ForegroundColor Cyan + Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan + Write-Host "n" -NoNewline -ForegroundColor Cyan + Write-Host "o]: " -NoNewline -ForegroundColor DarkCyan + $InstallInPath = (Read-Host).ToLower() + if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) + { Write-Host " Adding GHDL to PATH at machine level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "u") + { Write-Host " Adding GHDL to PATH at user level." + Add-EnvPath -Path "$InstallPath\bin" -Container "User" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "s") + { Write-Host " Adding GHDL to PATH at session level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + + Write-Host + Write-Host "Installing files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script + } # Zip + } # Install + elseif ($Update) + { Write-Host "Updating GHDL $GHDLVersion for Windows..." + if (Test-Path $InstallDirFile -PathType Leaf) + { Write-Host " Reading installation path from '$InstallDirFile' ..." + $InstallPath = Get-Content $InstallDirFile -Encoding Ascii + } + else + { $InstallPath = $InstallDir } + $InstallPath = $InstallPath.TrimEnd("\") + + Write-Host " Install directory: $InstallPath" + if (Test-Path -Path $InstallPath) + { Write-Host " Cleaning up installation directory '$InstallPath'." -ForegroundColor Yellow + Get-ChildItem -Path $InstallPath -Depth 0 | foreach { Remove-Item $_ -Recurse -ErrorAction SilentlyContinue } + } + + Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow + foreach ($container in @("Machine", "User")) + { foreach ($entry in (Get-EnvPath -Container $container)) + { if ($entry.ToLower().Contains("ghdl")) + { Write-Host " Removing '$entry' from $container level." + Remove-EnvPath -Path $entry -Container $container + } + } + } + Remove-EnvPath -Path $entry -Container "Session" + + Write-Host " Creating directory sub-directories in '$InstallPath' ..." + New-Item -ItemType directory -Path "$InstallPath\bin" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\include" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\lib" -ErrorAction SilentlyContinue | Out-Null + + Write-Host " Copying files..." + # executables + Copy-Item "$GHDLBuildDir\ghdl.exe" "$InstallPath\bin\ghdl.exe" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # include files + Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$InstallPath\include" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compile scripts + Copy-Item $GHDLVendorLibraryDir -Recurse "$InstallPath\lib" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compiled libraries + Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + + Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan + Write-Host "M" -NoNewline -ForegroundColor Cyan + Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan + Write-Host "u" -NoNewline -ForegroundColor Cyan + Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan + Write-Host "s" -NoNewline -ForegroundColor Cyan + Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan + Write-Host "n" -NoNewline -ForegroundColor Cyan + Write-Host "o]: " -NoNewline -ForegroundColor DarkCyan + $InstallInPath = (Read-Host).ToLower() + if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) + { Write-Host " Adding GHDL to PATH at machine level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "u") + { Write-Host " Adding GHDL to PATH at user level." + Add-EnvPath -Path "$InstallPath\bin" -Container "User" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "s") + { Write-Host " Adding GHDL to PATH at session level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + + Write-Host + Write-Host "Updating files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script + } # Update + elseif ($Uninstall) + { Write-Host "Uninstalling GHDL $GHDLVersion for Windows..." + if (Test-Path $InstallDirFile -PathType Leaf) + { Write-Host " Reading installation path from '$InstallDirFile' ..." + $InstallPath = Get-Content $InstallDirFile -Encoding Ascii + } + else + { $InstallPath = $DefaultInstallPath } + + Write-Host " Install directory: $InstallPath" + if (Test-Path -Path $InstallPath) + { Write-Host " Removing installation directory '$InstallPath'." -ForegroundColor Yellow + Remove-Item $InstallPath -Recurse -ErrorAction SilentlyContinue + } + + Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow + foreach ($container in @("Machine", "User")) + { foreach ($entry in (Get-EnvPath -Container $container)) + { if ($entry.ToLower().Contains("ghdl")) + { Write-Host " Removing '$entry' from $container level." + Remove-EnvPath -Path $entry -Container $container + } + } + } + Remove-EnvPath -Path $entry -Container "Session" + + Write-Host + Write-Host "Uninstalling files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script + } # Update + +} # Clean + +Exit-Script diff --git a/dist/windows/mcode/compile.bat b/dist/windows/mcode/compile.bat new file mode 100644 index 000000000..0c0e33153 --- /dev/null +++ b/dist/windows/mcode/compile.bat @@ -0,0 +1,31 @@ +mkdir build +cd build + +rem Do the compilation +set CFLAGS= -O -Wall + +gcc -c %CFLAGS% ../../../src/grt/grt-cbinding.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% ../../../src/grt/grt-cvpi.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% ../../../src/grt/config/clock.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% ../../../src/ortho/mcode/memsegs_c.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% -DWITH_GNAT_RUN_TIME ../../../src/grt/config/win32.c +if errorlevel 1 goto failed + +gnatmake %CFLAGS% -gnatn -aI../windows -aI../../../src -aI../../../src/ghdldrv -aI../../../src/psl -aI../../../src/grt -aI../../../src/ortho/mcode -aI../../../src/vhdl -aI../../../src/vhdl/translate ghdl_jit -aI../../../src/ortho -o ghdl.exe -largs grt-cbinding.o clock.o grt-cvpi.o memsegs_c.o win32.o -ldbghelp -Wl,--stack,8404992 +if errorlevel 1 goto failed + +cd .. +exit /b 0 + +:failed +echo "Compilation failed" +cd .. +exit /b 1 diff --git a/dist/windows/mcode/complib.bat b/dist/windows/mcode/complib.bat new file mode 100644 index 000000000..91504a832 --- /dev/null +++ b/dist/windows/mcode/complib.bat @@ -0,0 +1,119 @@ +set GHDL=ghdl + +cd build +gnatmake -aI..\windows ghdlfilter +cd .. + +set REL=..\..\.. +set LIBSRC=%REL%\..\..\libraries + +:: +:: library sources +:: +set STD_SRCS= textio textio_body +set IEEE_SRCS= std_logic_1164 std_logic_1164_body numeric_std numeric_std-body numeric_bit numeric_bit-body +set MATH_SRCS= math_real math_real-body math_complex math_complex-body + +set STD08_SRCS= textio textio_body env env_body +set IEEE08_SRCS= 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_bit_context ieee_std_context + +set VITAL95_SRCS= vital_timing vital_timing_body vital_primitives vital_primitives_body +set VITAL2000_SRCS= timing_p timing_b prmtvs_p prmtvs_b memory_p memory_b + +set SYNOPSYS_SRCS= std_logic_arith std_logic_textio std_logic_unsigned std_logic_signed std_logic_misc std_logic_misc-body +set MENTOR_SRCS= std_logic_arith std_logic_arith_body + + +mkdir lib +cd lib + +::::::::::::::::: +echo v87 libraries... + +mkdir v87 +cd v87 + +echo std +mkdir std +cd std +for %%F in (%STD_SRCS%) do %REL%\build\ghdlfilter -v87 < %LIBSRC%\std\%%F.vhdl > %%F.v87 && %REL%\build\%GHDL% -a --std=87 --bootstrap --work=std %%F.v87 +cd .. + +echo ieee +mkdir ieee +cd ieee +for %%F in (%IEEE_SRCS%) do %REL%\build\ghdlfilter -v87 < %LIBSRC%\ieee\%%F.vhdl > %%F.v87 && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.v87 +for %%F in (%VITAL95_SRCS%) do copy %LIBSRC%\vital95\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.vhd +cd .. + +echo synopsys +mkdir synopsys +cd synopsys +for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee ..\ieee\%%F.v87 +for %%F in (%VITAL95_SRCS%) do %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%SYNOPSYS_SRCS%) do copy %LIBSRC%\synopsys\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.vhd +cd .. + +cd .. + +::::::::::::::::: +echo v93 libraries... + +mkdir v93 +cd v93 + +echo std +mkdir std +cd std +for %%F in (%STD_SRCS%) do %REL%\build\ghdlfilter -v93 < %LIBSRC%\std\%%F.vhdl > %%F.v93 && %REL%\build\%GHDL% -a --std=93 --bootstrap --work=std %%F.v93 +cd .. + +echo ieee +mkdir ieee +cd ieee +for %%F in (%IEEE_SRCS%) do %REL%\build\ghdlfilter -v93 < %LIBSRC%\ieee\%%F.vhdl > %%F.v93 && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.v93 +for %%F in (%VITAL2000_SRCS%) do copy %LIBSRC%\vital2000\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd +for %%F in (%MATH_SRCS%) do copy %LIBSRC%\ieee\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd +cd .. + +echo synopsys +mkdir synopsys +cd synopsys +for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.v93 +for %%F in (%VITAL2000_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%MATH_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%SYNOPSYS_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\..\v87\synopsys\%%F.vhd +cd .. + +echo mentor +mkdir mentor +cd mentor +for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.v93 +for %%F in (%VITAL2000_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%MATH_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%MENTOR_SRCS%) do copy %LIBSRC%\mentor\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd +cd .. + +cd .. + +::::::::::::::::: +echo v08 libraries... + +mkdir v08 +cd v08 + +echo std +mkdir std +cd std +for %%F in (%STD08_SRCS%) do %REL%\build\ghdlfilter -v08 < %LIBSRC%\std\%%F.vhdl > %%F.v08 && %REL%\build\%GHDL% -a --std=08 --bootstrap --work=std %%F.v08 +cd .. + +echo ieee +mkdir ieee +cd ieee +for %%F in (%IEEE08_SRCS%) do %REL%\build\ghdlfilter -v08 < %LIBSRC%\ieee2008\%%F.vhdl > %%F.v08 && %REL%\build\%GHDL% -a --std=08 -P..\std --work=ieee %%F.v08 +cd .. + +::::::::::::::::: + +cd ..\.. diff --git a/dist/windows/mcode/ghdl.nsi b/dist/windows/mcode/ghdl.nsi new file mode 100644 index 000000000..21ecb50c4 --- /dev/null +++ b/dist/windows/mcode/ghdl.nsi @@ -0,0 +1,458 @@ +; ghdl.nsi +; +; This script is based on example2.nsi. +; remember the directory, +; Check if administrator +; uninstall support +; TODO: +; * allow multiple version +; * command line installation +; * Allow user install + +;-------------------------------- +!include version.nsi +;-------------------------------- + +; The name of the installer +Name "Ghdl" + +; The file to write +OutFile "ghdl-installer-${VERSION}.exe" + +SetDateSave on + +; The default installation directory +InstallDir $PROGRAMFILES\Ghdl + +; Registry key to check for directory (so if you install again, it will +; overwrite the old one automatically) +InstallDirRegKey HKLM "Software\Ghdl" "Install_Dir" + +LicenseData ..\..\..\COPYING +; LicenseForceSelection + +;-------------------------------- + +; Pages + +Page license +Page components +Page directory +Page instfiles + +UninstPage uninstConfirm +UninstPage instfiles + +;-------------------------------- +Function .onInit + Call IsNT + pop $R0 + StrCmp $R0 1 nt_ok + MessageBox MB_OK|MB_ICONEXCLAMATION "You must use Windows NT (XP/2000/Me...)" + Quit + +nt_ok: + Call IsUserAdmin + Pop $R0 + StrCmp $R0 "true" Admin + MessageBox MB_OK|MB_ICONEXCLAMATION "You must have Admin rights" + Quit + +Admin: + + ;;; Check if already installed. + ReadRegStr $0 HKLM "Software\Ghdl" "Install_Dir" + IfErrors not_installed + ReadRegStr $0 HKLM "Software\Ghdl" "Version" + IfErrors unknown_prev_version + Goto known_version +unknown_prev_version: + StrCpy $0 "(unknown)" +known_version: + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "You already have GHDL version $0 installed. Deinstall ?" IDCANCEL install_abort IDOK deinstall +install_abort: + Abort "Installation aborted" +deinstall: + ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "UninstallString" + IfErrors deinstall_failed + + ; First version of the GHDL installer adds quotes + StrCpy $1 $0 1 + StrCmp $1 '"' 0 str_ok + StrCpy $1 $0 "" 1 + StrCpy $0 $1 -1 +str_ok: + + ; Read install dir + ReadRegStr $1 HKLM "Software\Ghdl" "Install_Dir" + IfErrors deinstall_failed + +; MessageBox MB_OK 'copy $0 to $TEMP' + + ClearErrors +; MessageBox MB_OK 'copy $0 to $TEMP' + CopyFiles $0 $TEMP + IfErrors deinstall_failed + ExecWait '"$TEMP\uninst-ghdl.exe" /S _?=$1' + IfErrors deinstall_failed + Delete "$TEMP\uninst-ghdl.exe" + Return +deinstall_failed: + Delete $TEMP\uninst-ghdl.exe + MessageBox MB_YESNO|MB_ICONSTOP "Can't deinstall GHDL: de-installer not found or failed. Continue installation ?" IDNO install_abort +not_installed: + Return +FunctionEnd + +;-------------------------------- + +; The stuff to install +Section "Ghdl Compiler (required)" + + SectionIn RO + + ; Set output path to the installation directory. + SetOutPath $INSTDIR\bin + File /oname=ghdl.exe ..\build\ghdl.exe + + SetOutPath $INSTDIR + File /oname=COPYING.txt ..\..\..\COPYING + + ; Write the installation path into the registry + WriteRegStr HKLM "Software\Ghdl" "Install_Dir" $INSTDIR + ; Write te version + WriteRegStr HKLM "Software\Ghdl" "Version" ${VERSION} + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "DisplayName" "Ghdl" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "UninstallString" $INSTDIR\uninst-ghdl.exe + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "NoRepair" 1 + WriteUninstaller $INSTDIR\uninst-ghdl.exe" + +SectionEnd + +Section "VHDL standard and ieee libraries" + SectionIn RO + SetOutPath $INSTDIR\lib\v87 + File /r ..\lib\v87\std ..\lib\v87\ieee + SetOutPath $INSTDIR\lib\v93 + File /r ..\lib\v93\std ..\lib\v93\ieee + SetOutPath $INSTDIR\lib\v08 + File /r ..\lib\v08\std ..\lib\v08\ieee +SectionEnd + +Section "Synopsys libraries (Recommended)" + SetOutPath $INSTDIR\lib\v87 + File /r ..\lib\v87\synopsys + SetOutPath $INSTDIR\lib\v93 + File /r ..\lib\v93\synopsys +SectionEnd + +Section "Documentation (Recommended)" + SetOutPath $INSTDIR + File /oname=ghdl.htm ..\..\..\doc\ghdl.html +SectionEnd + +Section "Add in PATH (Recommended)" + WriteRegDWORD HKLM "Software\Ghdl" "PathSet" 1 + Push $INSTDIR\Bin + Call AddToPath +SectionEnd + +; Optional section (can be disabled by the user) +;Section "Start Menu Shortcuts" +; +; CreateDirectory "$SMPROGRAMS\Ghdl" +; CreateShortCut "$SMPROGRAMS\Ghdl\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 +; CreateShortCut "$SMPROGRAMS\Ghdl\Ghdl.lnk" "$INSTDIR\example2.nsi" "" "$INSTDIR\example2.nsi" 0 +; +;SectionEnd +; + +;-------------------------------- + +; Uninstaller + +Section "Uninstall" + + ReadRegDWORD $0 HKLM "Software\Ghdl" "PathSet" + StrCmp $0 "1" "" path_not_set + Push $INSTDIR\Bin + Call un.RemoveFromPath + +path_not_set: + + ; Remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" + DeleteRegKey HKLM Software\Ghdl + + ; Remove files and uninstaller + Delete $INSTDIR\bin\ghdl.exe + Delete $INSTDIR\bin\ghdl.htm + Delete $INSTDIR\uninst-ghdl.exe + Delete $INSTDIR\COPYING.txt + RMDir $INSTDIR\bin + RMDir /r $INSTDIR\lib + + + ; Remove shortcuts, if any + ; Delete "$SMPROGRAMS\Ghdl\*.*" + + ; Remove directories used + ; RMDir "$SMPROGRAMS\Ghdl" + RMDir "$INSTDIR" + +SectionEnd + +;;;;;;;; Misc functions + +; Author: Lilla (lilla@earthlink.net) 2003-06-13 +; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll +; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi +; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing). +; +; Usage: +; Call IsUserAdmin +; Pop $R0 ; at this point $R0 is "true" or "false" +; +Function IsUserAdmin +Push $R0 +Push $R1 +Push $R2 + +ClearErrors +UserInfo::GetName +IfErrors Win9x +Pop $R1 +UserInfo::GetAccountType +Pop $R2 + +StrCmp $R2 "Admin" 0 Continue +; Observation: I get here when running Win98SE. (Lilla) +; The functions UserInfo.dll looks for are there on Win98 too, +; but just don't work. So UserInfo.dll, knowing that admin isn't required +; on Win98, returns admin anyway. (per kichik) +; MessageBox MB_OK 'User "$R1" is in the Administrators group' +StrCpy $R0 "true" +Goto Done + +Continue: +; You should still check for an empty string because the functions +; UserInfo.dll looks for may not be present on Windows 95. (per kichik) +StrCmp $R2 "" Win9x +StrCpy $R0 "false" +;MessageBox MB_OK 'User "$R1" is in the "$R2" group' +Goto Done + +Win9x: +; comment/message below is by UserInfo.nsi author: +; This one means you don't need to care about admin or +; not admin because Windows 9x doesn't either +;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" +StrCpy $R0 "true" + +Done: +;MessageBox MB_OK 'User= "$R1" AccountType= "$R2" IsUserAdmin= "$R0"' + +Pop $R2 +Pop $R1 +Exch $R0 +FunctionEnd + + +!define ALL_USERS + +!ifndef WriteEnvStr_RegKey + !ifdef ALL_USERS + !define WriteEnvStr_RegKey \ + 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' + !else + !define WriteEnvStr_RegKey 'HKCU "Environment"' + !endif +!endif + +!verbose 3 +!include "WinMessages.NSH" +!verbose 4 + +; AddToPath - Adds the given dir to the search path. +; Input - head of the stack +; Note - Win9x systems requires reboot + +Function AddToPath + Exch $0 + Push $1 + Push $2 + Push $3 + + # don't add if the path doesn't exist + IfFileExists "$0\*.*" "" AddToPath_done + + ReadEnvStr $1 PATH + Push "$1;" + Push "$0;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$0\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + GetFullPathName /SHORT $3 $0 + Push "$1;" + Push "$3;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$3\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + + ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" + StrCpy $2 $1 1 -1 # copy last char + StrCmp $2 ";" 0 +2 # if last char == ; + StrCpy $1 $1 -1 # remove last char + StrCmp $1 "" AddToPath_NTdoIt + StrCpy $0 "$1;$0" + AddToPath_NTdoIt: + WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0 + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + AddToPath_done: + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +; RemoveFromPath - Remove a given dir from the path +; Input: head of the stack + +Function un.RemoveFromPath + Exch $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + + IntFmt $6 "%c" 26 # DOS EOF + + ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" + StrCpy $5 $1 1 -1 # copy last char + StrCmp $5 ";" +2 # if last char != ; + StrCpy $1 "$1;" # append ; + Push $1 + Push "$0;" + Call un.StrStr ; Find `$0;` in $1 + Pop $2 ; pos of our dir + StrCmp $2 "" unRemoveFromPath_done + ; else, it is in path + # $0 - path to add + # $1 - path var + StrLen $3 "$0;" + StrLen $4 $2 + StrCpy $5 $1 -$4 # $5 is now the part before the path to remove + StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove + StrCpy $3 $5$6 + + StrCpy $5 $3 1 -1 # copy last char + StrCmp $5 ";" 0 +2 # if last char == ; + StrCpy $3 $3 -1 # remove last char + + WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3 + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + unRemoveFromPath_done: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +########################################### +# Utility Functions # +########################################### + +; IsNT +; no input +; output, top of the stack = 1 if NT or 0 if not +; +; Usage: +; Call IsNT +; Pop $R0 +; ($R0 at this point is 1 or 0) + +!macro IsNT un +Function ${un}IsNT + Push $0 + ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion + StrCmp $0 "" 0 IsNT_yes + ; we are not NT. + Pop $0 + Push 0 + Return + + IsNT_yes: + ; NT!!! + Pop $0 + Push 1 +FunctionEnd +!macroend +!insertmacro IsNT "" +;!insertmacro IsNT "un." + +; StrStr +; input, top of stack = string to search for +; top of stack-1 = string to search in +; output, top of stack (replaces with the portion of the string remaining) +; modifies no other variables. +; +; Usage: +; Push "this is a long ass string" +; Push "ass" +; Call StrStr +; Pop $R0 +; ($R0 at this point is "ass string") + +!macro StrStr un +Function ${un}StrStr +Exch $R1 ; st=haystack,old$R1, $R1=needle + Exch ; st=old$R1,haystack + Exch $R2 ; st=old$R1,old$R2, $R2=haystack + Push $R3 + Push $R4 + Push $R5 + StrLen $R3 $R1 + StrCpy $R4 0 + ; $R1=needle + ; $R2=haystack + ; $R3=len(needle) + ; $R4=cnt + ; $R5=tmp + loop: + StrCpy $R5 $R2 $R3 $R4 + StrCmp $R5 $R1 done + StrCmp $R5 "" done + IntOp $R4 $R4 + 1 + Goto loop +done: + StrCpy $R1 $R2 "" $R4 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Exch $R1 +FunctionEnd +!macroend +!insertmacro StrStr "" +!insertmacro StrStr "un." + diff --git a/dist/windows/mcode/ghdlfilter.adb b/dist/windows/mcode/ghdlfilter.adb new file mode 100644 index 000000000..d75526dbd --- /dev/null +++ b/dist/windows/mcode/ghdlfilter.adb @@ -0,0 +1,132 @@ +-- +-- Preprocessor to handle library source metacomments +-- +-- Limitations: +-- - line metacomments must occur at end of line with no trailing space before the line break +-- - block metacomments must start in column 1 +-- +-- Supported line metacomments: +-- +-- --!V87 +-- --V87 +-- --V93 +-- --V08 +-- +-- Supported block metacomments: +-- +-- --START-!V87 +-- --END-!V87 +-- +-- --START-V93 +-- --END-V93 +-- +-- --START-V08 +-- --END-V08 +-- +-- +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Ghdlfilter is + type Mode_Kind is (Mode_93, Mode_87, Mode_08); + Mode : Mode_Kind; + + Line : String (1 .. 128); + Len : Natural; + + Comment : Boolean; + Block_Comment : Boolean; +begin + if Argument_Count /= 1 then + Put_Line (Standard_Error, "usage: " & Command_Name & " -v93|-v87|-v08"); + return; + end if; + + if Argument (1) = "-v93" then + Mode := Mode_93; + elsif Argument (1) = "-v87" then + Mode := Mode_87; + elsif Argument (1) = "-v08" then + Mode := Mode_08; + else + Put_Line (Standard_Error, "bad mode"); + return; + end if; + + Block_Comment := False; + + loop + exit when End_Of_File; + Get_Line (Line, Len); + + Comment := Block_Comment; + + -- + -- look for line metacomments + -- + if Len > 6 then + + if Mode = Mode_87 and ( Line (Len - 5 .. Len) = "--!V87" ) then + Comment := True; + end if; + + end if; + + + if Len > 5 then + + if Mode = Mode_87 and ( (Line (Len - 4 .. Len) = "--V93") or (Line (Len - 4 .. Len) = "--V08") ) then + Comment := True; + + elsif Mode = Mode_93 and ( (Line (Len - 4 .. Len) = "--V87") or (Line (Len - 4 .. Len) = "--V08") ) then + Comment := True; + + elsif Mode = Mode_08 and ( (Line (Len - 4 .. Len) = "--V87") or (Line (Len - 4 .. Len) = "--V93") ) then + Comment := True; + end if; + + end if; + + -- + -- look for block metacomment start + -- + if Len = 12 + and then Mode /= Mode_93 + and then Line (1 .. 12) = "--START-!V87" then + Block_Comment := True; + end if; + + if Len = 11 + and then Mode /= Mode_93 + and then Line (1 .. 11) = "--START-V93" then + Block_Comment := True; + end if; + + if Len = 11 + and then Mode /= Mode_08 + and then Line (1 .. 11) = "--START-V08" then + Block_Comment := True; + end if; + + -- + -- look for block metacomment end + -- + if Len = 9 and then ( (Line (1 .. 9) = "--END-V93") or (Line (1 .. 9) = "--END-V08") ) then + Block_Comment := False; + end if; + + if Len = 10 and then ( Line (1 .. 10) = "--END-!V87" ) then + Block_Comment := False; + end if; + + -- + -- comment output lines as needed + -- + if Comment then + Put ("-- "); + end if; + + Put_Line (Line (1 .. Len)); + + end loop; +end Ghdlfilter; diff --git a/dist/windows/mcode/ghdlversion.adb b/dist/windows/mcode/ghdlversion.adb new file mode 100644 index 000000000..d2f1c28be --- /dev/null +++ b/dist/windows/mcode/ghdlversion.adb @@ -0,0 +1,30 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; + +procedure Ghdlversion is + Line : String (1 .. 128); + Len : Natural; + Pos : Natural; + E : Natural; +begin + loop + exit when End_Of_File; + Get_Line (Line, Len); + + -- Search GHDL + Pos := Index (Line (1 .. Len), "GHDL "); + if Pos /= 0 then + Pos := Pos + 5; + E := Pos; + while Line (E) in '0' .. '9' + or Line (E) in 'a' .. 'z' + or Line (E) = '.' + loop + exit when E = Len; + E := E + 1; + end loop; + Put_Line ("!define VERSION """ & Line (Pos .. E - 1) & """"); + return; + end if; + end loop; +end Ghdlversion; diff --git a/dist/windows/mcode/grt-modules.adb b/dist/windows/mcode/grt-modules.adb new file mode 100644 index 000000000..de5eb79b8 --- /dev/null +++ b/dist/windows/mcode/grt-modules.adb @@ -0,0 +1,39 @@ +-- GHDL Run Time (GRT) - Modules. +-- Copyright (C) 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 GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +with System.Storage_Elements; -- Work around GNAT bug. +with Grt.Vcd; +with Grt.Vpi; +with Grt.Waves; +with Grt.Vital_Annotate; +with Grt.Disp_Tree; +with Grt.Disp_Rti; +with Grt.Backtraces; + +package body Grt.Modules is + procedure Register_Modules is + begin + -- List of modules to be registered. + Grt.Disp_Tree.Register; + Grt.Vcd.Register; + Grt.Waves.Register; + Grt.Vpi.Register; + Grt.Vital_Annotate.Register; + Grt.Disp_Rti.Register; + Grt.Backtraces.Register; + end Register_Modules; +end Grt.Modules; diff --git a/dist/windows/mcode/ortho_code-x86-flags.ads b/dist/windows/mcode/ortho_code-x86-flags.ads new file mode 100644 index 000000000..8915f3122 --- /dev/null +++ b/dist/windows/mcode/ortho_code-x86-flags.ads @@ -0,0 +1,2 @@ +with Ortho_Code.X86.Flags_Windows; +package Ortho_Code.X86.Flags renames Ortho_Code.X86.Flags_Windows; diff --git a/dist/windows/mcode/winbuild.ps1 b/dist/windows/mcode/winbuild.ps1 deleted file mode 100644 index 230213fcc..000000000 --- a/dist/windows/mcode/winbuild.ps1 +++ /dev/null @@ -1,692 +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; -# -# ============================================================================== -# 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: -# - compiles GHDL and GHDLFilter -# - analyses VHDL libraries -# - installs GHDL into a directory (xcopy deploiment) -# -# ============================================================================== -# 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 'winbuild.ps1 -Help' to see the integrated help page -# -# .EXAMPLE -# # -# # Normal flow -# PS> .\winbuild.ps1 -Clean -# PS> .\winbuild.ps1 -Compile -# PS> .\winbuild.ps1 -Install -# -# # Combine all commands in a single call -# PS>.\winbuild.ps1 -Clean -Compile -Install "C:\Tools\GHDL" -# -# # Install to user defined dir -# PS> .\winbuild.ps1 -Install "C:\Tools\GHDL" -# -# # Update or Uninstall -# PS> .\winbuild.ps1 -Update -# PS> .\winbuild.ps1 -Uninstall -# -# # Create a Zip-file -# PS>.\winbuild.ps1 -CreatePackage -Zip -# -[CmdletBinding()] -Param( - # clean up all files and directories - [switch]$Clean, - [switch]$Clean_GHDL, - [switch]$Clean_Libraries, - - # compile GHDL - [switch]$Compile, - [switch]$Compile_GHDL, - [switch]$Compile_Libraries, - - # create an installer package - [switch]$CreatePackage, - # creates a zip-file for xcopy deployment - [switch]$Zip, - - # install all files into a directory (xcopy deployment) - [switch]$Install = $false, - [parameter(mandatory=$false, ValueFromRemainingArguments=$true)] - [string]$InstallDir = "", - # update files - [switch]$Update, - # uninstall all files from a directory - [switch]$Uninstall, - - # display this help" - [switch]$Help -) - -# configure script here -$RelPathToRoot = "..\.." - -# save parameters and current working directory -$Script_ScriptDir = $PSScriptRoot -$Script_WorkingDir = Get-Location -$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) - -# set default values -$Hosting = $true -$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"] -$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"] -if ($EnableVerbose -eq $null) { $EnableVerbose = $false } -if ($EnableDebug -eq $null) { $EnableDebug = $false } -if ($EnableDebug -eq $true) { $EnableVerbose = $true } - -# load modules from GHDL's 'libraries' directory -Import-Module $PSScriptRoot\windows\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosting -Import-Module $PSScriptRoot\windows\targets.psm1 -Verbose:$false -Debug:$false - -# Display help if no command was selected -$Help = $Help -or (-not ( - $All -or - $Clean -or $Clean_GHDL -or $Clean_Libraries -or $Clean_Package_Zip -or - $Compile -or $Compile_GHDL -or $Compile_Libraries -or - $CreatePackage -or - $Install -or $Update -or $Uninstall - )) - -Write-Host "================================================================================" -ForegroundColor Magenta -Write-Host "GHDL for Windows - GHDL compile and bundle script" -ForegroundColor Magenta -Write-Host "================================================================================" -ForegroundColor Magenta - -if ($Help) -{ Get-Help $MYINVOCATION.InvocationName -Detailed - Exit-CompileScript -} - -if ($All) -{ $Clean = $true - $Compile = $true - $CreatePackage = $true -} -if ($Clean) -{ $Clean_GHDL = $true - $Clean_Libraries = $true - $Clean_Package_Zip = $true -} -if ($Compile) -{ $Compile_GHDL = $true - $Compile_Libraries = $true -} - -# configure some variables: paths, executables, directory names, ... -$GHDLVersion = Get-GHDLVersion $GHDLRootDir -$Backend = "mcode" -$WindowsDirName = "dist\$Backend\windows" -$BuildDirectoryName = "build" -$BuildBackendDirectoryName = "$BuildDirectoryName\$Backend" -$VHDLLibrariesDirectoryName = "lib" -$PackageDirectoryName = "build\zip\$Backend" -$ZipPackageFileName = "ghdl-$Backend-$GHDLVersion.zip" -$DefaultInstallPath = "C:\Program Files (x86)\GHDL" # This is the default path for 32-bit applications (x86-32) - -# construct directories -$GHDLWindowsDir = "$GHDLRootDir\$WindowsDirName" -$GHDLBuildDir = "$GHDLRootDir\$BuildBackendDirectoryName" -$GHDLVendorLibraryDir = "$GHDLRootDir\libraries\vendors" -$GHDLCompiledLibraryDir = "$GHDLRootDir\$BuildBackendDirectoryName\$VHDLLibrariesDirectoryName" -$GHDLZipPackageDir = "$GHDLRootDir\$PackageDirectoryName" -$GHDLZipPackageFile = "$GHDLZipPackageDir\$ZipPackageFileName" - -# construct files -$InstallDirFile = "$BuildDirectoryName\InstallDir.conf" - -$EnvPath_ContainerMapping = @{ - Machine = [EnvironmentVariableTarget]::Machine - User = [EnvironmentVariableTarget]::User -} - -function Exit-Script -{ [CmdletBinding()] - param( - [int]$ExitCode = 0 - ) - cd $Script_WorkingDir - # unload modules - Remove-Module shared -Verbose:$false -Debug:$false - Remove-Module targets -Verbose:$false -Debug:$false - exit $ExitCode -} - -# GitHub user: https://github.com/mkropat -# Gist account at GitHub: https://gist.github.com/mkropat -# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 -function Add-EnvPath -{ param( - [Parameter(Mandatory=$true)] - [string] $Path, - - [ValidateSet("Machine", "User", "Session")] - [string] $Container = "Session" - ) - - if ($Container -ne "Session") - { $containerType = $EnvPath_ContainerMapping[$Container] - $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" - if ($persistedPaths -notcontains $Path) - { $persistedPaths = $persistedPaths + $Path | where { $_ } - [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) - } - } - - $envPaths = $env:Path -split ";" - if ($envPaths -notcontains $Path) - { $envPaths = $envPaths + $Path | where { $_ } - $env:Path = $envPaths -join ";" - } -} - -# GitHub user: https://github.com/mkropat -# Gist account at GitHub: https://gist.github.com/mkropat -# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 -function Remove-EnvPath -{ param ( - [Parameter(Mandatory=$true)] - [string] $Path, - - [ValidateSet("Machine", "User", "Session")] - [string] $Container = "Session" - ) - - if ($Container -ne "Session") - { $containerType = $EnvPath_ContainerMapping[$Container] - $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" - if ($persistedPaths -contains $Path) - { $persistedPaths = $persistedPaths | where { $_ -and $_ -ne $Path } - [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) - } - } - - $envPaths = $env:Path -split ";" - if ($envPaths -contains $Path) - { $envPaths = $envPaths | where { $_ -and $_ -ne $Path } - $env:Path = $envPaths -join ";" - } -} - -# GitHub user: https://github.com/mkropat -# Gist account at GitHub: https://gist.github.com/mkropat -# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 -function Get-EnvPath -{ param ( - [Parameter(Mandatory=$true)] - [ValidateSet("Machine", "User")] - [string] $Container - ) - - $containerType = $EnvPath_ContainerMapping[$Container] - [Environment]::GetEnvironmentVariable('Path', $containerType) -split ";" | where { $_ } -} - - -if ($false) -{ # Write-Host "Uninstalling GHDL $GHDLVersion for Windows..." - - # Write-Host "[ERROR]: This command is not implemented." -ForegroundColor Red - Exit-Script -1 -} # Uninstall -else -{ # ============================================================================ - # Clean tasks - # ============================================================================ - if ($Clean) - { Write-Host "Removing all created files and directories..." } - - if ($Clean_GHDL) - { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" - $Script_Parameters = @( - '-Clean', - '-Hosted', - '-Verbose:$EnableVerbose', - '-Debug:$EnableDebug' - ) - - Write-Host "Running compile-ghdl.ps1 -Clean ..." -ForegroundColor DarkCyan - Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") - Invoke-Expression $InvokeExpr - if ($LastExitCode -ne 0) - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red - Exit-Script -1 - } - else - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "Completed compile-ghdl.ps1 " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - } - } # Clean_GHDL - if ($Clean_Libraries) - { if ($Clean_GHDL) - { Write-Host } - - $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1" - $Script_Parameters = @( - '-Clean', - '-Hosted', - '-Verbose:$EnableVerbose', - '-Debug:$EnableDebug' - ) - - Write-Host "Running compile-libraries.ps1 -Clean ..." -ForegroundColor DarkCyan - Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") - Invoke-Expression $InvokeExpr - if ($LastExitCode -ne 0) - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red - Exit-Script -1 - } - else - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "Completed compile-libraries.ps1 " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - } - } # Clean_Libraries - if ($Clean_Package_Zip) - { if ($Clean_GHDL -or $Clean_Libraries) - { Write-Host } - - Write-Host "Running more clean-up tasks..." -ForegroundColor DarkCyan - Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "Removing installer packages and temporary directories..." -ForegroundColor Yellow - if (Test-Path -Path $GHDLZipPackageDir) - { Write-Host " rmdir $GHDLZipPackageDir" - Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue - if ($? -eq $false) - { Write-Host "[ERROR]: While deleting '$GHDLZipPackageDir'." -ForegroundColor Red - Exit-Script -1 - } - } - - if (Test-Path -Path $GHDLZipPackageFile) - { Write-Host " rm $GHDLZipPackageFile" - Remove-Item $GHDLZipPackageFile -Force -Recurse -ErrorAction SilentlyContinue - if ($? -eq $false) - { Write-Host "[ERROR]: While deleting '$GHDLZipPackageFile'." -ForegroundColor Red - Exit-Script -1 - } - } - - Write-Host - Write-Host "Clean " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - } # Clean_Package_Zip - - # ============================================================================ - # Compile tasks - # ============================================================================ - if ($Compile_GHDL) - { if ($Clean) - { Write-Host } - - $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" - $Script_Parameters = @() - $Script_Parameters = @( - '-All', - '-Hosted', - '-Verbose:$EnableVerbose', - '-Debug:$EnableDebug' - ) - - # Write-Host "Compiling GHDL $GHDLVersion for Windows..." -ForegroundColor DarkCyan - # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - - Write-Host - Write-Host "Running compile-ghdl.ps1 -All ..." -ForegroundColor DarkCyan - Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") - Invoke-Expression $InvokeExpr - if ($LastExitCode -ne 0) - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red - Exit-Script -1 - } - else - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "Completed compile-ghdl.ps1 " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - } - } # Compile_GHDL - if ($Compile_Libraries) - { if ($Compile_GHDL) - { Write-Host } - - $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1" - $Script_Parameters = @() - $Script_Parameters = @( - '-Compile', - '-Hosted', - '-Verbose:$EnableVerbose', - '-Debug:$EnableDebug' - ) - - # Write-Host "Compiling GHDL's libraries ..." -ForegroundColor DarkCyan - # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - - $env:GHDL = "$GHDLBuildDir\ghdl.exe" - Write-Host ("Setting env:GHDL to '" + $env:GHDL + "'") - - Write-Host - Write-Host "Running compile-libraries.ps1 -Compile ..." -ForegroundColor DarkCyan - Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") - Invoke-Expression $InvokeExpr - if ($LastExitCode -ne 0) - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red - Exit-Script -1 - } - else - { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan - Write-Host "Completed compile-libraries.ps1 " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - } - } # Compile_GHDL - - # ============================================================================ - # Package tasks - # ============================================================================ - if ($CreatePackage) - { Write-Host "Creating an installation package for GHDL $GHDLVersion for Windows" - - if ($Zip) - { Write-Host "Loading PowerShell Community Extensions (PSCX) " -NoNewline - if ((Get-Module -ListAvailable | Where {$_.Name -like "PSCX"}).Version -ge "3.1.0.0") - { Import-Module Pscx -Verbose:$false - Write-Host "[Done]" -ForegroundColor Green - } - else - { Write-Host "[FAILED]" -ForegroundColor RED - Exit-Script -1 - } - - Write-Host "Output format: zip-file" - Write-Host " Removing old directory '$GHDLZipPackageDir'." - if (Test-Path -Path $GHDLZipPackageDir) - { Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue - if ($? -eq $false) - { Write-Host "[ERROR]: While deleting '$GHDLZipPackageDir'." -ForegroundColor Red - Exit-Script -1 - } - } - if (Test-Path -Path $GHDLZipPackageFile) - { Remove-Item $GHDLZipPackageFile -Force -Recurse -ErrorAction SilentlyContinue - if ($? -eq $false) - { Write-Host "[ERROR]: While deleting '$GHDLZipPackageFile'." -ForegroundColor Red - Exit-Script -1 - } - } - - Write-Host " Creating directory '$GHDLZipPackageDir' and sub-directories..." - New-Item -ItemType directory -Path "$GHDLZipPackageDir" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$GHDLZipPackageDir\bin" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$GHDLZipPackageDir\include" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$GHDLZipPackageDir\lib" -ErrorAction SilentlyContinue | Out-Null - - Write-Host " Gathering files..." - # executables - Copy-Item "$GHDLBuildDir\ghdl.exe" "$GHDLZipPackageDir\bin\ghdl.exe" -ErrorAction SilentlyContinue - # include files - Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$GHDLZipPackageDir\include" -ErrorAction SilentlyContinue - # pre-compile scripts - Copy-Item $GHDLVendorLibraryDir -Recurse "$GHDLZipPackageDir\lib\vendors" -ErrorAction SilentlyContinue - # pre-compiled libraries - Copy-Item $GHDLCompiledLibraryDir -Recurse "$GHDLZipPackageDir" -ErrorAction SilentlyContinue - - Write-Host " Compressing all files into '$GHDLZipPackageFile'..." - $file = Get-ChildItem $GHDLZipPackageDir -Recurse | Write-Zip -IncludeEmptyDirectories -EntryPathRoot $GHDLZipPackageDir -OutputPath $GHDLZipPackageFile - Write-Host " $([math]::round(($file.Length / 1MB), 3)) MiB written to disk" - - Write-Host - Write-Host "Creating package " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - } - else - { Write-Host "[ERROR]: No package format selected." -ForegroundColor Red - Write-Host "Possible formats:" - Write-Host " - Zip-file (-Zip)" - Write-Host - } - } - # ============================================================================ - # Compile tasks - # ============================================================================ - if ($Install) - { Write-Host "Installing GHDL $GHDLVersion for Windows..." - if ($InstallDir -eq "") - { if (Test-Path $InstallDirFile -PathType Leaf) - { Write-Host " Reading installation path from '$InstallDirFile' ..." - $InstallPath = Get-Content $InstallDirFile -Encoding Ascii - } - else - { $InstallPath = $DefaultInstallPath } - } - else - { $InstallPath = $InstallDir } - $InstallPath = $InstallPath.TrimEnd("\") - - if ($Zip) - { Write-Host "Loading PowerShell Community Extensions (PSCX) " -NoNewline - if ((Get-Module -ListAvailable | Where {$_.Name -like "PSCX"}).Version -ge "3.1.0.0") - { Import-Module Pscx -Verbose:$false - Write-Host "[Done]" -ForegroundColor Green - } - else - { Write-Host "[FAILED]" -ForegroundColor RED - Exit-Script -1 - } - - Write-Host " Installing from Zip-file..." - - Write-Host "[ERROR]: This command is not implemented." -ForegroundColor Red - } - else - { Write-Host " Writing installation path to '$InstallDirFile'..." - $InstallPath | Out-File -FilePath $InstallDirFile -Encoding Ascii - - if (Test-Path -Path $InstallPath) - { Write-Host "[ERROR]: Directory '$InstallPath' already exists." -ForegroundColor Red - Exit-Script -1 - } - Write-Host " Install directory: $InstallPath" - Write-Host " Creating directory '$InstallPath' and sub-directories..." - New-Item -ItemType directory -Path "$InstallPath" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$InstallPath\bin" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$InstallPath\include" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$InstallPath\lib" -ErrorAction SilentlyContinue | Out-Null - - Write-Host " Copying files..." - # executables - Copy-Item "$GHDLBuildDir\ghdl.exe" "$InstallPath\bin\ghdl.exe" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - # include files - Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$InstallPath\include" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - # pre-compile scripts - Copy-Item $GHDLVendorLibraryDir -Recurse "$InstallPath\lib" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - # pre-compiled libraries - Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - - Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan - Write-Host "M" -NoNewline -ForegroundColor Cyan - Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan - Write-Host "u" -NoNewline -ForegroundColor Cyan - Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan - Write-Host "s" -NoNewline -ForegroundColor Cyan - Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan - Write-Host "n" -NoNewline -ForegroundColor Cyan - Write-Host "o]: " -NoNewline -ForegroundColor DarkCyan - $InstallInPath = (Read-Host).ToLower() - if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) - { Write-Host " Adding GHDL to PATH at machine level." - Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" - Add-EnvPath -Path "$InstallPath\bin" -Container "Session" - } - elseif ($InstallInPath -eq "u") - { Write-Host " Adding GHDL to PATH at user level." - Add-EnvPath -Path "$InstallPath\bin" -Container "User" - Add-EnvPath -Path "$InstallPath\bin" -Container "Session" - } - elseif ($InstallInPath -eq "s") - { Write-Host " Adding GHDL to PATH at session level." - Add-EnvPath -Path "$InstallPath\bin" -Container "Session" - } - - Write-Host - Write-Host "Installing files " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - - Exit-Script - } # Zip - } # Install - elseif ($Update) - { Write-Host "Updating GHDL $GHDLVersion for Windows..." - if (Test-Path $InstallDirFile -PathType Leaf) - { Write-Host " Reading installation path from '$InstallDirFile' ..." - $InstallPath = Get-Content $InstallDirFile -Encoding Ascii - } - else - { $InstallPath = $InstallDir } - $InstallPath = $InstallPath.TrimEnd("\") - - Write-Host " Install directory: $InstallPath" - if (Test-Path -Path $InstallPath) - { Write-Host " Cleaning up installation directory '$InstallPath'." -ForegroundColor Yellow - Get-ChildItem -Path $InstallPath -Depth 0 | foreach { Remove-Item $_ -Recurse -ErrorAction SilentlyContinue } - } - - Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow - foreach ($container in @("Machine", "User")) - { foreach ($entry in (Get-EnvPath -Container $container)) - { if ($entry.ToLower().Contains("ghdl")) - { Write-Host " Removing '$entry' from $container level." - Remove-EnvPath -Path $entry -Container $container - } - } - } - Remove-EnvPath -Path $entry -Container "Session" - - Write-Host " Creating directory sub-directories in '$InstallPath' ..." - New-Item -ItemType directory -Path "$InstallPath\bin" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$InstallPath\include" -ErrorAction SilentlyContinue | Out-Null - New-Item -ItemType directory -Path "$InstallPath\lib" -ErrorAction SilentlyContinue | Out-Null - - Write-Host " Copying files..." - # executables - Copy-Item "$GHDLBuildDir\ghdl.exe" "$InstallPath\bin\ghdl.exe" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - # include files - Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$InstallPath\include" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - # pre-compile scripts - Copy-Item $GHDLVendorLibraryDir -Recurse "$InstallPath\lib" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - # pre-compiled libraries - Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue - - Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan - Write-Host "M" -NoNewline -ForegroundColor Cyan - Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan - Write-Host "u" -NoNewline -ForegroundColor Cyan - Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan - Write-Host "s" -NoNewline -ForegroundColor Cyan - Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan - Write-Host "n" -NoNewline -ForegroundColor Cyan - Write-Host "o]: " -NoNewline -ForegroundColor DarkCyan - $InstallInPath = (Read-Host).ToLower() - if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) - { Write-Host " Adding GHDL to PATH at machine level." - Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" - Add-EnvPath -Path "$InstallPath\bin" -Container "Session" - } - elseif ($InstallInPath -eq "u") - { Write-Host " Adding GHDL to PATH at user level." - Add-EnvPath -Path "$InstallPath\bin" -Container "User" - Add-EnvPath -Path "$InstallPath\bin" -Container "Session" - } - elseif ($InstallInPath -eq "s") - { Write-Host " Adding GHDL to PATH at session level." - Add-EnvPath -Path "$InstallPath\bin" -Container "Session" - } - - Write-Host - Write-Host "Updating files " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - - Exit-Script - } # Update - elseif ($Uninstall) - { Write-Host "Uninstalling GHDL $GHDLVersion for Windows..." - if (Test-Path $InstallDirFile -PathType Leaf) - { Write-Host " Reading installation path from '$InstallDirFile' ..." - $InstallPath = Get-Content $InstallDirFile -Encoding Ascii - } - else - { $InstallPath = $DefaultInstallPath } - - Write-Host " Install directory: $InstallPath" - if (Test-Path -Path $InstallPath) - { Write-Host " Removing installation directory '$InstallPath'." -ForegroundColor Yellow - Remove-Item $InstallPath -Recurse -ErrorAction SilentlyContinue - } - - Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow - foreach ($container in @("Machine", "User")) - { foreach ($entry in (Get-EnvPath -Container $container)) - { if ($entry.ToLower().Contains("ghdl")) - { Write-Host " Removing '$entry' from $container level." - Remove-EnvPath -Path $entry -Container $container - } - } - } - Remove-EnvPath -Path $entry -Container "Session" - - Write-Host - Write-Host "Uninstalling files " -NoNewline - Write-Host "[SUCCESSFUL]" -ForegroundColor Green - Write-Host - - Exit-Script - } # Update - -} # Clean - -Exit-Script diff --git a/dist/windows/mcode/windows/compile-ghdl.ps1 b/dist/windows/mcode/windows/compile-ghdl.ps1 deleted file mode 100644 index 2938683db..000000000 --- a/dist/windows/mcode/windows/compile-ghdl.ps1 +++ /dev/null @@ -1,246 +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; -# -# ============================================================================== -# 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 -# -[CmdletBinding()] -param( - # Display this help" - [switch]$Help = $false, - - # Slean up all files and directories - [switch]$Clean = $false, - [switch]$Clean_GHDL = $false, - - # Compile all targets - [switch]$All = $false, - - # Compile main targets - [switch]$Compile = $false, - # Compile GHDL (simulator) - [switch]$Compile_GHDL = $false, - # Undocumented - [switch]$Test = $false, - # Undocumented - [switch]$Test_GHDL = $false, - - # Build options - # Build a release version - [switch]$Release = $false, - # Set the back-end - [string]$Backend = "mcode", - - # Reduced messages - [switch]$Quiet = $false, - # Skip warning messages. (Show errors only.) - [switch]$SuppressWarnings = $false, - # Halt on errors - [switch]$HaltOnError = $false, - # Undocumented - [switch]$Hosted = $false -) - -# configure script here -$RelPathToRoot = "..\..\.." - -# --------------------------------------------- -# save parameters and working directory -$Script_ScriptDir = $PSScriptRoot -$Script_WorkingDir = Get-Location -$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) - -# set default values -$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"] -$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"] -if ($EnableVerbose -eq $null) { $EnableVerbose = $false } -if ($EnableDebug -eq $null) { $EnableDebug = $false } -if ($EnableDebug -eq $true) { $EnableVerbose = $true } - -# load modules from GHDL's 'libraries' directory -Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosted -Import-Module $PSScriptRoot\targets.psm1 -Verbose:$false -Debug:$false - -# Display help if no command was selected -$Help = $Help -or (-not ( - $All -or - $Clean -or $Clean_GHDL -or - $Compile -or $Compile_GHDL -or - $Test -or $Test_GHDL - )) - -if (-not $Hosted) -{ Write-Host "================================================================================" -ForegroundColor Magenta - Write-Host "GHDL for Windows - GHDL compile script" -ForegroundColor Magenta - Write-Host "================================================================================" -ForegroundColor Magenta -} - -if ($Help) -{ Get-Help $MYINVOCATION.InvocationName -Detailed - Exit-CompileScript -} - -if ($Clean) -{ $Clean_GHDL = $true -} -if ($All) -{ $Compile = $true -} -if ($Compile) -{ $Compile_GHDL = $true -} -if ($Test) -{ $Test_GHDL = $true -} - -# configure some variables: paths, executables, directory names, ... -$BuildDirectoryName = "build" - -# Parameter checks -if ($Backend -ne "mcode") -{ Write-Host "[ERROR]: Back-end '$Backend' is not supported on Windows." -ForegroundColor Red - Exit-CompileScript -1 -} - -# construct directories -$BinaryDestinationDirectory = "$GHDLRootDir\$BuildDirectoryName\$Backend" -# construct executables -$GHDLNewExecutable = "$GHDLRootDir\$BuildDirectoryName\$Backend\bin\ghdl.exe" - -# grep GHDL version string from Ada source file -$GHDLVersion = Get-GHDLVersion $GHDLRootDir -# compute some variables -$BuildRelease = if ($Release) { "Release" } else { "Development" } -if (-not $Hosted) -{ Write-Host " Version: $GHDLVersion" - Write-Host " Release: $BuildRelease" -} - -$Git_IsGitRepo = Test-GitRepository -# gather git information -if ($Git_IsGitRepo) -{ $Git_Branch_Name = & git rev-parse --abbrev-ref HEAD - $Git_Commit_DateString = & git log -1 --format=%cd --date=short - $Git_Commit_ShortHash = & git rev-parse --short HEAD - - if (-not $Hosted) - { Write-Host " Git branch: $Git_Branch_Name" - Write-Host " Git commit: $Git_Commit_DataString ($Git_Commit_ShortHash)" - } -} -if (-not $Hosted) -{ Write-Host "" } - -if ($Release) -{ $BuildDirectory = $BinaryDestinationDirectory } -else -{ $BuildDirectory = $BinaryDestinationDirectory } - - -# ============================================================================== -# Main Target: Clean -# ============================================================================== -if ($Clean_GHDL) -{ $error = Invoke-Clean $BuildDirectory -Quiet:$Quiet -Verbose:$EnableVerbose -Debug:$EnableDebug - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } -} # Clean - - -# ============================================================================== -# Main Target: GHDL -# ============================================================================== -if ($Compile_GHDL) -{ # create a build directory - $error = New-BuildDirectory $BuildDirectory - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } - - # patch the version file if it's no release build - if (-not $Release -and $Git_IsGitRepo) - { $error = Invoke-PatchVersionFile $GHDLRootDir $Git_Branch_Name $Git_Commit_DateString $Git_Commit_ShortHash - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } - } - - # build C source files - $error = Invoke-CompileCFiles $GHDLRootDir $BinaryDestinationDirectory - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } - - # build Ada source files - $error = Invoke-CompileGHDLAdaFiles $GHDLRootDir $BinaryDestinationDirectory - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } - - # strip result - $error = Invoke-StripGHDLExecutable $BinaryDestinationDirectory - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } -} - - -# ============================================================================== -# Main Target: GHDL -# ============================================================================== -if ($Test_GHDL) -{ # running ghdl - $error = Test-GHDLVersion $BuildDir - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } -} # Test - -Exit-CompileScript 0 diff --git a/dist/windows/mcode/windows/compile-libraries.ps1 b/dist/windows/mcode/windows/compile-libraries.ps1 deleted file mode 100644 index da2b29c09..000000000 --- a/dist/windows/mcode/windows/compile-libraries.ps1 +++ /dev/null @@ -1,868 +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; -# -# ============================================================================== -# 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 'compile-libraries.ps1 -Help' to see the integrated help page -# -# .EXAMPLE -# C:\PS> .\complib.ps1 -Clean -# .EXAMPLE -# C:\PS> .\complib.ps1 -Compile -Verbose -# .EXAMPLE -# C:\PS> .\complib.ps1 -VHDL2008 -SuppressWarnings -# -[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 = "", - # Undocumented - [switch]$Hosted = $false -) - -# configure script here -$RelPathToRoot = "..\..\.." - -# --------------------------------------------- -# save parameters and working directory -$Script_ScriptDir = $PSScriptRoot -$Script_WorkingDir = Get-Location -$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) - -# set default values -$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"] -$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"] -if ($EnableVerbose -eq $null) { $EnableVerbose = $false } -if ($EnableDebug -eq $null) { $EnableDebug = $false } -if ($EnableDebug -eq $true) { $EnableVerbose = $true } - -# load modules from GHDL's 'libraries' directory -Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosted - -# 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" - - -# 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" - ) -} - -if (-not $Hosted) -{ 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..." -ForegroundColor Yellow - if (Test-Path -Path $VHDLDestinationLibraryDirectory) - { $EnableVerbose -and (Write-Host " rmdir $VHDLDestinationLibraryDirectory") | Out-Null - Remove-Item $VHDLDestinationLibraryDirectory -Force -Recurse -ErrorAction SilentlyContinue - if ($? -eq $false) - { Write-Host "[ERROR]: Cannot remove '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red - Exit-CompileScript -1 - } - } - if (-not ($VHDL87 -or $VHDL93 -or $VHDL2008)) - { Exit-CompileScript } -} - -# 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 -} - - -$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) - { $EnableVerbose -and (Write-Host " Directory '$VHDLDestinationLibraryDirectory' already exists.") | Out-Null - - # change working directory to VHDLDestinationLibraryDirectory - $EnableVerbose -and (Write-Host " cd $VHDLDestinationLibraryDirectory") | Out-Null - Set-Location $VHDLDestinationLibraryDirectory - - $EnableVerbose -and (Write-Host " Cleaning up directory...") | Out-Null - Remove-Item ./* -Force -Recurse -ErrorAction SilentlyContinue - } - else - { $EnableVerbose -and (Write-Host " Creating directory '$VHDLDestinationLibraryDirectory'.") | Out-Null - New-Item -ItemType Directory -Path $VHDLDestinationLibraryDirectory -ErrorAction SilentlyContinue | Out-Null - if (-not $?) - { Write-Host "[ERROR]: Cannot create destination directory '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red - Exit-CompileScript -1 - } - - # change working directory to VHDLDestinationLibraryDirectory - $EnableVerbose -and (Write-Host " Change working directory to $VHDLDestinationLibraryDirectory") | Out-Null - Set-Location $VHDLDestinationLibraryDirectory - } - - Write-Host - Write-Host "Start compilation..." -} -# ============================================================================ -# v87 -# ============================================================================ -if ($VHDL87) -{ $VHDLVersion = "87" - $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" - Write-Host "Compiling libraries for 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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null - 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $ErrorCount += 1 - if ($HaltOnError) - { Exit-CompileScript -1 } - } - } -} -# ============================================================================ -# v93 -# ============================================================================ -if ($VHDL93) -{ $VHDLVersion = "93" - $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" - Write-Host "Compiling libraries for 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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $ErrorCount += 1 - if ($HaltOnError) - { Exit-CompileScript -1 } - } - } -} -# ============================================================================== -# v08 -# ============================================================================== -if ($VHDL2008) -{ $VHDLVersion = "08" - $VersionedDirectory = "$VHDLDestinationLibraryDirectory\v$VHDLVersion" - Write-Host "Compiling libraries for 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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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 VHDL-$VHDLVersion" ) | Out-Null - $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null - $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | 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" -ForegroundColor DarkGray ) | Out-Null - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " - if (($LastExitCode -ne 0) -or -not $?) - { $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/windows/mcode/windows/compile.bat b/dist/windows/mcode/windows/compile.bat deleted file mode 100644 index 0c0e33153..000000000 --- a/dist/windows/mcode/windows/compile.bat +++ /dev/null @@ -1,31 +0,0 @@ -mkdir build -cd build - -rem Do the compilation -set CFLAGS= -O -Wall - -gcc -c %CFLAGS% ../../../src/grt/grt-cbinding.c -if errorlevel 1 goto failed - -gcc -c %CFLAGS% ../../../src/grt/grt-cvpi.c -if errorlevel 1 goto failed - -gcc -c %CFLAGS% ../../../src/grt/config/clock.c -if errorlevel 1 goto failed - -gcc -c %CFLAGS% ../../../src/ortho/mcode/memsegs_c.c -if errorlevel 1 goto failed - -gcc -c %CFLAGS% -DWITH_GNAT_RUN_TIME ../../../src/grt/config/win32.c -if errorlevel 1 goto failed - -gnatmake %CFLAGS% -gnatn -aI../windows -aI../../../src -aI../../../src/ghdldrv -aI../../../src/psl -aI../../../src/grt -aI../../../src/ortho/mcode -aI../../../src/vhdl -aI../../../src/vhdl/translate ghdl_jit -aI../../../src/ortho -o ghdl.exe -largs grt-cbinding.o clock.o grt-cvpi.o memsegs_c.o win32.o -ldbghelp -Wl,--stack,8404992 -if errorlevel 1 goto failed - -cd .. -exit /b 0 - -:failed -echo "Compilation failed" -cd .. -exit /b 1 diff --git a/dist/windows/mcode/windows/complib.bat b/dist/windows/mcode/windows/complib.bat deleted file mode 100644 index bdd062b67..000000000 --- a/dist/windows/mcode/windows/complib.bat +++ /dev/null @@ -1,119 +0,0 @@ -set GHDL=ghdl - -cd build -gnatmake -aI..\windows ghdlfilter -cd .. - -set REL=..\..\.. -set LIBSRC=%REL%\..\..\libraries - -:: -:: library sources -:: -set STD_SRCS= textio textio_body -set IEEE_SRCS= std_logic_1164 std_logic_1164_body numeric_std numeric_std-body numeric_bit numeric_bit-body -set MATH_SRCS= math_real math_real-body math_complex math_complex-body - -set STD08_SRCS= textio textio_body env env_body -set IEEE08_SRCS= 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_bit_context ieee_std_context - -set VITAL95_SRCS= vital_timing vital_timing_body vital_primitives vital_primitives_body -set VITAL2000_SRCS= timing_p timing_b prmtvs_p prmtvs_b memory_p memory_b - -set SYNOPSYS_SRCS= std_logic_arith std_logic_textio std_logic_unsigned std_logic_signed std_logic_misc std_logic_misc-body -set MENTOR_SRCS= std_logic_arith std_logic_arith_body - - -mkdir lib -cd lib - -::::::::::::::::: -echo v87 libraries... - -mkdir v87 -cd v87 - -echo std -mkdir std -cd std -for %%F in (%STD_SRCS%) do %REL%\build\ghdlfilter -v87 < %LIBSRC%\std\%%F.vhdl > %%F.v87 && %REL%\build\%GHDL% -a --std=87 --bootstrap --work=std %%F.v87 -cd .. - -echo ieee -mkdir ieee -cd ieee -for %%F in (%IEEE_SRCS%) do %REL%\build\ghdlfilter -v87 < %LIBSRC%\ieee\%%F.vhdl > %%F.v87 && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.v87 -for %%F in (%VITAL95_SRCS%) do copy %LIBSRC%\vital95\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.vhd -cd .. - -echo synopsys -mkdir synopsys -cd synopsys -for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee ..\ieee\%%F.v87 -for %%F in (%VITAL95_SRCS%) do %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee ..\ieee\%%F.vhd -for %%F in (%SYNOPSYS_SRCS%) do copy %LIBSRC%\synopsys\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.vhd -cd .. - -cd .. - -::::::::::::::::: -echo v93 libraries... - -mkdir v93 -cd v93 - -echo std -mkdir std -cd std -for %%F in (%STD_SRCS%) do %REL%\build\ghdlfilter -v93 < %LIBSRC%\std\%%F.vhdl > %%F.v93 && %REL%\build\%GHDL% -a --std=93 --bootstrap --work=std %%F.v93 -cd .. - -echo ieee -mkdir ieee -cd ieee -for %%F in (%IEEE_SRCS%) do %REL%\build\ghdlfilter -v93 < %LIBSRC%\ieee\%%F.vhdl > %%F.v93 && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.v93 -for %%F in (%VITAL2000_SRCS%) do copy %LIBSRC%\vital2000\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd -for %%F in (%MATH_SRCS%) do copy %LIBSRC%\ieee\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd -cd .. - -echo synopsys -mkdir synopsys -cd synopsys -for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.v93 -for %%F in (%VITAL2000_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd -for %%F in (%MATH_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd -for %%F in (%SYNOPSYS_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\..\v87\synopsys\%%F.vhd -cd .. - -echo mentor -mkdir mentor -cd mentor -for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.v93 -for %%F in (%VITAL2000_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd -for %%F in (%MATH_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd -for %%F in (%MENTOR_SRCS%) do copy %LIBSRC%\mentor\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd -cd .. - -cd .. - -::::::::::::::::: -echo v08 libraries... - -mkdir v08 -cd v08 - -echo std -mkdir std -cd std -for %%F in (%STD08_SRCS%) do %REL%\build\ghdlfilter -v08 < %LIBSRC%\std\%%F.vhdl > %%F.v08 && %REL%\build\%GHDL% -a --std=08 --bootstrap --work=std %%F.v08 -cd .. - -echo ieee -mkdir ieee -cd ieee -for %%F in (%IEEE08_SRCS%) do %REL%\build\ghdlfilter -v08 < %LIBSRC%\ieee2008\%%F.vhdl > %%F.v08 && %REL%\build\%GHDL% -a --std=08 -P..\std --work=ieee %%F.v08 -cd .. - -::::::::::::::::: - -cd ..\.. diff --git a/dist/windows/mcode/windows/default_pathes.ads b/dist/windows/mcode/windows/default_pathes.ads deleted file mode 100644 index 29fe8a3a5..000000000 --- a/dist/windows/mcode/windows/default_pathes.ads +++ /dev/null @@ -1,10 +0,0 @@ -with Windows_Default_Path; -pragma Elaborate_All (Windows_Default_Path); - -package Default_Pathes is - Install_Prefix : constant String := - Windows_Default_Path.Get_Windows_Exec_Path; - Lib_Prefix : constant String := "lib"; - - Shared_Library_Extension : constant String := ".dll"; -end Default_Pathes; diff --git a/dist/windows/mcode/windows/elf_arch.ads b/dist/windows/mcode/windows/elf_arch.ads deleted file mode 100644 index 325c4e5e3..000000000 --- a/dist/windows/mcode/windows/elf_arch.ads +++ /dev/null @@ -1,2 +0,0 @@ -with Elf_Arch32; -package Elf_Arch renames Elf_Arch32; diff --git a/dist/windows/mcode/windows/ghdl.nsi b/dist/windows/mcode/windows/ghdl.nsi deleted file mode 100644 index 5b21aeaa6..000000000 --- a/dist/windows/mcode/windows/ghdl.nsi +++ /dev/null @@ -1,458 +0,0 @@ -; ghdl.nsi -; -; This script is based on example2.nsi. -; remember the directory, -; Check if administrator -; uninstall support -; TODO: -; * allow multiple version -; * command line installation -; * Allow user install - -;-------------------------------- -!include version.nsi -;-------------------------------- - -; The name of the installer -Name "Ghdl" - -; The file to write -OutFile "ghdl-installer-${VERSION}.exe" - -SetDateSave on - -; The default installation directory -InstallDir $PROGRAMFILES\Ghdl - -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM "Software\Ghdl" "Install_Dir" - -LicenseData ..\..\..\COPYING -; LicenseForceSelection - -;-------------------------------- - -; Pages - -Page license -Page components -Page directory -Page instfiles - -UninstPage uninstConfirm -UninstPage instfiles - -;-------------------------------- -Function .onInit - Call IsNT - pop $R0 - StrCmp $R0 1 nt_ok - MessageBox MB_OK|MB_ICONEXCLAMATION "You must use Windows NT (XP/2000/Me...)" - Quit - -nt_ok: - Call IsUserAdmin - Pop $R0 - StrCmp $R0 "true" Admin - MessageBox MB_OK|MB_ICONEXCLAMATION "You must have Admin rights" - Quit - -Admin: - - ;;; Check if already installed. - ReadRegStr $0 HKLM "Software\Ghdl" "Install_Dir" - IfErrors not_installed - ReadRegStr $0 HKLM "Software\Ghdl" "Version" - IfErrors unknown_prev_version - Goto known_version -unknown_prev_version: - StrCpy $0 "(unknown)" -known_version: - MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "You already have GHDL version $0 installed. Deinstall ?" IDCANCEL install_abort IDOK deinstall -install_abort: - Abort "Installation aborted" -deinstall: - ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "UninstallString" - IfErrors deinstall_failed - - ; First version of the GHDL installer adds quotes - StrCpy $1 $0 1 - StrCmp $1 '"' 0 str_ok - StrCpy $1 $0 "" 1 - StrCpy $0 $1 -1 -str_ok: - - ; Read install dir - ReadRegStr $1 HKLM "Software\Ghdl" "Install_Dir" - IfErrors deinstall_failed - -; MessageBox MB_OK 'copy $0 to $TEMP' - - ClearErrors -; MessageBox MB_OK 'copy $0 to $TEMP' - CopyFiles $0 $TEMP - IfErrors deinstall_failed - ExecWait '"$TEMP\uninst-ghdl.exe" /S _?=$1' - IfErrors deinstall_failed - Delete "$TEMP\uninst-ghdl.exe" - Return -deinstall_failed: - Delete $TEMP\uninst-ghdl.exe - MessageBox MB_YESNO|MB_ICONSTOP "Can't deinstall GHDL: de-installer not found or failed. Continue installation ?" IDNO install_abort -not_installed: - Return -FunctionEnd - -;-------------------------------- - -; The stuff to install -Section "Ghdl Compiler (required)" - - SectionIn RO - - ; Set output path to the installation directory. - SetOutPath $INSTDIR\bin - File /oname=ghdl.exe ..\build\ghdl.exe - - SetOutPath $INSTDIR - File /oname=COPYING.txt ..\..\..\COPYING - - ; Write the installation path into the registry - WriteRegStr HKLM "Software\Ghdl" "Install_Dir" $INSTDIR - ; Write te version - WriteRegStr HKLM "Software\Ghdl" "Version" ${VERSION} - - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "DisplayName" "Ghdl" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "UninstallString" $INSTDIR\uninst-ghdl.exe - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "NoRepair" 1 - WriteUninstaller $INSTDIR\uninst-ghdl.exe" - -SectionEnd - -Section "VHDL standard and ieee libraries" - SectionIn RO - SetOutPath $INSTDIR\lib\v87 - File /r ..\lib\v87\std ..\lib\v87\ieee - SetOutPath $INSTDIR\lib\v93 - File /r ..\lib\v93\std ..\lib\v93\ieee - SetOutPath $INSTDIR\lib\v08 - File /r ..\lib\v08\std ..\lib\v08\ieee -SectionEnd - -Section "Synopsys libraries (Recommended)" - SetOutPath $INSTDIR\lib\v87 - File /r ..\lib\v87\synopsys - SetOutPath $INSTDIR\lib\v93 - File /r ..\lib\v93\synopsys -SectionEnd - -Section "Documentation (Recommended)" - SetOutPath $INSTDIR - File /oname=ghdl.htm ..\..\..\doc\ghdl.html -SectionEnd - -Section "Add in PATH (Recommended)" - WriteRegDWORD HKLM "Software\Ghdl" "PathSet" 1 - Push $INSTDIR\Bin - Call AddToPath -SectionEnd - -; Optional section (can be disabled by the user) -;Section "Start Menu Shortcuts" -; -; CreateDirectory "$SMPROGRAMS\Ghdl" -; CreateShortCut "$SMPROGRAMS\Ghdl\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 -; CreateShortCut "$SMPROGRAMS\Ghdl\Ghdl.lnk" "$INSTDIR\example2.nsi" "" "$INSTDIR\example2.nsi" 0 -; -;SectionEnd -; - -;-------------------------------- - -; Uninstaller - -Section "Uninstall" - - ReadRegDWORD $0 HKLM "Software\Ghdl" "PathSet" - StrCmp $0 "1" "" path_not_set - Push $INSTDIR\Bin - Call un.RemoveFromPath - -path_not_set: - - ; Remove registry keys - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" - DeleteRegKey HKLM Software\Ghdl - - ; Remove files and uninstaller - Delete $INSTDIR\bin\ghdl.exe - Delete $INSTDIR\bin\ghdl.htm - Delete $INSTDIR\uninst-ghdl.exe - Delete $INSTDIR\COPYING.txt - RMDir $INSTDIR\bin - RMDir /r $INSTDIR\lib - - - ; Remove shortcuts, if any - ; Delete "$SMPROGRAMS\Ghdl\*.*" - - ; Remove directories used - ; RMDir "$SMPROGRAMS\Ghdl" - RMDir "$INSTDIR" - -SectionEnd - -;;;;;;;; Misc functions - -; Author: Lilla (lilla@earthlink.net) 2003-06-13 -; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll -; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi -; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing). -; -; Usage: -; Call IsUserAdmin -; Pop $R0 ; at this point $R0 is "true" or "false" -; -Function IsUserAdmin -Push $R0 -Push $R1 -Push $R2 - -ClearErrors -UserInfo::GetName -IfErrors Win9x -Pop $R1 -UserInfo::GetAccountType -Pop $R2 - -StrCmp $R2 "Admin" 0 Continue -; Observation: I get here when running Win98SE. (Lilla) -; The functions UserInfo.dll looks for are there on Win98 too, -; but just don't work. So UserInfo.dll, knowing that admin isn't required -; on Win98, returns admin anyway. (per kichik) -; MessageBox MB_OK 'User "$R1" is in the Administrators group' -StrCpy $R0 "true" -Goto Done - -Continue: -; You should still check for an empty string because the functions -; UserInfo.dll looks for may not be present on Windows 95. (per kichik) -StrCmp $R2 "" Win9x -StrCpy $R0 "false" -;MessageBox MB_OK 'User "$R1" is in the "$R2" group' -Goto Done - -Win9x: -; comment/message below is by UserInfo.nsi author: -; This one means you don't need to care about admin or -; not admin because Windows 9x doesn't either -;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" -StrCpy $R0 "true" - -Done: -;MessageBox MB_OK 'User= "$R1" AccountType= "$R2" IsUserAdmin= "$R0"' - -Pop $R2 -Pop $R1 -Exch $R0 -FunctionEnd - - -!define ALL_USERS - -!ifndef WriteEnvStr_RegKey - !ifdef ALL_USERS - !define WriteEnvStr_RegKey \ - 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' - !else - !define WriteEnvStr_RegKey 'HKCU "Environment"' - !endif -!endif - -!verbose 3 -!include "WinMessages.NSH" -!verbose 4 - -; AddToPath - Adds the given dir to the search path. -; Input - head of the stack -; Note - Win9x systems requires reboot - -Function AddToPath - Exch $0 - Push $1 - Push $2 - Push $3 - - # don't add if the path doesn't exist - IfFileExists "$0\*.*" "" AddToPath_done - - ReadEnvStr $1 PATH - Push "$1;" - Push "$0;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - Push "$1;" - Push "$0\;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - GetFullPathName /SHORT $3 $0 - Push "$1;" - Push "$3;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - Push "$1;" - Push "$3\;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - - ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" - StrCpy $2 $1 1 -1 # copy last char - StrCmp $2 ";" 0 +2 # if last char == ; - StrCpy $1 $1 -1 # remove last char - StrCmp $1 "" AddToPath_NTdoIt - StrCpy $0 "$1;$0" - AddToPath_NTdoIt: - WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - AddToPath_done: - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - -; RemoveFromPath - Remove a given dir from the path -; Input: head of the stack - -Function un.RemoveFromPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - Push $5 - Push $6 - - IntFmt $6 "%c" 26 # DOS EOF - - ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" - StrCpy $5 $1 1 -1 # copy last char - StrCmp $5 ";" +2 # if last char != ; - StrCpy $1 "$1;" # append ; - Push $1 - Push "$0;" - Call un.StrStr ; Find `$0;` in $1 - Pop $2 ; pos of our dir - StrCmp $2 "" unRemoveFromPath_done - ; else, it is in path - # $0 - path to add - # $1 - path var - StrLen $3 "$0;" - StrLen $4 $2 - StrCpy $5 $1 -$4 # $5 is now the part before the path to remove - StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove - StrCpy $3 $5$6 - - StrCpy $5 $3 1 -1 # copy last char - StrCmp $5 ";" 0 +2 # if last char == ; - StrCpy $3 $3 -1 # remove last char - - WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - unRemoveFromPath_done: - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - -########################################### -# Utility Functions # -########################################### - -; IsNT -; no input -; output, top of the stack = 1 if NT or 0 if not -; -; Usage: -; Call IsNT -; Pop $R0 -; ($R0 at this point is 1 or 0) - -!macro IsNT un -Function ${un}IsNT - Push $0 - ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion - StrCmp $0 "" 0 IsNT_yes - ; we are not NT. - Pop $0 - Push 0 - Return - - IsNT_yes: - ; NT!!! - Pop $0 - Push 1 -FunctionEnd -!macroend -!insertmacro IsNT "" -;!insertmacro IsNT "un." - -; StrStr -; input, top of stack = string to search for -; top of stack-1 = string to search in -; output, top of stack (replaces with the portion of the string remaining) -; modifies no other variables. -; -; Usage: -; Push "this is a long ass string" -; Push "ass" -; Call StrStr -; Pop $R0 -; ($R0 at this point is "ass string") - -!macro StrStr un -Function ${un}StrStr -Exch $R1 ; st=haystack,old$R1, $R1=needle - Exch ; st=old$R1,haystack - Exch $R2 ; st=old$R1,old$R2, $R2=haystack - Push $R3 - Push $R4 - Push $R5 - StrLen $R3 $R1 - StrCpy $R4 0 - ; $R1=needle - ; $R2=haystack - ; $R3=len(needle) - ; $R4=cnt - ; $R5=tmp - loop: - StrCpy $R5 $R2 $R3 $R4 - StrCmp $R5 $R1 done - StrCmp $R5 "" done - IntOp $R4 $R4 + 1 - Goto loop -done: - StrCpy $R1 $R2 "" $R4 - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Exch $R1 -FunctionEnd -!macroend -!insertmacro StrStr "" -!insertmacro StrStr "un." - diff --git a/dist/windows/mcode/windows/ghdlfilter.adb b/dist/windows/mcode/windows/ghdlfilter.adb deleted file mode 100644 index d75526dbd..000000000 --- a/dist/windows/mcode/windows/ghdlfilter.adb +++ /dev/null @@ -1,132 +0,0 @@ --- --- Preprocessor to handle library source metacomments --- --- Limitations: --- - line metacomments must occur at end of line with no trailing space before the line break --- - block metacomments must start in column 1 --- --- Supported line metacomments: --- --- --!V87 --- --V87 --- --V93 --- --V08 --- --- Supported block metacomments: --- --- --START-!V87 --- --END-!V87 --- --- --START-V93 --- --END-V93 --- --- --START-V08 --- --END-V08 --- --- -with Ada.Command_Line; use Ada.Command_Line; -with Ada.Text_IO; use Ada.Text_IO; - -procedure Ghdlfilter is - type Mode_Kind is (Mode_93, Mode_87, Mode_08); - Mode : Mode_Kind; - - Line : String (1 .. 128); - Len : Natural; - - Comment : Boolean; - Block_Comment : Boolean; -begin - if Argument_Count /= 1 then - Put_Line (Standard_Error, "usage: " & Command_Name & " -v93|-v87|-v08"); - return; - end if; - - if Argument (1) = "-v93" then - Mode := Mode_93; - elsif Argument (1) = "-v87" then - Mode := Mode_87; - elsif Argument (1) = "-v08" then - Mode := Mode_08; - else - Put_Line (Standard_Error, "bad mode"); - return; - end if; - - Block_Comment := False; - - loop - exit when End_Of_File; - Get_Line (Line, Len); - - Comment := Block_Comment; - - -- - -- look for line metacomments - -- - if Len > 6 then - - if Mode = Mode_87 and ( Line (Len - 5 .. Len) = "--!V87" ) then - Comment := True; - end if; - - end if; - - - if Len > 5 then - - if Mode = Mode_87 and ( (Line (Len - 4 .. Len) = "--V93") or (Line (Len - 4 .. Len) = "--V08") ) then - Comment := True; - - elsif Mode = Mode_93 and ( (Line (Len - 4 .. Len) = "--V87") or (Line (Len - 4 .. Len) = "--V08") ) then - Comment := True; - - elsif Mode = Mode_08 and ( (Line (Len - 4 .. Len) = "--V87") or (Line (Len - 4 .. Len) = "--V93") ) then - Comment := True; - end if; - - end if; - - -- - -- look for block metacomment start - -- - if Len = 12 - and then Mode /= Mode_93 - and then Line (1 .. 12) = "--START-!V87" then - Block_Comment := True; - end if; - - if Len = 11 - and then Mode /= Mode_93 - and then Line (1 .. 11) = "--START-V93" then - Block_Comment := True; - end if; - - if Len = 11 - and then Mode /= Mode_08 - and then Line (1 .. 11) = "--START-V08" then - Block_Comment := True; - end if; - - -- - -- look for block metacomment end - -- - if Len = 9 and then ( (Line (1 .. 9) = "--END-V93") or (Line (1 .. 9) = "--END-V08") ) then - Block_Comment := False; - end if; - - if Len = 10 and then ( Line (1 .. 10) = "--END-!V87" ) then - Block_Comment := False; - end if; - - -- - -- comment output lines as needed - -- - if Comment then - Put ("-- "); - end if; - - Put_Line (Line (1 .. Len)); - - end loop; -end Ghdlfilter; diff --git a/dist/windows/mcode/windows/ghdlversion.adb b/dist/windows/mcode/windows/ghdlversion.adb deleted file mode 100755 index d2f1c28be..000000000 --- a/dist/windows/mcode/windows/ghdlversion.adb +++ /dev/null @@ -1,30 +0,0 @@ -with Ada.Text_IO; use Ada.Text_IO; -with Ada.Strings.Fixed; use Ada.Strings.Fixed; - -procedure Ghdlversion is - Line : String (1 .. 128); - Len : Natural; - Pos : Natural; - E : Natural; -begin - loop - exit when End_Of_File; - Get_Line (Line, Len); - - -- Search GHDL - Pos := Index (Line (1 .. Len), "GHDL "); - if Pos /= 0 then - Pos := Pos + 5; - E := Pos; - while Line (E) in '0' .. '9' - or Line (E) in 'a' .. 'z' - or Line (E) = '.' - loop - exit when E = Len; - E := E + 1; - end loop; - Put_Line ("!define VERSION """ & Line (Pos .. E - 1) & """"); - return; - end if; - end loop; -end Ghdlversion; diff --git a/dist/windows/mcode/windows/grt-backtraces-impl.ads b/dist/windows/mcode/windows/grt-backtraces-impl.ads deleted file mode 100644 index 81db677ed..000000000 --- a/dist/windows/mcode/windows/grt-backtraces-impl.ads +++ /dev/null @@ -1,3 +0,0 @@ -with Grt.Backtraces.Jit; - -package Grt.Backtraces.Impl renames Grt.Backtraces.Jit; diff --git a/dist/windows/mcode/windows/grt-modules.adb b/dist/windows/mcode/windows/grt-modules.adb deleted file mode 100644 index de5eb79b8..000000000 --- a/dist/windows/mcode/windows/grt-modules.adb +++ /dev/null @@ -1,39 +0,0 @@ --- GHDL Run Time (GRT) - Modules. --- Copyright (C) 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 GCC; see the file COPYING. If not, write to the Free --- Software Foundation, 59 Temple Place - Suite 330, Boston, MA --- 02111-1307, USA. -with System.Storage_Elements; -- Work around GNAT bug. -with Grt.Vcd; -with Grt.Vpi; -with Grt.Waves; -with Grt.Vital_Annotate; -with Grt.Disp_Tree; -with Grt.Disp_Rti; -with Grt.Backtraces; - -package body Grt.Modules is - procedure Register_Modules is - begin - -- List of modules to be registered. - Grt.Disp_Tree.Register; - Grt.Vcd.Register; - Grt.Waves.Register; - Grt.Vpi.Register; - Grt.Vital_Annotate.Register; - Grt.Disp_Rti.Register; - Grt.Backtraces.Register; - end Register_Modules; -end Grt.Modules; diff --git a/dist/windows/mcode/windows/ortho_code-x86-flags.ads b/dist/windows/mcode/windows/ortho_code-x86-flags.ads deleted file mode 100644 index 8915f3122..000000000 --- a/dist/windows/mcode/windows/ortho_code-x86-flags.ads +++ /dev/null @@ -1,2 +0,0 @@ -with Ortho_Code.X86.Flags_Windows; -package Ortho_Code.X86.Flags renames Ortho_Code.X86.Flags_Windows; diff --git a/dist/windows/mcode/windows/shared.psm1 b/dist/windows/mcode/windows/shared.psm1 deleted file mode 100644 index 20aa5d7da..000000000 --- a/dist/windows/mcode/windows/shared.psm1 +++ /dev/null @@ -1,370 +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; -# -# ============================================================================== -# Authors: Patrick Lehmann -# -# PowerShell Module: The module provides common CmdLets for ... -# -# Description: -# ------------------------------------ -# This PowerShell module provides CommandLets (CmdLets) to ... -# -# ============================================================================== -# Copyright (C) 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. -# ============================================================================== - -[CmdletBinding()] -param( - [Parameter(Mandatory=$true)][string]$WorkingDir, - [Parameter(Mandatory=$true)][Switch]$Hosted -) - -$Module_WorkingDir = $WorkingDir -$Module_Hosted = $Hosted - -function Exit-CompileScript -{ <# - .SYNOPSIS - Undocumented - .DESCRIPTION - Undocumented - .PARAMETER ExitCode - ExitCode of this script run - #> - [CmdletBinding()] - param( - [int]$ExitCode = 0 - ) - cd $Module_WorkingDir - # unload modules - if (-not $Module_Hosted) - { Remove-Module shared -Verbose:$false -Debug:$false - Remove-Module targets -Verbose:$false -Debug:$false - } - 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 = 0 - $VersionAsInt = 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 = -1 } - } - elseif ($Line.StartsWith("--END-V") -or $Line.StartsWith("--END-!V")) - { $State = 0 } - else - { if ($State -eq 0) - { if ($Line.EndsWith("--V$Version")) - { Write-Output $Line } - elseif (-not (($Line -like "*--V??") -or ($Line.EndsWith("--!V$Version")))) - { Write-Output $Line } - } - elseif ($State -eq $VersionAsInt) - { Write-Output $Line } - # else - # { Write-Host "Discard line: $Line" -ForegroundColor Red } - } - } - else - { Write-Host "Unknown pipeline object type." -ForegroundColor Red } - } - - end - { - } -} - -function Restore-NativeCommandStream -{ <# - .SYNOPSIS - This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs - as a single line. - - .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( - [Parameter(ValueFromPipeline=$true)] - $InputObject - ) - - begin - { $LineRemainer = "" } - - process - { if ($InputObject -is [System.Management.Automation.ErrorRecord]) - { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") - { Write-Output $InputObject.ToString() } - elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") - { $NewLine = $LineRemainer + $InputObject.ToString() - while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1) - { Write-Output $NewLine.Substring(0, $NewLinePos) - $NewLine = $NewLine.Substring($NewLinePos + 1) - } - $LineRemainer = $NewLine - } - } - elseif ($InputObject -is [String]) - { Write-Output $InputObject } - else - { Write-Host "Unsupported object in pipeline stream" } - } - - end - { if ($LineRemainer -ne "") - { Write-Output $LineRemainer } - } -} - -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 - 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.) - #> - [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+:warning:\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-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 - Returns true, if the current working directy is under git control. - #> - - git rev-parse 2>&1 | Out-Null - return $LastExitCode -eq 0 -} - -# 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/windows/mcode/windows/targets.psm1 b/dist/windows/mcode/windows/targets.psm1 deleted file mode 100644 index 813873482..000000000 --- a/dist/windows/mcode/windows/targets.psm1 +++ /dev/null @@ -1,411 +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; -# -# ============================================================================== -# Authors: Patrick Lehmann -# -# PowerShell Module: The module provides build targets for GHDL. -# -# Description: -# ------------------------------------ -# This PowerShell module provides build targets for GHDL. -# -# ============================================================================== -# Copyright (C) 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. -# ============================================================================== - -# TODO: -# check if: -# - program are installed / auto find programs / auto find paths -# - program version - -# configure compiler tools -$Prog_GCC = "gcc.exe" -$Prog_GNATMake = "gnatmake.exe" -$Prog_Strip = "strip.exe" - -# configure output file -$GHDL_Mcode_Name = "ghdl.exe" - -# configure directory structure -$CommonSourceDirName = "src" -$WinMcodeSourceDirName = "dist\mcode\windows" -# $WinLLVMSourceDirName = "dist\llvm\windows" - -# construct file paths -$VersionFileName_In = "version.in" -$VersionFileName_Ads = "version.ads" - - -function Invoke-Clean -{ <# - .SYNOPSIS - This CommandLet removes all generated files. - .PARAMETER BuildDirectory - The directory where all generated files are stored. - .PARAMETER Quiet - Disable outputs to the host console. - #> - [CmdletBinding()] - param( - [string] $BuildDirectory, - [switch] $Quiet = $false - ) - - $EnableDebug = -not $Quiet -and ( $PSCmdlet.MyInvocation.BoundParameters["Debug"]) - $EnableVerbose = -not $Quiet -and ($EnableDebug -or $PSCmdlet.MyInvocation.BoundParameters["Verbose"]) - - -not $Quiet -and (Write-Host "Executing build target 'Clean' ..." -ForegroundColor Yellow) | Out-Null - $EnableVerbose -and (Write-Host " Removing all created files and directories..." ) | Out-Null - if (Test-Path -Path $BuildDirectory) - { $EnableDebug -and (Write-Host " rmdir $BuildDirectory" ) | Out-Null - Remove-Item $BuildDirectory -Force -Recurse -ErrorAction SilentlyContinue - if ($? -eq $false) - { Write-Host "[ERROR]: Cannot remove '$BuildDirectory'." -ForegroundColor Red - return $true - } - } - return $false -} # Invoke-Clean - -function New-BuildDirectory -{ <# - .SYNOPSIS - This CommandLet creates a build directory if not existent, yet. - .PARAMETER BuildDirectory - The directory where all generated files are stored. - .PARAMETER Quiet - Disable outputs to the host console. - #> - [CmdletBinding()] - param( - [string] $BuildDirectory, - [switch] $Quiet = $false - ) - - Write-Host "Executing build target 'BuildDirectory' ..." -ForegroundColor Yellow - if (Test-Path -Path $BuildDirectory -PathType Container) - { -not $Quiet -and (Write-Host " Directory '$BuildDirectory' already exists." ) | Out-Null } - else - { -not $Quiet -and (Write-Host " Creating new directory '$BuildDirectory'." ) | Out-Null - New-Item -ItemType Directory -Path $BuildDirectory -ErrorAction SilentlyContinue | Out-Null - if ($? -eq $false) - { Write-Host "[ERROR]: Cannot create '$BuildDirectory'." -ForegroundColor Red - return $true - } - } - - return $false -} # New-BuildDirectory - -function Get-GHDLVersion -{ <# - .SYNOPSIS - Returns the GHDL version string. - .PARAMETER GHDLRootDir - The repository root directory. - #> - [CmdletBinding()] - param( - [string] $GHDLRootDir - ) - # construct DirectoryPaths - $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - $VersionFilePath = $SourceDirectory + "\" + $VersionFileName_In - - if (-not (Test-Path -Path $VersionFilePath -PathType Leaf)) - { Write-Host "[ERROR]: Version file '$VersionFilePath' does not exists." -ForegroundColor Red - return $true - } - $FileContent = Get-Content -Path $VersionFilePath - foreach ($Line in $FileContent) - { if ($Line -match 'Ghdl_Ver(.+?)\"(.+?)\";') - { return $Matches[2] } - } - Write-Host "[ERROR]: RegExp didn't match in '$VersionFilePath'." -ForegroundColor Red - return $true -} # Get-GHDLVersion - -function Invoke-PatchVersionFile -{ <# - .SYNOPSIS - This CommandLet patches the version file to include the git patch state. - .PARAMETER GHDLRootDir - The repository root directory. - .PARAMETER GitBranchName - The branch's name, where HEAD is located. - .PARAMETER GitCommitDataString - The DateTime when HEAD was commited. - .PARAMETER GitCommitHash - The Hash of HEAD. - .PARAMETER Quiet - Disable outputs to the host console. - #> - [CmdletBinding()] - param( - [string] $GHDLRootDir, - [string] $GitBranchName = "unknown", - [string] $GitCommitDataString = "unknown", - [string] $GitCommitHash = "........", - [switch] $Quiet = $false - ) - # construct DirectoryPaths - $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - $VersionInputFilePath = $SourceDirectory + "\" + $VersionFileName_In - $VersionFilePath = $SourceDirectory + "\" + $VersionFileName_Ads - - Write-Host "Executing build target 'PatchVersionFile' ..." -ForegroundColor Yellow - - if (-not (Test-Path -Path $VersionInputFilePath -PathType Leaf)) - { Write-Host "[ERROR]: Version file '$VersionInputFilePath' does not exists." -ForegroundColor Red - return $true - } - -not $Quiet -and (Write-Host " Patching '$VersionInputFilePath'.") | Out-Null - $FileContent = Get-Content -Path $VersionInputFilePath -Encoding Ascii - if ($? -eq $false) - { Write-Host "[ERROR]: While opening '$VersionInputFilePath'." -ForegroundColor Red - return $true - } - $FileContent = $FileContent -Replace "\s\(tarball\)\s", " (commit: $GitCommitDataString; git branch: $GitBranchName'; hash: $GitCommitHash) " - - $FileContent | Out-File $VersionFilePath -Encoding Ascii - if ($? -eq $false) - { Write-Host "[ERROR]: While writing to '$VersionFilePath'." -ForegroundColor Red - return $true - } - - return $false -} # Invoke-PatchVersionFile - - -function Get-CFlags -{ <# - .SYNOPSIS - Returns common ANSI C compiler flags for GCC. - #> - return @( - "-O1", # optimize; level 1 - "-g" # enable debug symbols - ) -} - -function Invoke-CompileCFiles -{ <# - .SYNOPSIS - This CommandLet compiles all C files with GCC. - .PARAMETER GHDLRootDir - The repository root directory. - .PARAMETER BuildDirectory - The directory where all generated files are stored. - .PARAMETER Quiet - Disable outputs to the host console - #> - [CmdletBinding()] - param( - [string] $GHDLRootDir, - [string] $BuildDirectory, - [switch] $Quiet = $false - ) - # construct DirectoryPaths - $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - - Set-Location $BuildDirectory - Write-Host "Executing build target 'CompileCFiles' ..." -ForegroundColor Yellow - - # list all files to be compiled; add additional CFlags if needed - $SourceFiles = @() - $SourceFiles += New-Object PSObject -Property @{File="grt\grt-cbinding.c"; CFlags=@()} - $SourceFiles += New-Object PSObject -Property @{File="grt\grt-cvpi.c"; CFlags=@()} - $SourceFiles += New-Object PSObject -Property @{File="grt\config\clock.c"; CFlags=@()} - $SourceFiles += New-Object PSObject -Property @{File="grt\config\win32.c"; CFlags=@('-DWITH_GNAT_RUN_TIME')} - $SourceFiles += New-Object PSObject -Property @{File="ortho\mcode\memsegs_c.c"; CFlags=@()} - - # compile C files - foreach ($SourceFile in $SourceFiles) - { $Parameters = @() - $Parameters += "-c" # compile only - $Parameters += Get-CFlags # append common CFlags - $Parameters += $SourceFile.CFlags - $Parameters += $SourceDirectory + "\" + $SourceFile.File - - # call C compiler - $InvokeExpr = "$Prog_GCC " + ($Parameters -join " ") + " 2>&1" - - Write-Host (" compiling: " + $SourceFile.File) - Write-Debug " call: $InvokeExpr" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " - if ($LastExitCode -ne 0) - { Write-Host ("[ERROR]: While compiling '{0}'." -f $SourceFile.File) -ForegroundColor Red - return $true - } - } - - return $false -} # Invoke-CompileCFiles - - -function Invoke-CompileGHDLAdaFiles -{ <# - .SYNOPSIS - This CommandLet compiles all Ada files with GNAT. - .PARAMETER GHDLRootDir - The repository root directory. - .PARAMETER BuildDirectory - The directory where all generated files are stored. - .PARAMETER Quiet - Disable outputs to the host console - #> - [CmdletBinding()] - param( - [string] $GHDLRootDir, - [string] $BuildDirectory, - [switch] $Quiet = $false - ) - # construct DirectoryPaths - $CommonSourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - $WinMcodeSourceDirectory = $GHDLRootDir + "\" + $WinMcodeSourceDirName - - Set-Location $BuildDirectory - Write-Host "Executing build target 'CompileGHDLAdaFiles' ..." -ForegroundColor Yellow - - $Parameters = @() - $Parameters += Get-CFlags # append common CFlags - $Parameters += '-gnatn' - - # append all source paths - $Parameters += '-aI' + $WinMcodeSourceDirectory - $Parameters += '-aI' + $CommonSourceDirectory - $Parameters += '-aI' + $CommonSourceDirectory + '\ghdldrv' - $Parameters += '-aI' + $CommonSourceDirectory + '\psl' - $Parameters += '-aI' + $CommonSourceDirectory + '\grt' - $Parameters += '-aI' + $CommonSourceDirectory + '\ortho' - $Parameters += '-aI' + $CommonSourceDirectory + '\ortho\mcode' - $Parameters += '-aI' + $CommonSourceDirectory + '\vhdl' - $Parameters += '-aI' + $CommonSourceDirectory + '\vhdl\translate' - - # top level - $Parameters += 'ghdl_jit' - - # add output filename - $Parameters += '-o' - $Parameters += $GHDL_Mcode_Name - - # append linker parameters - $Parameters += '-largs' - $Parameters += 'grt-cbinding.o' - $Parameters += 'clock.o' - $Parameters += 'grt-cvpi.o' - $Parameters += 'memsegs_c.o' - $Parameters += 'win32.o' - $Parameters += '-ldbghelp' - $Parameters += '-largs' - # $Parameters += '-Wl,--stack,8404992' - - # call Ada compiler (GNAT) - $InvokeExpr = "$Prog_GNATMake " + ($Parameters -join " ") + " 2>&1" - - Write-Host " compiling with GNAT" - Write-Debug " call: $InvokeExpr" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " - if ($LastExitCode -ne 0) - { Write-Host "[ERROR]: While compiling '$GHDL_Mcode_Name'." -ForegroundColor Red - return $true - } - return $false -} # Invoke-CompileGHDLAdaFiles - - -function Invoke-StripGHDLExecutable -{ <# - .SYNOPSIS - This CommandLet strips the result files. - .PARAMETER BuildDirectory - The directory where all generated files are stored. - .PARAMETER Quiet - Disable outputs to the host console - #> - [CmdletBinding()] - param( - [string] $BuildDirectory, - [switch] $Quiet = $false - ) - - Set-Location $BuildDirectory - Write-Host "Executing build target 'StripGHDLExecutable' ..." -ForegroundColor Yellow - - # call striping tool (strip) - Write-Host " stripping '$GHDL_Mcode_Name'" - Write-Debug " call: $Prog_Strip $GHDL_Mcode_Name" - & $Prog_Strip $GHDL_Mcode_Name - if ($LastExitCode -ne 0) - { Write-Host "[ERROR]: While stripping '$GHDL_Mcode_Name'." -ForegroundColor Red - return $true - } - return $false -} # Invoke-StripGHDLExecutable - -function Test-GHDLVersion -{ <# - .SYNOPSIS - This CommandLet executes ghdl to read the version information - .PARAMETER BuildDirectory - The directory where all generated files are stored. - .PARAMETER Quiet - Disable outputs to the host console - #> - [CmdletBinding()] - param( - [string] $BuildDirectory, - [switch] $Quiet = $false - ) - - Set-Location $BuildDirectory - Write-Host "Executing build target 'GHDLVersion' ..." -ForegroundColor Yellow - - if (-not (Test-Path -Path $GHDL_Mcode_Name -PathType Leaf)) - { Write-Host " GHDL executable '$GHDL_Mcode_Name' does not exists." -ForegroundColor Red - return $true - } - - # call ghdl - $InvokeExpr = "$GHDL_Mcode_Name --version 2>&1" - - Write-Host " executing '$GHDL_Mcode_Name'" - Write-Host " call: $InvokeExpr" - Write-Host " ----------------------------------------" - Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-HostExtended " " - Write-Host " ----------------------------------------" - if ($LastExitCode -ne 0) - { Write-Host "[ERROR]: While executing '$GHDL_Mcode_Name'." -ForegroundColor Red - return $true - } - return $false -} # Test-GHDLVersion - - -# export functions -Export-ModuleMember -Function 'Get-GHDLVersion' -Export-ModuleMember -Function 'Invoke-Clean' -Export-ModuleMember -Function 'New-BuildDirectory' -Export-ModuleMember -Function 'Invoke-PatchVersionFile' -Export-ModuleMember -Function 'Restore-PatchedVersionFile' -Export-ModuleMember -Function 'Invoke-CompileCFiles' -Export-ModuleMember -Function 'Invoke-CompileGHDLAdaFiles' -Export-ModuleMember -Function 'Invoke-StripGHDLExecutable' -Export-ModuleMember -Function 'Test-GHDLVersion' diff --git a/dist/windows/mcode/windows/windows_default_path.adb b/dist/windows/mcode/windows/windows_default_path.adb deleted file mode 100644 index c627356f9..000000000 --- a/dist/windows/mcode/windows/windows_default_path.adb +++ /dev/null @@ -1,68 +0,0 @@ --- Find installation path (using executable). --- Copyright (C) 2002 - 2016 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 GCC; see the file COPYING. If not, write to the Free --- Software Foundation, 59 Temple Place - Suite 330, Boston, MA --- 02111-1307, USA. --- --- As a special exception, if other files instantiate generics from this --- unit, or you link this unit with other files to produce an executable, --- this unit does not by itself cause the resulting executable to be --- covered by the GNU General Public License. This exception does not --- however invalidate any other reasons why the executable file might be --- covered by the GNU Public License. - -with Interfaces.C; use Interfaces.C; -with System; use System; - -package body Windows_Default_Path is - - subtype DWORD is Interfaces.C.Unsigned_Long; - subtype HINSTANCE is Address; - function GetModuleFileName (Inst : HINSTANCE; Buf : Address; Size : DWORD) - return DWORD; - pragma Import (Stdcall, GetModuleFileName, "GetModuleFileNameA"); - - function Get_Windows_Exec_Path return String - is - File : String (1 .. 256); - Size : DWORD; - P : Natural; - begin - -- Get exe file path. - Size := GetModuleFileName (Null_Address, File'Address, File'Length); - if Size = 0 or Size = File'Length then - return "{cannot find install path}\lib"; - end if; - - -- Remove Program file. - P := Natural (Size); - while P > 0 loop - exit when File (P) = '\'; - exit when File (P) = ':' and P = 2; - P := P - 1; - end loop; - if File (P) = '\' and P > 1 then - -- Remove directory - P := P - 1; - while P > 0 loop - exit when File (P) = '\'; - exit when File (P) = ':' and P = 2; - P := P - 1; - end loop; - end if; - - return File (1 .. P); - end Get_Windows_Exec_Path; -end Windows_Default_Path; diff --git a/dist/windows/mcode/windows/windows_default_path.ads b/dist/windows/mcode/windows/windows_default_path.ads deleted file mode 100644 index 9da3be559..000000000 --- a/dist/windows/mcode/windows/windows_default_path.ads +++ /dev/null @@ -1,30 +0,0 @@ --- Find installation path (using executable). --- Copyright (C) 2002 - 2016 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 GCC; see the file COPYING. If not, write to the Free --- Software Foundation, 59 Temple Place - Suite 330, Boston, MA --- 02111-1307, USA. --- --- As a special exception, if other files instantiate generics from this --- unit, or you link this unit with other files to produce an executable, --- this unit does not by itself cause the resulting executable to be --- covered by the GNU General Public License. This exception does not --- however invalidate any other reasons why the executable file might be --- covered by the GNU Public License. - -package Windows_Default_Path is - -- Get the default path from executable name. - -- This function is called during elaboration! - function Get_Windows_Exec_Path return String; -end Windows_Default_Path; diff --git a/dist/windows/mcode/windows_default_path.adb b/dist/windows/mcode/windows_default_path.adb new file mode 100644 index 000000000..c627356f9 --- /dev/null +++ b/dist/windows/mcode/windows_default_path.adb @@ -0,0 +1,68 @@ +-- Find installation path (using executable). +-- Copyright (C) 2002 - 2016 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 GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +-- +-- As a special exception, if other files instantiate generics from this +-- unit, or you link this unit with other files to produce an executable, +-- this unit does not by itself cause the resulting executable to be +-- covered by the GNU General Public License. This exception does not +-- however invalidate any other reasons why the executable file might be +-- covered by the GNU Public License. + +with Interfaces.C; use Interfaces.C; +with System; use System; + +package body Windows_Default_Path is + + subtype DWORD is Interfaces.C.Unsigned_Long; + subtype HINSTANCE is Address; + function GetModuleFileName (Inst : HINSTANCE; Buf : Address; Size : DWORD) + return DWORD; + pragma Import (Stdcall, GetModuleFileName, "GetModuleFileNameA"); + + function Get_Windows_Exec_Path return String + is + File : String (1 .. 256); + Size : DWORD; + P : Natural; + begin + -- Get exe file path. + Size := GetModuleFileName (Null_Address, File'Address, File'Length); + if Size = 0 or Size = File'Length then + return "{cannot find install path}\lib"; + end if; + + -- Remove Program file. + P := Natural (Size); + while P > 0 loop + exit when File (P) = '\'; + exit when File (P) = ':' and P = 2; + P := P - 1; + end loop; + if File (P) = '\' and P > 1 then + -- Remove directory + P := P - 1; + while P > 0 loop + exit when File (P) = '\'; + exit when File (P) = ':' and P = 2; + P := P - 1; + end loop; + end if; + + return File (1 .. P); + end Get_Windows_Exec_Path; +end Windows_Default_Path; diff --git a/dist/windows/mcode/windows_default_path.ads b/dist/windows/mcode/windows_default_path.ads new file mode 100644 index 000000000..9da3be559 --- /dev/null +++ b/dist/windows/mcode/windows_default_path.ads @@ -0,0 +1,30 @@ +-- Find installation path (using executable). +-- Copyright (C) 2002 - 2016 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 GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +-- +-- As a special exception, if other files instantiate generics from this +-- unit, or you link this unit with other files to produce an executable, +-- this unit does not by itself cause the resulting executable to be +-- covered by the GNU General Public License. This exception does not +-- however invalidate any other reasons why the executable file might be +-- covered by the GNU Public License. + +package Windows_Default_Path is + -- Get the default path from executable name. + -- This function is called during elaboration! + function Get_Windows_Exec_Path return String; +end Windows_Default_Path; diff --git a/dist/windows/shared.psm1 b/dist/windows/shared.psm1 new file mode 100644 index 000000000..2517a6ae4 --- /dev/null +++ b/dist/windows/shared.psm1 @@ -0,0 +1,370 @@ +# 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 +# +# PowerShell Module: The module provides common CmdLets for ... +# +# Description: +# ------------------------------------ +# This PowerShell module provides CommandLets (CmdLets) to ... +# +# ============================================================================== +# Copyright (C) 2016-2017 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. +# ============================================================================== + +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$WorkingDir, + [Parameter(Mandatory=$true)][Switch]$Hosted +) + +$Module_WorkingDir = $WorkingDir +$Module_Hosted = $Hosted + +function Exit-CompileScript +{ <# + .SYNOPSIS + Undocumented + .DESCRIPTION + Undocumented + .PARAMETER ExitCode + ExitCode of this script run + #> + [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + cd $Module_WorkingDir + # unload modules + if (-not $Module_Hosted) + { Remove-Module shared -Verbose:$false -Debug:$false + Remove-Module targets -Verbose:$false -Debug:$false + } + 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 = 0 + $VersionAsInt = 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 = -1 } + } + elseif ($Line.StartsWith("--END-V") -or $Line.StartsWith("--END-!V")) + { $State = 0 } + else + { if ($State -eq 0) + { if ($Line.EndsWith("--V$Version")) + { Write-Output $Line } + elseif (-not (($Line -like "*--V??") -or ($Line.EndsWith("--!V$Version")))) + { Write-Output $Line } + } + elseif ($State -eq $VersionAsInt) + { Write-Output $Line } + # else + # { Write-Host "Discard line: $Line" -ForegroundColor Red } + } + } + else + { Write-Host "Unknown pipeline object type." -ForegroundColor Red } + } + + end + { + } +} + +function Restore-NativeCommandStream +{ <# + .SYNOPSIS + This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs + as a single line. + + .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( + [Parameter(ValueFromPipeline=$true)] + $InputObject + ) + + begin + { $LineRemainer = "" } + + process + { if ($InputObject -is [System.Management.Automation.ErrorRecord]) + { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") + { Write-Output $InputObject.ToString() } + elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") + { $NewLine = $LineRemainer + $InputObject.ToString() + while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1) + { Write-Output $NewLine.Substring(0, $NewLinePos) + $NewLine = $NewLine.Substring($NewLinePos + 1) + } + $LineRemainer = $NewLine + } + } + elseif ($InputObject -is [String]) + { Write-Output $InputObject } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { if ($LineRemainer -ne "") + { Write-Output $LineRemainer } + } +} + +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 + 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.) + #> + [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+:warning:\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-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 + Returns true, if the current working directy is under git control. + #> + + git rev-parse 2>&1 | Out-Null + return $LastExitCode -eq 0 +} + +# 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/windows/targets.psm1 b/dist/windows/targets.psm1 new file mode 100644 index 000000000..4df6f1358 --- /dev/null +++ b/dist/windows/targets.psm1 @@ -0,0 +1,411 @@ +# 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 +# +# PowerShell Module: The module provides build targets for GHDL. +# +# Description: +# ------------------------------------ +# This PowerShell module provides build targets for GHDL. +# +# ============================================================================== +# Copyright (C) 2016-2017 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. +# ============================================================================== + +# TODO: +# check if: +# - program are installed / auto find programs / auto find paths +# - program version + +# configure compiler tools +$Prog_GCC = "gcc.exe" +$Prog_GNATMake = "gnatmake.exe" +$Prog_Strip = "strip.exe" + +# configure output file +$GHDL_Mcode_Name = "ghdl.exe" + +# configure directory structure +$CommonSourceDirName = "src" +$WinMcodeSourceDirName = "dist\windows\mcode" +# $WinLLVMSourceDirName = "dist\windows\llvm" + +# construct file paths +$VersionFileName_In = "version.in" +$VersionFileName_Ads = "version.ads" + + +function Invoke-Clean +{ <# + .SYNOPSIS + This CommandLet removes all generated files. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console. + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + $EnableDebug = -not $Quiet -and ( $PSCmdlet.MyInvocation.BoundParameters["Debug"]) + $EnableVerbose = -not $Quiet -and ($EnableDebug -or $PSCmdlet.MyInvocation.BoundParameters["Verbose"]) + + -not $Quiet -and (Write-Host "Executing build target 'Clean' ..." -ForegroundColor Yellow) | Out-Null + $EnableVerbose -and (Write-Host " Removing all created files and directories..." ) | Out-Null + if (Test-Path -Path $BuildDirectory) + { $EnableDebug -and (Write-Host " rmdir $BuildDirectory" ) | Out-Null + Remove-Item $BuildDirectory -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: Cannot remove '$BuildDirectory'." -ForegroundColor Red + return $true + } + } + return $false +} # Invoke-Clean + +function New-BuildDirectory +{ <# + .SYNOPSIS + This CommandLet creates a build directory if not existent, yet. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console. + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + Write-Host "Executing build target 'BuildDirectory' ..." -ForegroundColor Yellow + if (Test-Path -Path $BuildDirectory -PathType Container) + { -not $Quiet -and (Write-Host " Directory '$BuildDirectory' already exists." ) | Out-Null } + else + { -not $Quiet -and (Write-Host " Creating new directory '$BuildDirectory'." ) | Out-Null + New-Item -ItemType Directory -Path $BuildDirectory -ErrorAction SilentlyContinue | Out-Null + if ($? -eq $false) + { Write-Host "[ERROR]: Cannot create '$BuildDirectory'." -ForegroundColor Red + return $true + } + } + + return $false +} # New-BuildDirectory + +function Get-GHDLVersion +{ <# + .SYNOPSIS + Returns the GHDL version string. + .PARAMETER GHDLRootDir + The repository root directory. + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir + ) + # construct DirectoryPaths + $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + $VersionFilePath = $SourceDirectory + "\" + $VersionFileName_In + + if (-not (Test-Path -Path $VersionFilePath -PathType Leaf)) + { Write-Host "[ERROR]: Version file '$VersionFilePath' does not exists." -ForegroundColor Red + return $true + } + $FileContent = Get-Content -Path $VersionFilePath + foreach ($Line in $FileContent) + { if ($Line -match 'Ghdl_Ver(.+?)\"(.+?)\";') + { return $Matches[2] } + } + Write-Host "[ERROR]: RegExp didn't match in '$VersionFilePath'." -ForegroundColor Red + return $true +} # Get-GHDLVersion + +function Invoke-PatchVersionFile +{ <# + .SYNOPSIS + This CommandLet patches the version file to include the git patch state. + .PARAMETER GHDLRootDir + The repository root directory. + .PARAMETER GitBranchName + The branch's name, where HEAD is located. + .PARAMETER GitCommitDataString + The DateTime when HEAD was commited. + .PARAMETER GitCommitHash + The Hash of HEAD. + .PARAMETER Quiet + Disable outputs to the host console. + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir, + [string] $GitBranchName = "unknown", + [string] $GitCommitDataString = "unknown", + [string] $GitCommitHash = "........", + [switch] $Quiet = $false + ) + # construct DirectoryPaths + $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + $VersionInputFilePath = $SourceDirectory + "\" + $VersionFileName_In + $VersionFilePath = $SourceDirectory + "\" + $VersionFileName_Ads + + Write-Host "Executing build target 'PatchVersionFile' ..." -ForegroundColor Yellow + + if (-not (Test-Path -Path $VersionInputFilePath -PathType Leaf)) + { Write-Host "[ERROR]: Version file '$VersionInputFilePath' does not exists." -ForegroundColor Red + return $true + } + -not $Quiet -and (Write-Host " Patching '$VersionInputFilePath'.") | Out-Null + $FileContent = Get-Content -Path $VersionInputFilePath -Encoding Ascii + if ($? -eq $false) + { Write-Host "[ERROR]: While opening '$VersionInputFilePath'." -ForegroundColor Red + return $true + } + $FileContent = $FileContent -Replace "\s\(tarball\)\s", " (commit: $GitCommitDataString; git branch: $GitBranchName'; hash: $GitCommitHash) " + + $FileContent | Out-File $VersionFilePath -Encoding Ascii + if ($? -eq $false) + { Write-Host "[ERROR]: While writing to '$VersionFilePath'." -ForegroundColor Red + return $true + } + + return $false +} # Invoke-PatchVersionFile + + +function Get-CFlags +{ <# + .SYNOPSIS + Returns common ANSI C compiler flags for GCC. + #> + return @( + "-O1", # optimize; level 1 + "-g" # enable debug symbols + ) +} + +function Invoke-CompileCFiles +{ <# + .SYNOPSIS + This CommandLet compiles all C files with GCC. + .PARAMETER GHDLRootDir + The repository root directory. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir, + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + # construct DirectoryPaths + $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + + Set-Location $BuildDirectory + Write-Host "Executing build target 'CompileCFiles' ..." -ForegroundColor Yellow + + # list all files to be compiled; add additional CFlags if needed + $SourceFiles = @() + $SourceFiles += New-Object PSObject -Property @{File="grt\grt-cbinding.c"; CFlags=@()} + $SourceFiles += New-Object PSObject -Property @{File="grt\grt-cvpi.c"; CFlags=@()} + $SourceFiles += New-Object PSObject -Property @{File="grt\config\clock.c"; CFlags=@()} + $SourceFiles += New-Object PSObject -Property @{File="grt\config\win32.c"; CFlags=@('-DWITH_GNAT_RUN_TIME')} + $SourceFiles += New-Object PSObject -Property @{File="ortho\mcode\memsegs_c.c"; CFlags=@()} + + # compile C files + foreach ($SourceFile in $SourceFiles) + { $Parameters = @() + $Parameters += "-c" # compile only + $Parameters += Get-CFlags # append common CFlags + $Parameters += $SourceFile.CFlags + $Parameters += $SourceDirectory + "\" + $SourceFile.File + + # call C compiler + $InvokeExpr = "$Prog_GCC " + ($Parameters -join " ") + " 2>&1" + + Write-Host (" compiling: " + $SourceFile.File) + Write-Debug " call: $InvokeExpr" + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " + if ($LastExitCode -ne 0) + { Write-Host ("[ERROR]: While compiling '{0}'." -f $SourceFile.File) -ForegroundColor Red + return $true + } + } + + return $false +} # Invoke-CompileCFiles + + +function Invoke-CompileGHDLAdaFiles +{ <# + .SYNOPSIS + This CommandLet compiles all Ada files with GNAT. + .PARAMETER GHDLRootDir + The repository root directory. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir, + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + # construct DirectoryPaths + $CommonSourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + $WinMcodeSourceDirectory = $GHDLRootDir + "\" + $WinMcodeSourceDirName + + Set-Location $BuildDirectory + Write-Host "Executing build target 'CompileGHDLAdaFiles' ..." -ForegroundColor Yellow + + $Parameters = @() + $Parameters += Get-CFlags # append common CFlags + $Parameters += '-gnatn' + + # append all source paths + $Parameters += '-aI' + $WinMcodeSourceDirectory + $Parameters += '-aI' + $CommonSourceDirectory + $Parameters += '-aI' + $CommonSourceDirectory + '\ghdldrv' + $Parameters += '-aI' + $CommonSourceDirectory + '\psl' + $Parameters += '-aI' + $CommonSourceDirectory + '\grt' + $Parameters += '-aI' + $CommonSourceDirectory + '\ortho' + $Parameters += '-aI' + $CommonSourceDirectory + '\ortho\mcode' + $Parameters += '-aI' + $CommonSourceDirectory + '\vhdl' + $Parameters += '-aI' + $CommonSourceDirectory + '\vhdl\translate' + + # top level + $Parameters += 'ghdl_jit' + + # add output filename + $Parameters += '-o' + $Parameters += $GHDL_Mcode_Name + + # append linker parameters + $Parameters += '-largs' + $Parameters += 'grt-cbinding.o' + $Parameters += 'clock.o' + $Parameters += 'grt-cvpi.o' + $Parameters += 'memsegs_c.o' + $Parameters += 'win32.o' + $Parameters += '-ldbghelp' + $Parameters += '-largs' + # $Parameters += '-Wl,--stack,8404992' + + # call Ada compiler (GNAT) + $InvokeExpr = "$Prog_GNATMake " + ($Parameters -join " ") + " 2>&1" + + Write-Host " compiling with GNAT" + Write-Debug " call: $InvokeExpr" + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: While compiling '$GHDL_Mcode_Name'." -ForegroundColor Red + return $true + } + return $false +} # Invoke-CompileGHDLAdaFiles + + +function Invoke-StripGHDLExecutable +{ <# + .SYNOPSIS + This CommandLet strips the result files. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + Set-Location $BuildDirectory + Write-Host "Executing build target 'StripGHDLExecutable' ..." -ForegroundColor Yellow + + # call striping tool (strip) + Write-Host " stripping '$GHDL_Mcode_Name'" + Write-Debug " call: $Prog_Strip $GHDL_Mcode_Name" + & $Prog_Strip $GHDL_Mcode_Name + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: While stripping '$GHDL_Mcode_Name'." -ForegroundColor Red + return $true + } + return $false +} # Invoke-StripGHDLExecutable + +function Test-GHDLVersion +{ <# + .SYNOPSIS + This CommandLet executes ghdl to read the version information + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + Set-Location $BuildDirectory + Write-Host "Executing build target 'GHDLVersion' ..." -ForegroundColor Yellow + + if (-not (Test-Path -Path $GHDL_Mcode_Name -PathType Leaf)) + { Write-Host " GHDL executable '$GHDL_Mcode_Name' does not exists." -ForegroundColor Red + return $true + } + + # call ghdl + $InvokeExpr = "$GHDL_Mcode_Name --version 2>&1" + + Write-Host " executing '$GHDL_Mcode_Name'" + Write-Host " call: $InvokeExpr" + Write-Host " ----------------------------------------" + Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-HostExtended " " + Write-Host " ----------------------------------------" + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: While executing '$GHDL_Mcode_Name'." -ForegroundColor Red + return $true + } + return $false +} # Test-GHDLVersion + + +# export functions +Export-ModuleMember -Function 'Get-GHDLVersion' +Export-ModuleMember -Function 'Invoke-Clean' +Export-ModuleMember -Function 'New-BuildDirectory' +Export-ModuleMember -Function 'Invoke-PatchVersionFile' +Export-ModuleMember -Function 'Restore-PatchedVersionFile' +Export-ModuleMember -Function 'Invoke-CompileCFiles' +Export-ModuleMember -Function 'Invoke-CompileGHDLAdaFiles' +Export-ModuleMember -Function 'Invoke-StripGHDLExecutable' +Export-ModuleMember -Function 'Test-GHDLVersion' -- cgit v1.2.3