forked from ni/labview-icon-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild_lvlibp.ps1
More file actions
149 lines (128 loc) · 4.37 KB
/
Copy pathBuild_lvlibp.ps1
File metadata and controls
149 lines (128 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<#
.SYNOPSIS
Builds the Editor Packed Library (.lvlibp) using g-cli.
.DESCRIPTION
Invokes the LabVIEW build specification "Editor Packed Library" through
g-cli, embedding the provided version information and commit identifier.
.PARAMETER LabVIEWVersion
LabVIEW version year (e.g., 2021) or numeric version (e.g., 21.0).
Alias: MinimumSupportedLVVersion.
.PARAMETER SupportedBitness
Bitness of the LabVIEW environment ("32" or "64").
.PARAMETER RepoRoot
Path to the repository root where the project file resides.
.PARAMETER Major
Major version component for the PPL.
.PARAMETER Minor
Minor version component for the PPL.
.PARAMETER Patch
Patch version component for the PPL.
.PARAMETER Build
Build number component for the PPL.
.PARAMETER Commit
Commit hash or identifier recorded in the build.
.EXAMPLE
.\Build_lvlibp.ps1 -LabVIEWVersion "2021" -SupportedBitness "64" -RepoRoot "C:\labview-icon-editor" -Major 1 -Minor 0 -Patch 0 -Build 0 -Commit "Placeholder"
#>
param(
[Alias('MinimumSupportedLVVersion')]
[AllowNull()]
[AllowEmptyString()]
[string]$LabVIEWVersion = '2021',
[string]$SupportedBitness,
[string]$RepoRoot,
[string]$WorktreeRoot,
[switch]$SkipWorktreeRootCheck,
[Int32]$Major,
[Int32]$Minor,
[Int32]$Patch,
[Int32]$Build,
[string]$Commit,
[ValidateRange(0, 600000)]
[int]$ConnectTimeoutMs = 0
)
Write-Output "PPL Version: $Major.$Minor.$Patch.$Build"
Write-Output "Commit: $Commit"
$resolvedRepoRoot = $RepoRoot
if ($resolvedRepoRoot) {
$resolvedRepoRoot = (Resolve-Path -Path $resolvedRepoRoot -ErrorAction Stop).Path
$RepoRoot = $resolvedRepoRoot
$preflightScript = Join-Path -Path $resolvedRepoRoot -ChildPath 'Tooling\Invoke-Preflight.ps1'
if (Test-Path -Path $preflightScript) {
. $preflightScript
$scriptArgs = Convert-BoundParametersToArgumentList -BoundParameters $PSBoundParameters
$relativeScript = if ($PSCommandPath) { Get-RepoRelativePath -RepoRoot $resolvedRepoRoot -Path $PSCommandPath } else { $null }
$preflight = Invoke-Preflight `
-RepoRoot $resolvedRepoRoot `
-WorktreeRoot $WorktreeRoot `
-LabVIEWVersion $LabVIEWVersion `
-LabVIEWBitness $SupportedBitness `
-SkipWorktreeRootCheck:$SkipWorktreeRootCheck `
-AutoWorktree:$false `
-ScriptPath $relativeScript `
-ScriptArguments $scriptArgs
if ($preflight.Reinvoked) {
return
}
$resolvedRepoRoot = $preflight.RepoRoot
$RepoRoot = $resolvedRepoRoot
}
}
$labviewYear = $LabVIEWVersion
if ($RepoRoot) {
$versionHelper = Join-Path -Path $RepoRoot -ChildPath 'Tooling\support\LabVIEWVersion.ps1'
if (Test-Path -Path $versionHelper) {
. $versionHelper
$versionInfo = Get-LabVIEWVersionInfo -VersionInput $LabVIEWVersion -RepoRoot $RepoRoot
$labviewYear = $versionInfo.Year
}
}
if ([string]::IsNullOrWhiteSpace($labviewYear)) {
$labviewYear = '2021'
}
function Invoke-CloseLabVIEWSafely {
param(
[string]$Version,
[string]$Bitness
)
$closeScript = Join-Path -Path $RepoRoot -ChildPath '.github\actions\close-labview\Close_LabVIEW.ps1'
if (Test-Path -Path $closeScript) {
try {
& $closeScript -LabVIEWVersion $Version -SupportedBitness $Bitness | Out-Null
} catch {
Write-Warning ("Close_LabVIEW.ps1 failed: {0}" -f $_.Exception.Message)
}
return
}
try {
& g-cli --lv-ver $Version --arch $Bitness QuitLabVIEW | Out-Null
} catch {
Write-Warning ("Failed to close LabVIEW: {0}" -f $_.Exception.Message)
}
}
$gcliArgs = @(
'--lv-ver', $labviewYear,
'--arch', $SupportedBitness
)
if ($ConnectTimeoutMs -gt 0) {
$gcliArgs += @('--connect-timeout', $ConnectTimeoutMs)
}
$gcliArgs += @(
'lvbuildspec',
'--',
'-v', "$Major.$Minor.$Patch.$Build",
'-p', "$RepoRoot\lv_icon_editor.lvproj",
'-b', 'Editor Packed Library'
)
Write-Output "Executing the following command:"
Write-Output ("g-cli {0}" -f ($gcliArgs -join ' '))
& g-cli @gcliArgs
# Check the exit code
if ($LASTEXITCODE -ne 0) {
Invoke-CloseLabVIEWSafely -Version $labviewYear -Bitness $SupportedBitness
Write-Host "Build failed with exit code $LASTEXITCODE."
exit 1
} else {
Write-Host "Build succeeded."
exit 0
}