Skip to content

Commit 3c53e00

Browse files
committed
fix make files
1 parent 605e671 commit 3c53e00

File tree

2 files changed

+34
-39
lines changed

2 files changed

+34
-39
lines changed

make.ps1

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env pwsh
22
##############################################################################################################
33

4-
Function PrivClipper {
4+
Function Show-Usage {
55
Return "
66
Usage: pwsh -File $($PSCommandPath) [OPTIONS]
77
Options:
88
build Build program
99
"
1010
}
1111

12-
Function PrivWget {
12+
Function Request-File {
1313
ForEach ($REPLY in $args) {
1414
$params = @{
1515
Uri = $REPLY
@@ -20,77 +20,71 @@ Function PrivWget {
2020
}
2121
}
2222

23-
Function PrivMsiexec {
23+
Function Install-Program {
2424
While ($Input.MoveNext()) {
25-
$params = @{}
2625
Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) {
2726
'msi' {
28-
$params = @{
29-
FilePath = 'msiexec'
30-
ArgumentList = '/passive', '/package', $Input.Current
31-
}
27+
& msiexec /passive /package $Input.Current | Out-Host
3228
}
3329
'exe' {
34-
$params = @{
35-
FilePath = $Input.Current
36-
ArgumentList = '/SP-', '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART'
37-
}
30+
& ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Host
3831
}
3932
}
40-
Start-Process -PassThru -Wait @params
4133
Remove-Item $Input.Current
4234
}
4335
}
4436

45-
Function PrivLazBuild {
37+
Function Build-Project {
4638
$VAR = @{
4739
Cmd = 'lazbuild'
4840
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'
4941
Path = "C:\Lazarus"
5042
}
51-
If (-not (Get-Command $VAR.Cmd -ea 'continue')) {
52-
PrivWget $VAR.Url | PrivMsiexec
43+
Try {
44+
Get-Command $VAR.Cmd
45+
} Catch {
46+
Request-File $VAR.Url | Install-Program
5347
$env:PATH+=";$($VAR.Path)"
5448
Get-Command $VAR.Cmd
5549
}
5650
If ( Test-Path -Path 'use\components.txt' ) {
57-
Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--init'
58-
Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--remote'
51+
& git submodule update --recursive --init | Out-Host
52+
& git submodule update --recursive --remote | Out-Host
5953
Get-Content -Path 'use\components.txt' | ForEach-Object {
60-
If ((-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--verbose-pkgsearch', $_)) -and
61-
(-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--add-package', $_)) -and
54+
If ((-not (& lazbuild --verbose-pkgsearch $_ | Out-Null)) -and
55+
(-not (& lazbuild --add-package $_ | Out-Null)) -and
6256
(-not (Test-Path -Path 'use\components.txt'))) {
63-
$OutFile = PrivWget "https://packages.lazarus-ide.org/$($_).zip"
57+
$OutFile = Request-File "https://packages.lazarus-ide.org/$($_).zip"
6458
Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force
6559
Remove-Item $OutFile
66-
}
60+
}
6761
}
6862
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object {
69-
Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--add-package-link', $_.Name
63+
& lazbuild --add-package-link $_ | Out-Host
7064
}
7165
}
7266
Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object {
73-
Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--no-write-project', '--recursive', '--build-mode=release', $_.Name
67+
& lazbuild --no-write-project --recursive --build-mode=release $_ | Out-Host
7468
}
7569
}
7670

77-
Function PrivMain {
71+
Function Switch-Action {
7872
$ErrorActionPreference = 'stop'
7973
Set-PSDebug -Strict -Trace 1
8074
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
8175
If ($args.count -gt 0) {
8276
Switch ($args[0]) {
8377
'build' {
84-
PrivLazBuild
78+
Build-Project
8579
}
8680
Default {
87-
PrivClipper
81+
Show-Usage
8882
}
8983
}
9084
} Else {
91-
PrivClipper
85+
Show-Usage
9286
}
9387
}
9488

9589
##############################################################################################################
96-
PrivMain @args
90+
Switch-Action @args | Out-Null

make.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ function priv_lazbuild
2424
git submodule update --init --recursive
2525
git submodule update --recursive --remote
2626
while read -r; do
27-
if ! (lazbuild --verbose-pkgsearch "${REPLY}") ||
28-
! (lazbuild --add-package "${REPLY}") ||
27+
if [[ -n "${REPLY}" ]] &&
28+
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
29+
! (lazbuild --add-package "${REPLY}") &&
2930
! [[ -f "use/${REPLY}" ]]; then
30-
declare -A VAR=(
31-
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
32-
[out]=$(mktemp)
33-
)
34-
wget --output-document "${VAR[out]}" "${VAR[url]}"
35-
unzip -o "${VAR[out]}" -d "use/${REPLY}"
36-
rm --verbose "${VAR[out]}"
37-
fi
31+
declare -A VAR=(
32+
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
33+
[out]=$(mktemp)
34+
)
35+
wget --output-document "${VAR[out]}" "${VAR[url]}" >/dev/null
36+
unzip -o "${VAR[out]}" -d "use/${REPLY}"
37+
rm --verbose "${VAR[out]}"
38+
fi
3839
done < 'use/components.txt'
3940
find 'use' -type 'f' -name '*.lpk' -exec lazbuild --add-package-link {} +
4041
fi

0 commit comments

Comments
 (0)