Skip to content

Commit bced0a2

Browse files
committed
add make.ps1
1 parent b3c42a6 commit bced0a2

File tree

3 files changed

+131
-9
lines changed

3 files changed

+131
-9
lines changed

.github/workflows/make.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
matrix:
2222
os:
2323
- ubuntu-latest
24+
- windows-latest
2425
steps:
2526
- name: Checkout
2627
uses: actions/checkout@v4
@@ -31,3 +32,8 @@ jobs:
3132
if: runner.os == 'Linux'
3233
shell: bash
3334
run: bash -x make.sh build
35+
36+
- name: Build on Windows
37+
if: runner.os == 'Windows'
38+
shell: powershell
39+
run: pwsh -File make.ps1 build

make.ps1

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env pwsh
2+
##############################################################################################################
3+
4+
Function PrivClipper {
5+
Return "
6+
Usage: pwsh -File $($PSCommandPath) [OPTIONS]
7+
Options:
8+
build Build program
9+
"
10+
}
11+
12+
Function PrivWget {
13+
ForEach ($REPLY in $args) {
14+
$params = @{
15+
Uri = $REPLY
16+
OutFile = (Split-Path -Path $REPLY -Leaf).Split('?')[0]
17+
}
18+
Invoke-WebRequest @params | Out-Null
19+
Return $params.OutFile
20+
}
21+
}
22+
23+
Function PrivMsiexec {
24+
While ($Input.MoveNext()) {
25+
$params = @{}
26+
Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) {
27+
'msi' {
28+
$params = @{
29+
FilePath = 'msiexec'
30+
ArgumentList = '/passive', '/package', $Input.Current
31+
}
32+
}
33+
'exe' {
34+
$params = @{
35+
FilePath = $Input.Current
36+
ArgumentList = '/SP-', '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART'
37+
}
38+
}
39+
}
40+
Start-Process -PassThru -Wait @params
41+
Remove-Item $Input.Current
42+
}
43+
}
44+
45+
Function PrivLazBuild {
46+
$VAR = @{
47+
Cmd = 'lazbuild'
48+
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'
49+
Path = "C:\Lazarus"
50+
}
51+
If (-not (Get-Command $VAR.Cmd -ea 'continue')) {
52+
PrivWget $VAR.Url | PrivMsiexec
53+
$env:PATH+=";$($VAR.Path)"
54+
Get-Command $VAR.Cmd
55+
}
56+
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'
59+
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
62+
(-not (Test-Path -Path 'use\components.txt')) {
63+
$OutFile = PrivWget "https://packages.lazarus-ide.org/$($_).zip"
64+
Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force
65+
Remove-Item $OutFile
66+
}
67+
}
68+
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object {
69+
Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--add-package-link', $_.Name
70+
}
71+
}
72+
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
74+
}
75+
}
76+
77+
Function PrivMain {
78+
$ErrorActionPreference = 'stop'
79+
Set-PSDebug -Strict -Trace 1
80+
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
81+
If ($args.count -gt 0) {
82+
Switch ($args[0]) {
83+
'build' {
84+
PrivLazBuild
85+
}
86+
Default {
87+
PrivClipper
88+
}
89+
}
90+
} Else {
91+
PrivClipper
92+
}
93+
}
94+
95+
##############################################################################################################
96+
PrivMain @args

make.sh

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,46 @@ Options:
99
EOF
1010
)
1111

12-
function pub_build
12+
function priv_lazbuild
1313
(
14-
find 'src' -type 'f' -name '*.lpi' -exec lazbuild --recursive --build-mode=release {} \;
15-
)
16-
17-
function priv_main
18-
(
19-
set -euo pipefail
2014
if ! (which lazbuild); then
2115
source '/etc/os-release'
2216
case ${ID:?} in
2317
debian | ubuntu)
2418
sudo apt-get update
2519
sudo apt-get install -y lazarus
26-
;;
20+
;;
2721
esac
2822
fi
23+
if [[ -f 'use/components.txt' ]]; then
24+
git submodule update --init --recursive
25+
git submodule update --recursive --remote
26+
while read -r; do
27+
if ! (lazbuild --verbose-pkgsearch "${REPLY}") ||
28+
! (lazbuild --add-package "${REPLY}") ||
29+
! [[ -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
38+
done < 'use/components.txt'
39+
find 'use' -type 'f' -name '*.lpk' -exec lazbuild --add-package-link {} +
40+
fi
41+
find 'src' -type 'f' -name '*.lpi' \
42+
-exec lazbuild --no-write-project --recursive --no-write-project --build-mode=release {} + 1>&2
43+
)
44+
45+
function priv_main
46+
(
47+
set -euo pipefail
2948
if ((${#})); then
3049
case ${1} in
31-
build) pub_build 1>&2 ;;
50+
build) priv_lazbuild ;;
51+
*) priv_clippit ;;
3252
esac
3353
else
3454
priv_clippit

0 commit comments

Comments
 (0)