diff options
author | tgingold <tgingold@users.noreply.github.com> | 2016-08-25 03:03:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-25 03:03:43 +0200 |
commit | 55a3109ba79139e86d99436aabb797897547821a (patch) | |
tree | 8a1e3ede9f8e2fcd7a3fe4576163afa2179a2c47 | |
parent | ffc92a8cd7e71cc8c87be28580bd2fe0fbda0095 (diff) | |
parent | 70b634cf20c1f7a6d2b6439d94899e3ff0a43344 (diff) | |
download | ghdl-55a3109ba79139e86d99436aabb797897547821a.tar.gz ghdl-55a3109ba79139e86d99436aabb797897547821a.tar.bz2 ghdl-55a3109ba79139e86d99436aabb797897547821a.zip |
Merge pull request #139 from Paebbels/paebbels/winbuild
Reworked compile scripts for Windows.
-rw-r--r-- | dist/mcode/winbuild.ps1 | 705 | ||||
-rw-r--r-- | dist/mcode/windows/compile-ghdl.ps1 | 297 | ||||
-rw-r--r-- | dist/mcode/windows/compile-libraries.ps1 | 253 | ||||
-rw-r--r-- | dist/mcode/windows/shared.psm1 | 3 | ||||
-rw-r--r-- | dist/mcode/windows/targets.psm1 | 190 | ||||
-rw-r--r-- | libraries/vendors/compile-altera.ps1 | 4 | ||||
-rw-r--r-- | libraries/vendors/compile-lattice.ps1 | 4 | ||||
-rw-r--r-- | libraries/vendors/compile-osvvm.ps1 | 4 | ||||
-rw-r--r-- | libraries/vendors/compile-vunit.ps1 | 4 | ||||
-rw-r--r-- | libraries/vendors/compile-xilinx-ise.ps1 | 4 | ||||
-rw-r--r-- | libraries/vendors/compile-xilinx-vivado.ps1 | 4 | ||||
-rw-r--r-- | libraries/vendors/shared.psm1 | 16 |
12 files changed, 763 insertions, 725 deletions
diff --git a/dist/mcode/winbuild.ps1 b/dist/mcode/winbuild.ps1 index 5d154c28f..6f6a49375 100644 --- a/dist/mcode/winbuild.ps1 +++ b/dist/mcode/winbuild.ps1 @@ -35,33 +35,35 @@ # 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 -InstallPath "C:\Tools\GHDL"
-
- # Create a zip-file
- PS>.\winbuild.ps1 -CreatePackage -Zip
-
- # combine all commands in a single call
- PS>.\winbuild.ps1 -Clean -Compile -Install -InstallPath "C:\Tools\GHDL"
-#>
-# define script parameters
+# .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 "C:\Tools\GHDL"
+#
+# # Create a Zip-file
+# PS>.\winbuild.ps1 -CreatePackage -Zip
+#
+# # combine all commands in a single call
+# PS>.\winbuild.ps1 -Clean -Compile -Install "C:\Tools\GHDL"
+#
[CmdletBinding()]
Param(
- # compile GHDL
- [switch]$Compile,
-
# 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,
@@ -69,12 +71,9 @@ Param( [switch]$Zip,
# install all files into a directory (xcopy deployment)
- [switch]$Install,
- # Installation directory
- [string]$InstallPath,
- # update files
- [switch]$Update,
-
+ [string]$Install = "",
+ # update files
+ [switch]$Update,
# uninstall all files from a directory
[switch]$Uninstall,
@@ -83,34 +82,85 @@ Param( )
# configure script here
-$Script_RelPathToRoot = "..\.."
+$RelPathToRoot = "..\.."
# save parameters and current working directory
-$Script_Parameters = $args
-$Script_ScriptDir = $PSScriptRoot
-$Script_WorkingDir = Get-Location
-$GHDLRootDir_AbsPath = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $Script_RelPathToRoot))
+$Script_ScriptDir = $PSScriptRoot
+$Script_WorkingDir = Get-Location
+$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot))
+
+# set default values
+$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent
+$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent
+
+# Write-Host ("--> " + $Verbose + " value: " +$PSCmdlet.MyInvocation.BoundParameters["Verbose"] + " IsPresent: " + $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent)
+# Write-Host ("--> " + $PSCommandPath + " " + $PSBoundParameters + " " + $PSCmdlet + " " + $PSDefaultParameterValues)
+
+# load modules from GHDL's 'libraries' directory
+Import-Module $PSScriptRoot\windows\shared.psm1 -Verbose:$false -ArgumentList "$Script_WorkingDir"
+Import-Module $PSScriptRoot\windows\targets.psm1 -Verbose:$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, ...
-$WindowsDirName = "dist\mcode\windows"
-$BuildDirName = "dist\mcode\build"
-$CompiledLibraryDirName = "dist\mcode\lib"
-$ZipPackageDirName = "dist\mcode\zip"
-$ZipPackageFileName = "dist\mcode\ghdl-install.zip"
-$VendorLibraryDirName = "libraries\vendors"
+$GHDLVersion = Get-GHDLVersion $GHDLRootDir
+$Backend = "mcode"
+$WindowsDirName = "dist\$Backend\windows"
+$BuildDirectoryName = "build\$Backend"
+$VHDLLibrariesDirectoryName = "lib"
+$PackageDirectoryName = "build\zip\$Backend"
+$ZipPackageFileName = "ghdl-$Backend-$GHDLVersion.zip"
# construct directories
-$GHDLWindowsDir = $GHDLRootDir_AbsPath + "\" + $WindowsDirName
-$GHDLBuildDir = $GHDLRootDir_AbsPath + "\" + $BuildDirName
-$GHDLCompiledLibraryDir = $GHDLRootDir_AbsPath + "\" + $CompiledLibraryDirName
-$GHDLZipPackageDir = $GHDLRootDir_AbsPath + "\" + $ZipPackageDirName
-$GHDLZipPackageFile = $GHDLRootDir_AbsPath + "\" + $ZipPackageFileName
-$GHDLVendorLibraryDirName = $GHDLRootDir_AbsPath + "\" + $VendorLibraryDirName
+$GHDLWindowsDir = "$GHDLRootDir\$WindowsDirName"
+$GHDLBuildDir = "$GHDLRootDir\$BuildDirectoryName"
+$GHDLVendorLibraryDir = "$GHDLRootDir\libraries\vendors"
+$GHDLCompiledLibraryDir = "$GHDLRootDir\$BuildDirectoryName\$VHDLLibrariesDirectoryName"
+$GHDLZipPackageDir = "$GHDLRootDir\$PackageDirectoryName"
+$GHDLZipPackageFile = "$GHDLZipPackageDir\$ZipPackageFileName"
-# set default values
-$Script_ExitCode = 0
-if ($PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent) { $Script_EnableDebug = $true }
-if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) { $Script_EnableVerbose = $true }
+function Exit-Script
+{ [CmdletBinding()]
+ param(
+ [int]$ExitCode = 0
+ )
+ cd $Script_WorkingDir
+ # unload modules
+ Remove-Module shared
+ Remove-Module targets
+ exit $ExitCode
+}
# Author: Ed Wilson
# Source: https://blogs.technet.com/b/heyscriptingguy/archive/2011/07/23/use-powershell-to-modify-your-environmental-path.aspx
@@ -158,303 +208,286 @@ function Remove-Path }
-if ($Help)
- { Write-Host "Usage:"
- Write-Host " compile.ps1 [-Verbose] [-Debug] (-Help|-Compile|-Clean|-CreatePackage|-Install|-Uninstall)" -ForegroundColor Gray
- Write-Host
- Write-Host "Options:"
- Write-Host " -Verbose enable detailed messages"
- Write-Host " -Debug enable debug messages"
- Write-Host
- Write-Host "Commands:"
- Write-Host " -Help display this help"
- Write-Host " -Compile compile all library files"
- Write-Host " -Clean clean up all files and directories"
- Write-Host " -CreatePackage create an installer package"
- Write-Host " -Install install all files into a directory (xcopy deployment)"
- Write-Host " -Uninstall uninstall all files from a directory"
- Write-Host
- Write-Host "Options for -CreatePackage:"
- Write-Host " -Zip creates a zip-file for xcopy deployment"
- Write-Host
- Write-Host "Options for -Install:"
- Write-Host " -InstallPath <dir> directory into which GHDL will be installed"
- Write-Host
- Write-Host "Examples:"
- Write-Host " # Normal flow"
- Write-Host " PS>.\winbuild.ps1 -Clean" -ForegroundColor Gray
- Write-Host " PS>.\winbuild.ps1 -Compile" -ForegroundColor Gray
- Write-Host " PS>.\winbuild.ps1 -Install -InstallPath `"C:\Tools\GHDL`"" -ForegroundColor Gray
- Write-Host
- Write-Host " # Create a zip-file"
- Write-Host " PS>.\winbuild.ps1 -CreatePackage -Zip" -ForegroundColor Gray
- Write-Host
- Write-Host " # combine all commands in a single call"
- Write-Host " PS>.\winbuild.ps1 -Clean -Compile -Install -InstallPath `"C:\Tools\GHDL`"" -ForegroundColor Gray
- Write-Host
- }
+if ($Update)
+{ Write-Host "Updating GHDL $GHDLVersion for Windows..."
+
+ Write-Host "[ERROR]: This command is not implemented." -ForegroundColor Red
+ Exit-Script -1
+} # Update
elseif ($Uninstall)
- { Write-Host "Uninstalling GHDL $GHDLVersion for Windows"
+{ Write-Host "Uninstalling GHDL $GHDLVersion for Windows..."
- Write-Host "This command is not implemented" -ForegroundColor Red
- $Script_ExitCode = 1
+ 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 ($Script_ExitCode -eq 0)
- { Write-Host
- Write-Host "Uninstall " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
+ 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)
+ { $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)
+ { Write-Host "Removing installer packages and temporary directories..."
+ 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
}
- } # Uninstall
-else
- { $Script_ExitCode = -1
+ }
- if ($Clean)
- { $Script_ExitCode = 0
- Write-Host "Removing all created files and directories..."
+ 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
+ }
+ }
- if ($Script_ExitCode -eq 0)
- { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1"
- $Script_Parameters = @('-Clean')
- #$Script_Parameters += '-Clean'
- if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' }
- if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' }
-
- Write-Host "Running compile-ghdl.ps1 ..."
- Write-Host "--------------------------------------------------------------------------------"
- Invoke-Expression "$Script_Path $($Script_Parameters -join " ")"
- if ($LastExitCode -ne 0)
- { $Script_ExitCode = 1
- Write-Host "--------------------------------------------------------------------------------"
- Write-Host "ERROR while executing 'compile-ghdl.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red
- }
- else
- { Write-Host "--------------------------------------------------------------------------------"
- Write-Host "Completed " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- }
-
- if ($Script_ExitCode -eq 0)
- { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1"
- $Script_Parameters = @()
- $Script_Parameters += '-Clean'
- if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' }
- if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' }
-
- Write-Host "Running compile-libraries.ps1 ..."
- Write-Host "--------------------------------------------------------------------------------"
- Invoke-Expression "$Script_Path $($Script_Parameters -join " ")"
- if ($LastExitCode -ne 0)
- { $Script_ExitCode = 1
- Write-Host "--------------------------------------------------------------------------------"
- Write-Host "ERROR while executing 'compile-libraries.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red
- }
- else
- { Write-Host "--------------------------------------------------------------------------------"
- Write-Host "Completed " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- }
-
- if ($Script_ExitCode -eq 0)
- { Write-Host "Removing installer packages and temporary directories..."
- Write-Host " $GHDLZipPackageDir"
- Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue
-
- Write-Host " $GHDLZipPackageFile"
- Remove-Item $GHDLZipPackageFile -Force -Recurse -ErrorAction SilentlyContinue
- }
+ Write-Host
+ Write-Host "Clean " -NoNewline
+ Write-Host "[SUCCESSFUL]" -ForegroundColor Green
+ Write-Host
+ } # Clean_Package_Zip
+
+ # ============================================================================
+ # Compile tasks
+ # ============================================================================
+ if ($Compile_GHDL)
+ { Write-Host "Compiling GHDL $GHDLVersion for Windows..."
+
+ $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1"
+ $Script_Parameters = @()
+ $Script_Parameters = @(
+ '-All',
+ '-Verbose:$EnableVerbose',
+ '-Debug:$EnableDebug'
+ )
- if ($Script_ExitCode -eq 0)
- { Write-Host
- Write-Host "Clean " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- } # Clean
+ 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)
+ { Write-Host "Compiling GHDL's libraries ..."
+
+ $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1"
+ $Script_Parameters = @()
+ $Script_Parameters = @(
+ '-Compile',
+ '-Verbose:$EnableVerbose',
+ '-Debug:$EnableDebug'
+ )
- if ($Compile)
- { $Script_ExitCode = 0
- Write-Host "Compiling GHDL $GHDLVersion for Windows"
-
- if ($Script_ExitCode -eq 0)
- { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1"
- $Script_Parameters = @()
- $Script_Parameters += '-All'
- if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' }
- if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' }
-
- Write-Host "Running compile-ghdl.ps1 ..."
- Write-Host "--------------------------------------------------------------------------------"
- Invoke-Expression "$Script_Path $($Script_Parameters -join " ")"
- if ($LastExitCode -ne 0)
- { $Script_ExitCode = 1
- Write-Host "--------------------------------------------------------------------------------"
- Write-Host "ERROR while executing 'compile-ghdl.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red
- }
- else
- { Write-Host "--------------------------------------------------------------------------------"
- Write-Host "Completed " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- }
-
- if ($Script_ExitCode -eq 0)
- { $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1"
- $Script_Parameters = @()
- $Script_Parameters += '-Compile'
- if ($Script_EnableVerbose -eq $true) { $Script_Parameters += '-Verbose' }
- if ($Script_EnableDebug -eq $true) { $Script_Parameters += '-Debug' }
-
- $env:GHDL = "$GHDLBuildDir\ghdl.exe"
-
- Write-Host "Running compile-libraries.ps1 ..."
- Write-Host "--------------------------------------------------------------------------------"
- Invoke-Expression "$Script_Path $($Script_Parameters -join " ")"
- if ($LastExitCode -ne 0)
- { $Script_ExitCode = 1
- Write-Host "--------------------------------------------------------------------------------"
- Write-Host "ERROR while executing 'compile-libraries.ps1 $($Script_Paramters -join " ")'" -ForegroundColor Red
- }
- else
- { Write-Host "--------------------------------------------------------------------------------"
- Write-Host "Completed " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- }
-
- if ($Script_ExitCode -eq 0)
- { Write-Host
- Write-Host "Compile " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- } # Compile
+ $env:GHDL = "$GHDLBuildDir\ghdl.exe"
+ Write-Host "env:GHDL --" + $env:GHDL + "--"
+
+ 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
+ }
- if ($CreatePackage)
- { $Script_ExitCode = 0
- Write-Host "Creating an installation package for GHDL $GHDLVersion for Windows"
-
- if ($Zip)
- { if ((Get-Module -ListAvailable | Where {$_.Name -like "PSCX"}).Version -ge "3.1.0.0")
- { Write-Host "Loading PowerShell Community Extensions (PSCX) " -NoNewline
- Import-Module Pscx
- Write-Host "[Done]" -ForegroundColor Green
- }
- else
- { $Script_ExitCode = 1
- Write-Host "[FAILED]" -ForegroundColor RED
- }
- }
-
- # create zip-file
- if (($Script_ExitCode -eq 0) -and $Zip)
- { Write-Host "Output format: zip-file"
-
- Write-Host " Removing old directory '$GHDLZipPackageDir'."
- Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue
-
- Write-Host " Creating directory '$GHDLZipPackageDir'."
- [void](New-Item -ItemType directory -Path "$GHDLZipPackageDir" -ErrorAction SilentlyContinue)
- [void](New-Item -ItemType directory -Path "$GHDLZipPackageDir\bin" -ErrorAction SilentlyContinue)
- [void](New-Item -ItemType directory -Path "$GHDLZipPackageDir\scripts" -ErrorAction SilentlyContinue)
-
- Copy-Item "$GHDLBuildDir\ghdl.exe" "$GHDLZipPackageDir\bin\ghdl.exe" -ErrorAction SilentlyContinue
- Copy-Item "$GHDLBuildDir\ghdlfilter.exe" "$GHDLZipPackageDir\bin\ghdlfilter.exe" -ErrorAction SilentlyContinue
-
- Copy-Item $GHDLCompiledLibraryDir -Recurse "$GHDLZipPackageDir" -ErrorAction SilentlyContinue
- Copy-Item $GHDLVendorLibraryDirName -Recurse "$GHDLZipPackageDir\scripts" -ErrorAction SilentlyContinue
-
- Write-Host " Compressing 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"
- }
- else
- { $Script_ExitCode = 1
- Write-Host "No package format selected." -ForegroundColor Red
- Write-Host "Possible formats:"
- Write-Host " - zip-file (-Zip)"
- Write-Host
- }
-
- if ($Script_ExitCode -eq 0)
- { Write-Host
- Write-Host "Create Package " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- } # CreatePackage
+ 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
- if ($Install)
- { $Script_ExitCode = 0
- Write-Host "Installing GHDL $GHDLVersion for Windows"
-
- if ($InstallPath -eq "")
- { $Script_ExitCode = 1
- Write-Host "Missing argument -InstallPath" -ForegroundColor Red
- }
- else
- { if (Test-Path -Path $InstallPath)
- { if ($Update)
- { Remove-Item -Path "$InstallPath\*" -Recurse -Force }
- else
- { Write-Host " Directory '$InstallPath' already exists." -ForegroundColor Red
- Write-Host
- $Script_ExitCode = 1
- }
- }
- elseif ($Update)
- { Write-Host " Directory '$InstallPath' does not exists." -ForegroundColor Red
- Write-Host
- $Script_ExitCode = 1
- }
- }
-
- if ($Script_ExitCode -eq 0)
- { Write-Host " Install directory: $InstallPath"
-
- Write-Host " Creating directory '$InstallPath'."
- [void](New-Item -ItemType directory -Path "$InstallPath" -ErrorAction SilentlyContinue)
- [void](New-Item -ItemType directory -Path "$InstallPath\bin" -ErrorAction SilentlyContinue)
- [void](New-Item -ItemType directory -Path "$InstallPath\scripts" -ErrorAction SilentlyContinue)
-
- Copy-Item "$GHDLBuildDir\ghdl.exe" "$InstallPath\bin\ghdl.exe" -ErrorAction SilentlyContinue
- Copy-Item "$GHDLBuildDir\ghdlfilter.exe" "$InstallPath\bin\ghdlfilter.exe" -ErrorAction SilentlyContinue
-
- Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -ErrorAction SilentlyContinue
- Copy-Item "$GHDLVendorLibraryDirName\*.*" -Recurse "$InstallPath\scripts" -ErrorAction SilentlyContinue
- }
-
- if ($Script_ExitCode -eq 0)
- { Write-Host " Registering installation directory in system PATH" -NoNewline
- Write-Host " [DISABLED]" -ForegroundColor Red
- #Add-Path "$InstallPath\bin"
- }
-
- if ($Script_ExitCode -eq 0)
- { Write-Host
- Write-Host "Install " -NoNewline
- Write-Host "[SUCCESSFUL]" -ForegroundColor Green
- Write-Host
- }
- } # Install
+ 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
- if ($Script_ExitCode -eq -1)
- { Write-Host "ERROR: missing argument(s)" -ForegroundColor Red
- Write-Host
- Write-Host "Usage:"
- Write-Host " winbuild.ps1 [-Verbose] [-Debug] (-Help|-Compile|-Clean|-CreatePackage|-Install|-Uninstall)" -ForegroundColor Gray
- Write-Host
- } # Unknown
+ 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 ($Install -eq $true)
+ { $InstallPath = "C:\Program Files (x86)\GHDL" }
+ elseif ($Install -eq "")
+ { $InstallPath = "C:\Program Files (x86)\GHDL" }
+ else
+ { $InstallPath = $Install }
+
+ 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
+ { 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" -ErrorAction SilentlyContinue
+ # include files
+ Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$InstallPath\include" -ErrorAction SilentlyContinue
+ # pre-compile scripts
+ Copy-Item $GHDLVendorLibraryDir -Recurse "$InstallPath\lib\vendors" -ErrorAction SilentlyContinue
+ # pre-compiled libraries
+ Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -ErrorAction SilentlyContinue
-# restore working directory if changed
-Set-Location $Script_WorkingDir
-
-# return exit status
-exit $Script_ExitCode
+ Write-Host
+ Write-Host "Installing files " -NoNewline
+ Write-Host "[SUCCESSFUL]" -ForegroundColor Green
+ Write-Host
+
+ Exit-Script
+ } # Zip
+ } # Install
+
+} # Clean
+
+Exit-Script
diff --git a/dist/mcode/windows/compile-ghdl.ps1 b/dist/mcode/windows/compile-ghdl.ps1 index 7bfa62fbb..5017b1fee 100644 --- a/dist/mcode/windows/compile-ghdl.ps1 +++ b/dist/mcode/windows/compile-ghdl.ps1 @@ -35,216 +35,221 @@ # Software Foundation, 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # ============================================================================== -<# - .SYNOPSIS - GHDL for Windows - GHDL compile script - Use 'compile.ps1 -Help' to see the integrated help page - - .EXAMPLE - C:\PS> .\compile.ps1 -Clean -Compile -#> -# define script parameters +# .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( - # compile ALL - [switch]$All = $false, +param( + # Display this help" + [switch]$Help = $false, - # compile main targets - [switch]$Compile = $false, - # compile GHDL (simulator) - [switch]$GHDL = $false, - [switch]$Test = $false, + # Slean up all files and directories + [switch]$Clean = $false, + [switch]$Clean_GHDL = $false, - # compile TOOLS - [switch]$Tools = $false, - # compile Filter (helper) - [switch]$Filter = $false, + # Compile all targets + [switch]$All = $false, - # build options - [switch]$Release = $false, + # Compile main targets + [switch]$Compile = $false, + # Compile GHDL (simulator) + [switch]$Compile_GHDL = $false, + # Undocumented + [switch]$Test = $false, + # Undocumented + [switch]$Test_GHDL = $false, - # clean up all files and directories - [switch]$Clean = $false, + # Build options + # Build a release version + [switch]$Release = $false, + # Set the back-end + [string]$Backend = "mcode", - # display this help" - [switch]$Help = $false + # 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 -$Script_RelPathToRoot = "..\..\.." +$RelPathToRoot = "..\..\.." -# save parameters and current working directory -$Script_Parameters = $args +# --------------------------------------------- +# save parameters and working directory +$Script_ScriptDir = $PSScriptRoot $Script_WorkingDir = Get-Location -$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $Script_RelPathToRoot)) +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) # set default values -$Script_ExitCode = 0 -$BuildRelease = "Development" # "Release" +$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent +$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent + +# Write-Host ("--> " + $Verbose + " value: " +$PSCmdlet.MyInvocation.BoundParameters["Verbose"] + " IsPresent: " + $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) +# Write-Host ("--> " + $PSCommandPath + " " + $PSBoundParameters + " " + $PSCmdlet + " " + $PSDefaultParameterValues) + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList "$Script_WorkingDir" +Import-Module $PSScriptRoot\targets.psm1 -Verbose:$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 - $Tools = $true +{ $Compile = $true } if ($Compile) -{ $GHDL = $true - $Test = $true +{ $Compile_GHDL = $true } -if ($Tools) -{ $Filter = $true +if ($Test) +{ $Test_GHDL = $true } -if ($Release) -{ $BuildRelease = "Release" } -else -{ $BuildRelease = "Development" } - -$NoCommand = -not ($Clean -or $All -or $Compile -or $Tools -or $GHDL -or $Test -or $Filter) -if ($NoCommand) -{ $Help = $true } +# configure some variables: paths, executables, directory names, ... +$BuildDirectoryName = "build" -Write-Host "================================================================================" -ForegroundColor Magenta -Write-Host "GHDL for Windows - GHDL and tools compile script" -ForegroundColor Magenta -Write-Host "================================================================================" -ForegroundColor Magenta - -# if command is help or no command was given => display help page(s) -if ($Help) -{ Write-Host "Usage:" - Write-Host " compile.ps1 (-Help|-Clean|-All|-Compile|-Tools|-GHDL|-Test|-Filter)" -ForegroundColor Gray - Write-Host - Write-Host "Options:" - Write-Host " -Release build in release mode" - # Write-Host " -Debug enable debug messages" - # Write-Host - Write-Host "Commands:" - Write-Host " -Help display this help" - Write-Host " -All compile all targets" - Write-Host " -Compile compile all main targets" - Write-Host " -Tools compile all tool targets" - Write-Host " -GHDL compile ghdl.exe" - Write-Host " -Filter compile filter.exe" - Write-Host " -Clean clean up all files and directories" - Write-Host - - exit 0 -} # Help +# Parameter checks +if ($Backend -ne "mcode") +{ Write-Host "[ERROR]: Back-end '$Backend' is not supported on Windows." -ForegroundColor Red + Exit-CompileScript -1 +} -# load modules -Import-Module $PSScriptRoot\shared.psm1 -Import-Module $PSScriptRoot\targets.psm1 +# 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 +$GHDLVersion = Get-GHDLVersion $GHDLRootDir +# compute some variables +$BuildRelease = if ($Release) { "Release" } else { "Development" } +if (-not $Hosted) +{ Write-Host " Version: $GHDLVersion" + Write-Host " Release: $BuildRelease" +} -# gather git information $Git_IsGitRepo = Test-GitRepository +# gather git information if ($Git_IsGitRepo) { $Git_Branch_Name = & git rev-parse --abbrev-ref HEAD - $Git_Commit_DataString = & git log -1 --format=%cd --date=short + $Git_Commit_DateString = & git log -1 --format=%cd --date=short $Git_Commit_ShortHash = & git rev-parse --short HEAD -} - -Write-Host " Version: $GHDLVersion" -Write-Host " Release: $BuildRelease" -if ($Git_IsGitRepo) -{ Write-Host " Git branch: $Git_Branch_Name" - Write-Host " Git commit: $Git_Commit_DataString ($Git_Commit_ShortHash)" -} -Write-Host -function Write-TargetResult($error) -{ if ($error) - { Write-Host " [FAILED]" -ForegroundColor Red } - # else - # { Write-Host " [DONE]" -ForegroundColor Green } + if (-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 ($BuildRelease -eq "Release") -{ $BuildDir = $GHDLRootDir + "\dist\mcode\build" } -elseif ($BuildRelease -eq "Development") -{ $BuildDir = $GHDLRootDir + "\dist\mcode\build" } +if ($Release) +{ $BuildDirectory = $BinaryDestinationDirectory } else -{ Write-Host "[ERROR]: Unknown build setting '$BuildRelease'." -ForegroundColor Red - exit 1 -} +{ $BuildDirectory = $BinaryDestinationDirectory } + # ============================================================================== # Main Target: Clean # ============================================================================== -if ($Clean) -{ $error = Invoke-Clean $BuildDir - Write-TargetResult $error +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 ($GHDL) +if ($Compile_GHDL) { # create a build directory - $error = Invoke-CreateBuildDirectory $BuildDir - Write-TargetResult $error + $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 $error) -and ($BuildRelease -eq "Development") -and $Git_IsGitRepo) - { $error = Invoke-PatchVersionFile $GHDLRootDir $Git_Branch_Name $Git_Commit_DataString $Git_Commit_ShortHash - Write-TargetResult $error + 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 - if (-not $error) - { $error = Invoke-CompileCFiles $GHDLRootDir $BuildDir - Write-TargetResult $error + $error = Invoke-CompileCFiles $GHDLRootDir $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 } # build Ada source files - if (-not $error) - { $error = Invoke-CompileGHDLAdaFiles $GHDLRootDir $BuildDir - Write-TargetResult $error + $error = Invoke-CompileGHDLAdaFiles $GHDLRootDir $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 } # strip result - if (-not $error) - { $error = Invoke-StripGHDLExecutable $BuildDir - Write-TargetResult $error + $error = Invoke-StripGHDLExecutable $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 } # restore the version file if it was patched - if ((-not $error) -and ($BuildRelease -eq "Development") -and $Git_IsGitRepo) + if (-not $Release -and $Git_IsGitRepo) { $error = Restore-PatchedVersionFile $GHDLRootDir - Write-TargetResult $error + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } } -} # Compile +} -if ($Test) -{ # running ghdl - $error = Test-GHDLVersion $BuildDir - Write-TargetResult $error -} # Test # ============================================================================== -# Tool Target: Filter +# Main Target: GHDL # ============================================================================== -if ($Filter) -{ # create a build directory - $error = Invoke-CreateBuildDirectory $BuildDir - Write-TargetResult $error - - # build Ada source files - if (-not $error) - { $error = Invoke-CompileFilterAdaFiles $GHDLRootDir $BuildDir - Write-TargetResult $error +if ($Test_GHDL) +{ # running ghdl + $error = Test-GHDLVersion $BuildDir + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 } -} # Tools - - -# unload PowerShell modules -Remove-Module shared -Remove-Module targets - -# restore working directory if changed -Set-Location $Script_WorkingDir +} # Test -# return exit status -exit $Script_ExitCode +Exit-CompileScript 0 diff --git a/dist/mcode/windows/compile-libraries.ps1 b/dist/mcode/windows/compile-libraries.ps1 index dc7cbb57e..01ab7712b 100644 --- a/dist/mcode/windows/compile-libraries.ps1 +++ b/dist/mcode/windows/compile-libraries.ps1 @@ -39,12 +39,14 @@ # .SYNOPSIS # GHDL for Windows - Library compile script -# Use 'complib.ps1 -Help' to see the integrated help page +# Use 'compile-libraries.ps1 -Help' to see the integrated help page # # .EXAMPLE -# C:\PS> .\complib.ps1 -Verbose -Compile +# C:\PS> .\complib.ps1 -Clean # .EXAMPLE -# C:\PS> .\complib.ps1 -Verbose -Clean +# C:\PS> .\complib.ps1 -Compile -Verbose +# .EXAMPLE +# C:\PS> .\complib.ps1 -VHDL2008 -SuppressWarnings # [CmdletBinding()] param( @@ -70,29 +72,41 @@ param( [switch]$HaltOnError = $false, # Set GHDL executable - [string]$GHDL = "" + [string]$GHDL = "", + # Undocumented + [switch]$Hosted = $false ) # configure script here -$Script_RelPathToRoot = "..\..\.." +$RelPathToRoot = "..\..\.." # --------------------------------------------- # save parameters and working directory -$Script_Parameters = $args $Script_ScriptDir = $PSScriptRoot $Script_WorkingDir = Get-Location -$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $Script_RelPathToRoot)) +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) # set default values -$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent -$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent +$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent +$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent # load modules from GHDL's 'libraries' directory -Import-Module $PSScriptRoot\shared.psm1 -ArgumentList "$Script_WorkingDir" +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList "$Script_WorkingDir" # Display help if no command was selected $Help = $Help -or (-not ($Compile -or $VHDL87 -or $VHDL93 -or $VHDL2008 -or $Clean)) +function Exit-CompileScript +{ [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + cd $Script_WorkingDir + # unload modules + Remove-Module shared -Verbose:$false + exit $ExitCode +} + if ($Help) { Get-Help $MYINVOCATION.InvocationName -Detailed Exit-CompileScript @@ -115,22 +129,6 @@ $VHDLDestinationLibraryDirectory = "$GHDLRootDir\$BuildDirectoryName\$Backend\$V # construct executables $GHDLNewExecutable = "$GHDLRootDir\$BuildDirectoryName\$Backend\bin\ghdl.exe" -# get GHDL executable -if ($GHDL -ne "") -{ $GHDLExecutable = $GHDL } -elseif (Test-Path env:GHDL) -{ $GHDLExecutable = $env:GHDL } -elseif (Test-Path $GHDLNewExecutable -PathType Leaf) -{ $GHDLExecutable = $GHDLNewExecutable } -else -{ $GHDLExecutable = "ghdl.exe" } - -if (-not (Test-Path $GHDLExecutable -PathType Leaf)) -{ Write-Host "GHDL executable 'ghdl.exe' not found." -ForegroundColor Red - Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Yellow - Exit-CompileScript -1 -} - # Library sources $SourceFiles = @{ @@ -190,17 +188,40 @@ $SourceFiles = @{ ) } -Write-Host "================================================================================" -ForegroundColor Yellow -Write-Host "GHDL ($Backend) for Windows - Library compile script" -ForegroundColor Yellow -Write-Host "================================================================================" -ForegroundColor Yellow +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..." - Write-Host " rmdir $VHDLDestinationLibraryDirectory" - - Remove-Item $VHDLDestinationLibraryDirectory -Force -Recurse -ErrorAction SilentlyContinue + if (Test-Path -Path $VHDLDestinationLibraryDirectory) + { Write-Host " rmdir $VHDLDestinationLibraryDirectory" + 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" } - Exit-CompileScript +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 } @@ -223,7 +244,7 @@ if ($VHDL87 -or $VHDL93 -or $VHDL2008) else { Write-Host " Creating directory '$VHDLDestinationLibraryDirectory'." New-Item -ItemType Directory -Path $VHDLDestinationLibraryDirectory -ErrorAction SilentlyContinue | Out-Null - if ($LastExitCode -ne 0) + if (-not $?) { Write-Host "[ERROR]: Cannot create destination directory '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red Exit-CompileScript -1 } @@ -236,10 +257,6 @@ if ($VHDL87 -or $VHDL93 -or $VHDL2008) Write-Host Write-Host "Start compilation..." } - - - - # ============================================================================ # v87 # ============================================================================ @@ -261,7 +278,7 @@ if ($VHDL87) $VHDLSourcesIndex = "std" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -269,10 +286,10 @@ if ($VHDL87) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -293,7 +310,7 @@ if ($VHDL87) $VHDLSourcesIndex = "ieee" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -301,10 +318,10 @@ if ($VHDL87) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -325,7 +342,7 @@ if ($VHDL87) $VHDLSourcesIndex = "ieee" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -333,10 +350,10 @@ if ($VHDL87) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -345,7 +362,7 @@ if ($VHDL87) foreach ($SourceFile in $SourceFiles["synopsys"] + $SourceFiles["synopsys8793"]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -353,10 +370,10 @@ if ($VHDL87) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -366,7 +383,7 @@ if ($VHDL87) $VHDLSourcesIndex = "vital95" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -374,10 +391,10 @@ if ($VHDL87) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -405,7 +422,7 @@ if ($VHDL93) $VHDLSourcesIndex = "std" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -413,10 +430,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -437,7 +454,7 @@ if ($VHDL93) $VHDLSourcesIndex = "ieee" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -445,10 +462,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -458,7 +475,7 @@ if ($VHDL93) $VHDLSourcesIndex = "vital2000" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -466,10 +483,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -490,7 +507,7 @@ if ($VHDL93) $VHDLSourcesIndex = "ieee" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -498,10 +515,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -510,7 +527,7 @@ if ($VHDL93) foreach ($SourceFile in $SourceFiles[$VHDLFlavor] + $SourceFiles["synopsys8793"]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -518,10 +535,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -531,7 +548,7 @@ if ($VHDL93) $VHDLSourcesIndex = "vital2000" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -539,10 +556,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -563,7 +580,7 @@ if ($VHDL93) $VHDLSourcesIndex = "ieee" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -571,10 +588,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -583,7 +600,7 @@ if ($VHDL93) foreach ($SourceFile in $SourceFiles[$VHDLFlavor]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -591,10 +608,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -604,7 +621,7 @@ if ($VHDL93) $VHDLSourcesIndex = "vital2000" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -612,10 +629,10 @@ if ($VHDL93) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -643,7 +660,7 @@ if ($VHDL2008) $VHDLSourcesIndex = "std08" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLLibrary\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -651,10 +668,10 @@ if ($VHDL2008) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -675,7 +692,7 @@ if ($VHDL2008) $VHDLSourcesIndex = "ieee2008" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -683,10 +700,10 @@ if ($VHDL2008) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -696,7 +713,7 @@ if ($VHDL2008) $VHDLSourcesIndex = "vital2000" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -704,10 +721,10 @@ if ($VHDL2008) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" -frelaxed-rules --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -728,7 +745,7 @@ if ($VHDL2008) $VHDLSourcesIndex = "ieee2008" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -736,10 +753,10 @@ if ($VHDL2008) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -748,7 +765,7 @@ if ($VHDL2008) foreach ($SourceFile in $SourceFiles[$VHDLFlavor]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -756,10 +773,10 @@ if ($VHDL2008) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } @@ -769,7 +786,7 @@ if ($VHDL2008) $VHDLSourcesIndex = "vital2000" foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" - $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null + $EnableVerbose -and (Write-Host " Patching file for $VHDLVersion" ) | Out-Null # Patch file Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` | Format-VHDLSourceFile -Version "$VHDLVersion" ` @@ -777,10 +794,10 @@ if ($VHDL2008) # Analyze file $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" -frelaxed-rules --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" - $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null - $EnableDebug -and (Write-Host " $InvokeExpr" ) | Out-Null + $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) + if (($LastExitCode -ne 0) -or -not $?) { $ErrorCount += 1 if ($HaltOnError) { Exit-CompileScript -1 } diff --git a/dist/mcode/windows/shared.psm1 b/dist/mcode/windows/shared.psm1 index 5e00b74cf..e39ce67ce 100644 --- a/dist/mcode/windows/shared.psm1 +++ b/dist/mcode/windows/shared.psm1 @@ -56,7 +56,8 @@ function Exit-CompileScript cd $Module_WorkingDir # unload modules - Remove-Module shared + Remove-Module shared -Verbose:$false + Remove-Module targets -Verbose:$false exit $ExitCode } diff --git a/dist/mcode/windows/targets.psm1 b/dist/mcode/windows/targets.psm1 index 502305a90..5dfd12b0b 100644 --- a/dist/mcode/windows/targets.psm1 +++ b/dist/mcode/windows/targets.psm1 @@ -36,20 +36,17 @@ # - program version # configure compiler tools -$GCCExecutable = "gcc.exe" -$GNATMakeExecutable = "gnatmake.exe" -$StripExecutable = "strip.exe" +$Prog_GCC = "gcc.exe" +$Prog_GNATMake = "gnatmake.exe" +$Prog_Strip = "strip.exe" # configure output file -$GHDLExecutableName = "ghdl.exe" -$FilterExecutable = "filter.exe" +$GHDL_Mcode_Name = "ghdl.exe" # configure directory structure $CommonSourceDirName = "src" $WinMcodeSourceDirName = "dist\mcode\windows" # $WinLLVMSourceDirName = "dist\llvm\windows" -$WinMcodeBuildDirName = "dist\mcode\build" -# $WinLLVMBuildDirName = "dist\llvm\build" # construct file paths $VersionFileName = "version.ads" @@ -70,17 +67,23 @@ function Invoke-Clean [switch] $Quiet = $false ) - Write-Host "Executing build target 'Clean' ..." -ForegroundColor Yellow - if ($Quiet -eq $false) - { Write-Host " Removing all created files and directories..." - Write-Host " rmdir $BuildDirectory" - } - Remove-Item $BuildDirectory -Force -Recurse -ErrorAction SilentlyContinue + $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 Invoke-CreateBuildDirectory +function New-BuildDirectory { <# .SYNOPSIS This CommandLet creates a build directory if not existent, yet. @@ -95,20 +98,20 @@ function Invoke-CreateBuildDirectory [switch] $Quiet = $false ) - Write-Host "Executing build target 'CreateBuildDirectory' ..." -ForegroundColor Yellow - if (Test-Path -Path $BuildDirectory) - { if ($Quiet -eq $false) - { Write-Host " Directory '$BuildDirectory' already exists." } - } + 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 - { if ($Quiet -eq $false) - { Write-Host " Creating new directory '$BuildDirectory'." } - - [void](New-Item -ItemType directory -Path $BuildDirectory -ErrorAction SilentlyContinue) + { -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 -} # Invoke-CreateBuildDirectory +} # New-BuildDirectory function Get-GHDLVersion { <# @@ -123,20 +126,20 @@ function Get-GHDLVersion ) # construct DirectoryPaths $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - # construct FilePaths $VersionFilePath = $SourceDirectory + "\" + $VersionFileName - if (-not (Test-Path -Path $VersionFilePath)) - { Write-Host " Version file '$VersionFilePath' does not exists." -ForegroundColor Red - return "" + 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] } } - return "" -} + Write-Host "[ERROR]: RegExp didn't match in '$VersionFilePath'." -ForegroundColor Red + return $true +} # Get-GHDLVersion function Invoke-PatchVersionFile { <# @@ -156,30 +159,36 @@ function Invoke-PatchVersionFile [CmdletBinding()] param( [string] $GHDLRootDir, - [string] $GitBranchName = "unknown", - [string] $GitCommitDataString = "unknown", - [string] $GitCommitHash = "........", - [switch] $Quiet = $false + [string] $GitBranchName = "unknown", + [string] $GitCommitDataString = "unknown", + [string] $GitCommitHash = "........", + [switch] $Quiet = $false ) # construct DirectoryPaths $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - # construct FilePaths $CurrentVersionFilePath = $SourceDirectory + "\" + $VersionFileName $OriginalVersionFilePath = $SourceDirectory + "\" + $VersionFileName + ".bak" Write-Host "Executing build target 'PatchVersionFile' ..." -ForegroundColor Yellow - if (-not (Test-Path -Path $CurrentVersionFilePath)) - { Write-Host " Version file '$CurrentVersionFilePath' does not exists." -ForegroundColor Red + if (-not (Test-Path -Path $CurrentVersionFilePath -PathType Leaf)) + { Write-Host "[ERROR]: Version file '$CurrentVersionFilePath' does not exists." -ForegroundColor Red return $true } - if ($Quiet -eq $false) - { Write-Host " Patching '$CurrentVersionFilePath'." } + -not $Quiet -and (Write-Host " Patching '$CurrentVersionFilePath'.") | Out-Null $FileContent = Get-Content -Path $CurrentVersionFilePath -Encoding Ascii + if ($? -eq $false) + { Write-Host "[ERROR]: While opening '$CurrentVersionFilePath'." -ForegroundColor Red + return $true + } $FileContent = $FileContent -Replace "\s\(\d+\)\s", " (commit: $GitCommitDataString; git branch: $GitBranchName'; hash: $GitCommitHash) " Move-Item $CurrentVersionFilePath $OriginalVersionFilePath -Force $FileContent | Out-File $CurrentVersionFilePath -Encoding Ascii + if ($? -eq $false) + { Write-Host "[ERROR]: While writing to '$CurrentVersionFilePath'." -ForegroundColor Red + return $true + } return $false } # Invoke-PatchVersionFile @@ -200,19 +209,22 @@ function Restore-PatchedVersionFile ) # construct DirectoryPaths $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - # construct FilePaths $CurrentVersionFilePath = $SourceDirectory + "\" + $VersionFileName $OriginalVersionFilePath = $SourceDirectory + "\" + $VersionFileName + ".bak" Write-Host "Executing build target 'PatchedVersionFile' ..." -ForegroundColor Yellow - if (-not (Test-Path -Path "$CurrentVersionFilePath")) - { Write-Host " Version file '$CurrentVersionFilePath' does not exists." -ForegroundColor Red + if (-not (Test-Path -Path "$OriginalVersionFilePath" -PathType Leaf)) + { Write-Host "[ERROR]: Original version file '$OriginalVersionFilePath' does not exists." -ForegroundColor Red return $true } - if ($Quiet -eq $false) - { Write-Host " Restoring '$CurrentVersionFilePath'." } + -not $Quiet -and (Write-Host " Restoring '$CurrentVersionFilePath'.") | Out-Null Move-Item $OriginalVersionFilePath $CurrentVersionFilePath -Force + if ($? -eq $false) + { Write-Host "[ERROR]: While moving '$OriginalVersionFilePath' to '$CurrentVersionFilePath'." -ForegroundColor Red + return $true + } + return $false } # Restore-PatchedVersionFile @@ -267,13 +279,15 @@ function Invoke-CompileCFiles $Parameters += $SourceDirectory + "\" + $SourceFile.File # call C compiler - $InvokeExpr = "$GCCExecutable " + ($Parameters -join " ") + " 2>&1" + $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) - { return $true } + { Write-Host ("[ERROR]: While compiling '{0}'." -f $SourceFile.File) -ForegroundColor Red + return $true + } } return $false @@ -324,7 +338,7 @@ function Invoke-CompileGHDLAdaFiles # add output filename $Parameters += '-o' - $Parameters += $GHDLExecutableName + $Parameters += $GHDL_Mcode_Name # append linker parameters $Parameters += '-largs' @@ -338,59 +352,18 @@ function Invoke-CompileGHDLAdaFiles # $Parameters += '-Wl,--stack,8404992' # call Ada compiler (GNAT) - $InvokeExpr = "$GNATMakeExecutable " + ($Parameters -join " ") + " 2>&1" + $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 " " - return ($LastExitCode -ne 0) + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: While compiling '$GHDL_Mcode_Name'." -ForegroundColor Red + return $true + } + return $false } # Invoke-CompileGHDLAdaFiles -function Invoke-CompileFilterAdaFiles -{ <# - .SYNOPSIS - This CommandLet compiles all Ada files with GNAT. - .PARAMETER SourceDirectory - The directory where all source files are located. - .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 'CompileFilterAdaFiles' ..." -ForegroundColor Yellow - - $Parameters = @() - $Parameters += Get-CFlags # append common CFlags - $Parameters += '-gnatn' - - # append all source paths - $Parameters += '-aI' + $SourceDirectory + '\..\dist\mcode\windows' - - # top level - $Parameters += 'ghdlfilter' - - # add output filename - $Parameters += '-o' - $Parameters += $FilterExecutable - - # call Ada compiler (GNAT) - $InvokeExpr = "$GNATMakeExecutable " + ($Parameters -join " ") + " 2>&1" - - Write-Host " compiling with GNAT" - Write-Debug " call: $InvokeExpr" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " - return ($LastExitCode -ne 0) -} # Invoke-CompileFilterAdaFiles function Invoke-StripGHDLExecutable { <# @@ -411,10 +384,14 @@ function Invoke-StripGHDLExecutable Write-Host "Executing build target 'StripGHDLExecutable' ..." -ForegroundColor Yellow # call striping tool (strip) - Write-Host " stripping '$GHDLExecutableName'" - Write-Debug " call: $StripExecutable $GHDLExecutableName" - & $StripExecutable $GHDLExecutableName - return ($LastExitCode -ne 0) + 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 @@ -435,31 +412,34 @@ function Test-GHDLVersion Set-Location $BuildDirectory Write-Host "Executing build target 'GHDLVersion' ..." -ForegroundColor Yellow - if (-not (Test-Path -Path $GHDLExecutableName)) - { Write-Host " GHDL executable '$GHDLExecutableName' does not exists." -ForegroundColor Red + 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 = "$GHDLExecutableName --version 2>&1" + $InvokeExpr = "$GHDL_Mcode_Name --version 2>&1" - Write-Host " executing '$GHDLExecutableName'" + Write-Host " executing '$GHDL_Mcode_Name'" Write-Host " call: $InvokeExpr" Write-Host " ----------------------------------------" Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-HostExtended " " Write-Host " ----------------------------------------" - return ($LastExitCode -ne 0) + 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 'Invoke-CreateBuildDirectory' +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-CompileFilterAdaFiles' Export-ModuleMember -Function 'Invoke-StripGHDLExecutable' Export-ModuleMember -Function 'Test-GHDLVersion' diff --git a/libraries/vendors/compile-altera.ps1 b/libraries/vendors/compile-altera.ps1 index e4275e622..e45812538 100644 --- a/libraries/vendors/compile-altera.ps1 +++ b/libraries/vendors/compile-altera.ps1 @@ -103,8 +103,8 @@ param( $WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -ArgumentList "AlteraQuartus" -Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("Altera Quartus", "$WorkingDir") +Import-Module $PSScriptRoot\config.psm1 -Verbose:$false -ArgumentList "AlteraQuartus" +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList @("Altera Quartus", "$WorkingDir") # Display help if no command was selected $Help = $Help -or (-not ($All -or $Altera -or $Max -or $Cyclone -or $Arria -or $Stratix -or $Nanometer)) diff --git a/libraries/vendors/compile-lattice.ps1 b/libraries/vendors/compile-lattice.ps1 index 462685018..c2c6069ca 100644 --- a/libraries/vendors/compile-lattice.ps1 +++ b/libraries/vendors/compile-lattice.ps1 @@ -114,8 +114,8 @@ param( $WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -ArgumentList "LatticeDiamond" -Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("Lattice Diamond", "$WorkingDir") +Import-Module $PSScriptRoot\config.psm1 -Verbose:$false -ArgumentList "LatticeDiamond" +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList @("Lattice Diamond", "$WorkingDir") # Display help if no command was selected $Help = $Help -or (-not ($All -or diff --git a/libraries/vendors/compile-osvvm.ps1 b/libraries/vendors/compile-osvvm.ps1 index 470fcf6aa..e732d87ff 100644 --- a/libraries/vendors/compile-osvvm.ps1 +++ b/libraries/vendors/compile-osvvm.ps1 @@ -72,8 +72,8 @@ param( $WorkingDir = Get-Location
# load modules from GHDL's 'vendors' library directory
-Import-Module $PSScriptRoot\config.psm1 -ArgumentList "OSVVM"
-Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("OSVVM", "$WorkingDir")
+Import-Module $PSScriptRoot\config.psm1 -Verbose:$false -ArgumentList "OSVVM"
+Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList @("OSVVM", "$WorkingDir")
# Display help if no command was selected
$Help = $Help -or (-not ($All -or $OSVVM))
diff --git a/libraries/vendors/compile-vunit.ps1 b/libraries/vendors/compile-vunit.ps1 index 75bf97cd5..f17d151f8 100644 --- a/libraries/vendors/compile-vunit.ps1 +++ b/libraries/vendors/compile-vunit.ps1 @@ -72,8 +72,8 @@ param( $WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -ArgumentList "VUnit" -Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("VUnit", "$WorkingDir") +Import-Module $PSScriptRoot\config.psm1 -Verbose:$false -ArgumentList "VUnit" +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList @("VUnit", "$WorkingDir") # Display help if no command was selected $Help = $Help -or (-not ($All -or $VUnit)) diff --git a/libraries/vendors/compile-xilinx-ise.ps1 b/libraries/vendors/compile-xilinx-ise.ps1 index fce3de9e3..1e47ea9fe 100644 --- a/libraries/vendors/compile-xilinx-ise.ps1 +++ b/libraries/vendors/compile-xilinx-ise.ps1 @@ -95,8 +95,8 @@ if ($Help) $WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -ArgumentList "XilinxISE" -Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("Xilinx ISE", "$WorkingDir") +Import-Module $PSScriptRoot\config.psm1 -Verbose:$false -ArgumentList "XilinxISE" +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList @("Xilinx ISE", "$WorkingDir") # Display help if no command was selected $Help = $Help -or (-not ($All -or $Unisim -or $Simprim -or $Unimacro)) diff --git a/libraries/vendors/compile-xilinx-vivado.ps1 b/libraries/vendors/compile-xilinx-vivado.ps1 index ff135315e..63ab5be76 100644 --- a/libraries/vendors/compile-xilinx-vivado.ps1 +++ b/libraries/vendors/compile-xilinx-vivado.ps1 @@ -86,8 +86,8 @@ param( $WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -ArgumentList "XilinxVivado" -Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("Xilinx Vivado", "$WorkingDir") +Import-Module $PSScriptRoot\config.psm1 -Verbose:$false -ArgumentList "XilinxVivado" +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList @("Xilinx Vivado", "$WorkingDir") # Display help if no command was selected $Help = $Help -or (-not ($All -or $Unisim -or $Simprim -or $Unimacro)) diff --git a/libraries/vendors/shared.psm1 b/libraries/vendors/shared.psm1 index 52dd206da..c15439fdf 100644 --- a/libraries/vendors/shared.psm1 +++ b/libraries/vendors/shared.psm1 @@ -3,11 +3,11 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== +# Authors: Patrick Lehmann +# # PowerShell Module: The module provides common CmdLets for the library # pre-compilation process. # -# Authors: Patrick Lehmann -# # Description: # ------------------------------------ # This PowerShell module provides CommandLets (CmdLets) to handle the GHDL.exe @@ -60,8 +60,8 @@ function Exit-CompileScript cd $Module_WorkingDir # unload modules - Remove-Module config - Remove-Module shared + Remove-Module config -Verbose:$false + Remove-Module shared -Verbose:$false if ($ExitCode -eq 0) { exit 0 } @@ -201,7 +201,7 @@ function Get-VHDLVariables elseif ($VHDL2008) { $VHDLVersion = "v08" $VHDLStandard = "08" - $VHDLFlavor = "standard" + $VHDLFlavor = "synopsys" } else { $VHDLVersion = "v93" @@ -275,8 +275,9 @@ function Start-PackageCompilation Write-Host "Compiling library '$Library' ..." -ForegroundColor Yellow $ErrorCount = 0 foreach ($File in $SourceFiles) - { Write-Host "Analyzing package file '$File'" -ForegroundColor Cyan + { Write-Host "Analyzing package file '$File'" -ForegroundColor DarkCyan $InvokeExpr = "$GHDLBinary " + ($GHDLOptions -join " ") + " --work=$Library " + $File + " 2>&1" + # Write-Host " $InvokeExpr" -ForegroundColor DarkGray $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings if ($LastExitCode -ne 0) { $ErrorCount += 1 @@ -325,8 +326,9 @@ function Start-PrimitiveCompilation Write-Host "Compiling library '$Library' ..." -ForegroundColor Yellow $ErrorCount = 0 foreach ($File in $SourceFiles) - { Write-Host "Analyzing primitive file '$File'" -ForegroundColor Cyan + { Write-Host "Analyzing primitive file '$File'" -ForegroundColor DarkCyan $InvokeExpr = "$GHDLBinary " + ($GHDLOptions -join " ") + " --work=$Library " + $File + " 2>&1" + # Write-Host " $InvokeExpr" -ForegroundColor DarkGray $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings if ($LastExitCode -ne 0) { $ErrorCount += 1 |