aboutsummaryrefslogtreecommitdiffstats
path: root/dist/mcode/winbuild.ps1
diff options
context:
space:
mode:
Diffstat (limited to 'dist/mcode/winbuild.ps1')
-rw-r--r--dist/mcode/winbuild.ps1705
1 files changed, 369 insertions, 336 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