-
Notifications
You must be signed in to change notification settings - Fork 4
/
make.ps1
90 lines (84 loc) · 2.85 KB
/
make.ps1
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
#!/usr/bin/env pwsh
##############################################################################################################
Function Show-Usage {
Return "
Usage: pwsh -File $($PSCommandPath) [OPTIONS]
Options:
build Build program
"
}
Function Request-File {
ForEach ($REPLY in $args) {
$params = @{
Uri = $REPLY
OutFile = (Split-Path -Path $REPLY -Leaf).Split('?')[0]
}
Invoke-WebRequest @params | Out-Null
Return $params.OutFile
}
}
Function Install-Program {
While ($Input.MoveNext()) {
Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) {
'msi' {
& msiexec /passive /package $Input.Current | Out-Host
}
'exe' {
& ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Host
}
}
Remove-Item $Input.Current
}
}
Function Build-Project {
$VAR = @{
Cmd = 'lazbuild'
Url = 'https://netix.dl.sourceforge.net/project/lazarus/Lazarus%20Windows%2064%20bits/Lazarus%203.6/lazarus-3.6-fpc-3.2.2-win64.exe?viasf=1'
Path = "C:\Lazarus"
}
Try {
Get-Command $VAR.Cmd
} Catch {
Request-File $VAR.Url | Install-Program
$env:PATH+=";$($VAR.Path)"
Get-Command $VAR.Cmd
}
If ( Test-Path -Path 'use\components.txt' ) {
& git submodule update --recursive --init | Out-Host
& git submodule update --recursive --remote | Out-Host
Get-Content -Path 'use\components.txt' | ForEach-Object {
If ((-not (& lazbuild --verbose-pkgsearch $_ | Out-Null)) -and
(-not (& lazbuild --add-package $_ | Out-Null)) -and
(-not (Test-Path -Path 'use\components.txt'))) {
$OutFile = Request-File "https://packages.lazarus-ide.org/$($_).zip"
Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force
Remove-Item $OutFile
}
}
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object {
& lazbuild --add-package-link $_ | Out-Host
}
}
Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object {
& lazbuild --no-write-project --recursive --build-mode=release $_ | Out-Host
}
}
Function Switch-Action {
$ErrorActionPreference = 'stop'
Set-PSDebug -Strict -Trace 1
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
If ($args.count -gt 0) {
Switch ($args[0]) {
'build' {
Build-Project
}
Default {
Show-Usage
}
}
} Else {
Show-Usage
}
}
##############################################################################################################
Switch-Action @args | Out-Null