diff options
author | Patrick Lehmann <Patrick.Lehmann@tu-dresden.de> | 2016-10-23 21:39:07 +0200 |
---|---|---|
committer | Patrick Lehmann <Patrick.Lehmann@tu-dresden.de> | 2016-10-23 21:59:45 +0200 |
commit | 97f4808fb4337065ad2a21d63e3d5bad3e03500c (patch) | |
tree | 3d6531e2b35adea7c4e0972dcc10ff99fe825200 /dist/mcode | |
parent | de1c213c36101c80f961f2ba24d4188646de8cb5 (diff) | |
download | ghdl-97f4808fb4337065ad2a21d63e3d5bad3e03500c.tar.gz ghdl-97f4808fb4337065ad2a21d63e3d5bad3e03500c.tar.bz2 ghdl-97f4808fb4337065ad2a21d63e3d5bad3e03500c.zip |
Fixed windows build flow.
Diffstat (limited to 'dist/mcode')
-rw-r--r-- | dist/mcode/winbuild.ps1 | 108 | ||||
-rw-r--r-- | dist/mcode/windows/compile-ghdl.ps1 | 9 | ||||
-rw-r--r-- | dist/mcode/windows/compile-libraries.ps1 | 2 | ||||
-rw-r--r-- | dist/mcode/windows/targets.psm1 | 62 |
4 files changed, 94 insertions, 87 deletions
diff --git a/dist/mcode/winbuild.ps1 b/dist/mcode/winbuild.ps1 index cccb2824d..e18213a11 100644 --- a/dist/mcode/winbuild.ps1 +++ b/dist/mcode/winbuild.ps1 @@ -147,7 +147,8 @@ if ($Compile) $GHDLVersion = Get-GHDLVersion $GHDLRootDir
$Backend = "mcode"
$WindowsDirName = "dist\$Backend\windows"
-$BuildDirectoryName = "build\$Backend"
+$BuildDirectoryName = "build"
+$BuildBackendDirectoryName = "$BuildDirectoryName\$Backend"
$VHDLLibrariesDirectoryName = "lib"
$PackageDirectoryName = "build\zip\$Backend"
$ZipPackageFileName = "ghdl-$Backend-$GHDLVersion.zip"
@@ -155,14 +156,14 @@ $DefaultInstallPath = "C:\Program Files (x86)\GHDL" # This is the default # construct directories
$GHDLWindowsDir = "$GHDLRootDir\$WindowsDirName"
-$GHDLBuildDir = "$GHDLRootDir\$BuildDirectoryName"
+$GHDLBuildDir = "$GHDLRootDir\$BuildBackendDirectoryName"
$GHDLVendorLibraryDir = "$GHDLRootDir\libraries\vendors"
-$GHDLCompiledLibraryDir = "$GHDLRootDir\$BuildDirectoryName\$VHDLLibrariesDirectoryName"
+$GHDLCompiledLibraryDir = "$GHDLRootDir\$BuildBackendDirectoryName\$VHDLLibrariesDirectoryName"
$GHDLZipPackageDir = "$GHDLRootDir\$PackageDirectoryName"
$GHDLZipPackageFile = "$GHDLZipPackageDir\$ZipPackageFileName"
# construct files
-$InstallDirFile = "$GHDLBuildDir\InstallDir.conf"
+$InstallDirFile = "$BuildDirectoryName\InstallDir.conf"
$EnvPath_ContainerMapping = @{
Machine = [EnvironmentVariableTarget]::Machine
@@ -291,7 +292,10 @@ else }
} # Clean_GHDL
if ($Clean_Libraries)
- { $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1"
+ { if ($Clean_GHDL)
+ { Write-Host }
+
+ $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1"
$Script_Parameters = @(
'-Clean',
'-Hosted',
@@ -316,7 +320,12 @@ else }
} # Clean_Libraries
if ($Clean_Package_Zip)
- { Write-Host "Removing installer packages and temporary directories..."
+ { if ($Clean_GHDL -or $Clean_Libraries)
+ { Write-Host }
+
+ Write-Host "Running more clean-up tasks..." -ForegroundColor DarkCyan
+ Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan
+ Write-Host "Removing installer packages and temporary directories..." -ForegroundColor Yellow
if (Test-Path -Path $GHDLZipPackageDir)
{ Write-Host " rmdir $GHDLZipPackageDir"
Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue
@@ -345,16 +354,22 @@ else # Compile tasks
# ============================================================================
if ($Compile_GHDL)
- { Write-Host "Compiling GHDL $GHDLVersion for Windows..."
+ { if ($Clean)
+ { Write-Host }
$Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1"
$Script_Parameters = @()
$Script_Parameters = @(
'-All',
+ '-Hosted',
'-Verbose:$EnableVerbose',
'-Debug:$EnableDebug'
)
-
+
+ # Write-Host "Compiling GHDL $GHDLVersion for Windows..." -ForegroundColor DarkCyan
+ # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan
+
+ Write-Host
Write-Host "Running compile-ghdl.ps1 -All ..." -ForegroundColor DarkCyan
Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan
$InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ")
@@ -372,19 +387,25 @@ else }
} # Compile_GHDL
if ($Compile_Libraries)
- { Write-Host "Compiling GHDL's libraries ..."
-
+ { if ($Compile_GHDL)
+ { Write-Host }
+
$Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1"
$Script_Parameters = @()
$Script_Parameters = @(
'-Compile',
+ '-Hosted',
'-Verbose:$EnableVerbose',
'-Debug:$EnableDebug'
)
- $env:GHDL = "$GHDLBuildDir\ghdl.exe"
- Write-Host "env:GHDL --" + $env:GHDL + "--"
+ # Write-Host "Compiling GHDL's libraries ..." -ForegroundColor DarkCyan
+ # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan
+ $env:GHDL = "$GHDLBuildDir\ghdl.exe"
+ Write-Host ("Setting env:GHDL to '" + $env:GHDL + "'")
+
+ Write-Host
Write-Host "Running compile-libraries.ps1 -Compile ..." -ForegroundColor DarkCyan
Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan
$InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ")
@@ -471,7 +492,7 @@ else # ============================================================================
# Compile tasks
# ============================================================================
- if ($Install -eq $true)
+ if ($Install)
{ Write-Host "Installing GHDL $GHDLVersion for Windows..."
if ($InstallDir -eq "")
{ if (Test-Path $InstallDirFile -PathType Leaf)
@@ -525,15 +546,30 @@ else # pre-compiled libraries
Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue
- Write-Host "Install GHDL in PATH at machine level? " -NoNewline -ForegroundColor DarkCyan
- Write-Host "[Y/n]" -NoNewline -ForegroundColor Cyan
- Write-Host ":" -NoNewline -ForegroundColor DarkCyan
+ Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "M" -NoNewline -ForegroundColor Cyan
+ Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "u" -NoNewline -ForegroundColor Cyan
+ Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "s" -NoNewline -ForegroundColor Cyan
+ Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "n" -NoNewline -ForegroundColor Cyan
+ Write-Host "o]: " -NoNewline -ForegroundColor DarkCyan
$InstallInPath = (Read-Host).ToLower()
- if (($InstallInPath -eq "") -or ($InstallInPath -eq "y"))
+ if (($InstallInPath -eq "") -or ($InstallInPath -eq "m"))
{ Write-Host " Adding GHDL to PATH at machine level."
Add-EnvPath -Path "$InstallPath\bin" -Container "Machine"
Add-EnvPath -Path "$InstallPath\bin" -Container "Session"
}
+ elseif ($InstallInPath -eq "u")
+ { Write-Host " Adding GHDL to PATH at user level."
+ Add-EnvPath -Path "$InstallPath\bin" -Container "User"
+ Add-EnvPath -Path "$InstallPath\bin" -Container "Session"
+ }
+ elseif ($InstallInPath -eq "s")
+ { Write-Host " Adding GHDL to PATH at session level."
+ Add-EnvPath -Path "$InstallPath\bin" -Container "Session"
+ }
Write-Host
Write-Host "Installing files " -NoNewline
@@ -543,7 +579,7 @@ else Exit-Script
} # Zip
} # Install
- elseif ($Update -eq $true)
+ elseif ($Update)
{ Write-Host "Updating GHDL $GHDLVersion for Windows..."
if (Test-Path $InstallDirFile -PathType Leaf)
{ Write-Host " Reading installation path from '$InstallDirFile' ..."
@@ -556,22 +592,21 @@ else Write-Host " Install directory: $InstallPath"
if (Test-Path -Path $InstallPath)
{ Write-Host " Cleaning up installation directory '$InstallPath'." -ForegroundColor Yellow
- Get-ChildItem -Path $InstallPath -Depth 0 | foreach { Remove-Item $_ -ErrorAction SilentlyContinue }
+ Get-ChildItem -Path $InstallPath -Depth 0 | foreach { Remove-Item $_ -Recurse -ErrorAction SilentlyContinue }
}
- Write-Host " Removing GHDL from PATH variables in Machine, User..." -ForegroundColor Yellow
+ Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow
foreach ($container in @("Machine", "User"))
{ foreach ($entry in (Get-EnvPath -Container $container))
{ if ($entry.ToLower().Contains("ghdl"))
{ Write-Host " Removing '$entry' from $container level."
Remove-EnvPath -Path $entry -Container $container
- Remove-EnvPath -Path $entry -Container "Session"
}
}
}
+ Remove-EnvPath -Path $entry -Container "Session"
Write-Host " Creating directory sub-directories in '$InstallPath' ..."
- # 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
@@ -586,15 +621,30 @@ else # pre-compiled libraries
Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue
- Write-Host "Install GHDL in PATH at machine level? " -NoNewline -ForegroundColor DarkCyan
- Write-Host "[Y/n]" -NoNewline -ForegroundColor Cyan
- Write-Host ":" -NoNewline -ForegroundColor DarkCyan
+ Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "M" -NoNewline -ForegroundColor Cyan
+ Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "u" -NoNewline -ForegroundColor Cyan
+ Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "s" -NoNewline -ForegroundColor Cyan
+ Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan
+ Write-Host "n" -NoNewline -ForegroundColor Cyan
+ Write-Host "o]: " -NoNewline -ForegroundColor DarkCyan
$InstallInPath = (Read-Host).ToLower()
- if (($InstallInPath -eq "") -or ($InstallInPath -eq "y"))
+ if (($InstallInPath -eq "") -or ($InstallInPath -eq "m"))
{ Write-Host " Adding GHDL to PATH at machine level."
Add-EnvPath -Path "$InstallPath\bin" -Container "Machine"
Add-EnvPath -Path "$InstallPath\bin" -Container "Session"
}
+ elseif ($InstallInPath -eq "u")
+ { Write-Host " Adding GHDL to PATH at user level."
+ Add-EnvPath -Path "$InstallPath\bin" -Container "User"
+ Add-EnvPath -Path "$InstallPath\bin" -Container "Session"
+ }
+ elseif ($InstallInPath -eq "s")
+ { Write-Host " Adding GHDL to PATH at session level."
+ Add-EnvPath -Path "$InstallPath\bin" -Container "Session"
+ }
Write-Host
Write-Host "Updating files " -NoNewline
@@ -603,7 +653,7 @@ else Exit-Script
} # Update
- elseif ($Uninstall -eq $true)
+ elseif ($Uninstall)
{ Write-Host "Uninstalling GHDL $GHDLVersion for Windows..."
if (Test-Path $InstallDirFile -PathType Leaf)
{ Write-Host " Reading installation path from '$InstallDirFile' ..."
@@ -618,16 +668,16 @@ else Remove-Item $InstallPath -Recurse -ErrorAction SilentlyContinue
}
- Write-Host " Removing GHDL from PATH variables in Machine, User..." -ForegroundColor Yellow
+ Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow
foreach ($container in @("Machine", "User"))
{ foreach ($entry in (Get-EnvPath -Container $container))
{ if ($entry.ToLower().Contains("ghdl"))
{ Write-Host " Removing '$entry' from $container level."
Remove-EnvPath -Path $entry -Container $container
- Remove-EnvPath -Path $entry -Container "Session"
}
}
}
+ Remove-EnvPath -Path $entry -Container "Session"
Write-Host
Write-Host "Uninstalling files " -NoNewline
diff --git a/dist/mcode/windows/compile-ghdl.ps1 b/dist/mcode/windows/compile-ghdl.ps1 index 51fd0a1d5..2938683db 100644 --- a/dist/mcode/windows/compile-ghdl.ps1 +++ b/dist/mcode/windows/compile-ghdl.ps1 @@ -228,15 +228,6 @@ if ($Compile_GHDL) { Write-Host " [FAILED]" -ForegroundColor Red Exit-CompileScript -1 } - - # restore the version file if it was patched - if (-not $Release -and $Git_IsGitRepo) - { $error = Restore-PatchedVersionFile $GHDLRootDir - if ($error -eq $true) - { Write-Host " [FAILED]" -ForegroundColor Red - Exit-CompileScript -1 - } - } } diff --git a/dist/mcode/windows/compile-libraries.ps1 b/dist/mcode/windows/compile-libraries.ps1 index 8a7ce2d4a..597c7f237 100644 --- a/dist/mcode/windows/compile-libraries.ps1 +++ b/dist/mcode/windows/compile-libraries.ps1 @@ -187,7 +187,7 @@ if (-not $Hosted) } if ($Clean) -{ Write-Host "Removing all created files and directories..." +{ Write-Host "Removing all created files and directories..." -ForegroundColor Yellow if (Test-Path -Path $VHDLDestinationLibraryDirectory) { $EnableVerbose -and (Write-Host " rmdir $VHDLDestinationLibraryDirectory") | Out-Null Remove-Item $VHDLDestinationLibraryDirectory -Force -Recurse -ErrorAction SilentlyContinue diff --git a/dist/mcode/windows/targets.psm1 b/dist/mcode/windows/targets.psm1 index 5dfd12b0b..813873482 100644 --- a/dist/mcode/windows/targets.psm1 +++ b/dist/mcode/windows/targets.psm1 @@ -49,7 +49,8 @@ $WinMcodeSourceDirName = "dist\mcode\windows" # $WinLLVMSourceDirName = "dist\llvm\windows" # construct file paths -$VersionFileName = "version.ads" +$VersionFileName_In = "version.in" +$VersionFileName_Ads = "version.ads" function Invoke-Clean @@ -126,7 +127,7 @@ function Get-GHDLVersion ) # construct DirectoryPaths $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - $VersionFilePath = $SourceDirectory + "\" + $VersionFileName + $VersionFilePath = $SourceDirectory + "\" + $VersionFileName_In if (-not (Test-Path -Path $VersionFilePath -PathType Leaf)) { Write-Host "[ERROR]: Version file '$VersionFilePath' does not exists." -ForegroundColor Red @@ -165,68 +166,33 @@ function Invoke-PatchVersionFile [switch] $Quiet = $false ) # construct DirectoryPaths - $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - $CurrentVersionFilePath = $SourceDirectory + "\" + $VersionFileName - $OriginalVersionFilePath = $SourceDirectory + "\" + $VersionFileName + ".bak" + $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + $VersionInputFilePath = $SourceDirectory + "\" + $VersionFileName_In + $VersionFilePath = $SourceDirectory + "\" + $VersionFileName_Ads Write-Host "Executing build target 'PatchVersionFile' ..." -ForegroundColor Yellow - if (-not (Test-Path -Path $CurrentVersionFilePath -PathType Leaf)) - { Write-Host "[ERROR]: Version file '$CurrentVersionFilePath' does not exists." -ForegroundColor Red + if (-not (Test-Path -Path $VersionInputFilePath -PathType Leaf)) + { Write-Host "[ERROR]: Version file '$VersionInputFilePath' does not exists." -ForegroundColor Red return $true } - -not $Quiet -and (Write-Host " Patching '$CurrentVersionFilePath'.") | Out-Null - $FileContent = Get-Content -Path $CurrentVersionFilePath -Encoding Ascii + -not $Quiet -and (Write-Host " Patching '$VersionInputFilePath'.") | Out-Null + $FileContent = Get-Content -Path $VersionInputFilePath -Encoding Ascii if ($? -eq $false) - { Write-Host "[ERROR]: While opening '$CurrentVersionFilePath'." -ForegroundColor Red + { Write-Host "[ERROR]: While opening '$VersionInputFilePath'." -ForegroundColor Red return $true } - $FileContent = $FileContent -Replace "\s\(\d+\)\s", " (commit: $GitCommitDataString; git branch: $GitBranchName'; hash: $GitCommitHash) " + $FileContent = $FileContent -Replace "\s\(tarball\)\s", " (commit: $GitCommitDataString; git branch: $GitBranchName'; hash: $GitCommitHash) " - Move-Item $CurrentVersionFilePath $OriginalVersionFilePath -Force - $FileContent | Out-File $CurrentVersionFilePath -Encoding Ascii + $FileContent | Out-File $VersionFilePath -Encoding Ascii if ($? -eq $false) - { Write-Host "[ERROR]: While writing to '$CurrentVersionFilePath'." -ForegroundColor Red + { Write-Host "[ERROR]: While writing to '$VersionFilePath'." -ForegroundColor Red return $true } return $false } # Invoke-PatchVersionFile -function Restore-PatchedVersionFile -{ <# - .SYNOPSIS - This CommandLet restores the original version file. - .PARAMETER GHDLRootDir - The repository root directory. - .PARAMETER Quiet - Disable outputs to the host console. - #> - [CmdletBinding()] - param( - [string] $GHDLRootDir, - [switch] $Quiet = $false - ) - # construct DirectoryPaths - $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName - $CurrentVersionFilePath = $SourceDirectory + "\" + $VersionFileName - $OriginalVersionFilePath = $SourceDirectory + "\" + $VersionFileName + ".bak" - - Write-Host "Executing build target 'PatchedVersionFile' ..." -ForegroundColor Yellow - - if (-not (Test-Path -Path "$OriginalVersionFilePath" -PathType Leaf)) - { Write-Host "[ERROR]: Original version file '$OriginalVersionFilePath' does not exists." -ForegroundColor Red - return $true - } - -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 function Get-CFlags { <# |