Skip to content

Commit

Permalink
fix github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
theavege committed Dec 19, 2024
1 parent 6857faa commit 36fff1c
Show file tree
Hide file tree
Showing 7 changed files with 392 additions and 80 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- master
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -21,12 +22,19 @@ jobs:
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Build on Linux
if: runner.os == 'Linux'
shell: bash
run: bash -x make.sh all
run: bash -x make.sh build

- name: Build on Windows
if: runner.os == 'Windows'
shell: powershell
run: pwsh -File make.ps1 build
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use/*/
**/backup/
**/lib/
*.res
*.dbg
*.lps
*.compiled
*.o
*.or
*.so
*.ppu
*.exe
*.compiled
*.obj
*.a
**/backup/

104 changes: 104 additions & 0 deletions make.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/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 = @{
Use = 'use'
Cmd = 'lazbuild'
Url = 'https://fossies.org/windows/misc/lazarus-3.6-fpc-3.2.2-win64.exe'
Path = "C:\Lazarus"
}
Try {
Get-Command $VAR.Cmd
} Catch {
"Install $($VAR.Path)" | Out-Host
Request-File $VAR.Url | Install-Program
$env:PATH+=";$($VAR.Path)"
Get-Command $VAR.Cmd
}
If (Test-Path -Path $($VAR.Use)) {
& git submodule update --init --recursive --force --remote | Out-Host
$COMPONENTS = "$($VAR.Use)\components.txt"
If (Test-Path -Path $COMPONENTS) {
'Download packages:' | Out-Host
Get-Content -Path $COMPONENTS | ForEach-Object {
If ((! (& $VAR.Cmd --verbose-pkgsearch $_ )) &&
(! (& $VAR.Cmd --add-package $_)) &&
(! (Test-Path -Path "$($VAR.Use)\$($_)"))) {
" download package $($_)" | Out-Host
$OutFile = Request-File "https://packages.lazarus-ide.org/$($_).zip"
Expand-Archive -Path $OutFile -DestinationPath "$($VAR.Use)\$($_)" -Force
Remove-Item $OutFile
}
}
}
'Add dependencies:' | Out-Host
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use'| Sort-Object | ForEach-Object {
" add dependence $($_)" | Out-Host
& $VAR.Cmd --add-package-link $_ | Out-Host
}
}
'Build projects:' | Out-Host
Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'peazip-sources'| Sort-Object | ForEach-Object {
" build project $($_)" | Out-Host
If (& $VAR.Cmd --no-write-project --recursive $_) {
& $VAR.Cmd --no-write-project --recursive $_ | Out-Host
Throw "Error!!!"
}
}
"Done!" | 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
61 changes: 47 additions & 14 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,66 @@ Options:
EOF
)

function priv_main
function priv_lazbuild
(
set -eo pipefail
if !(which lazbuild); then
if ! (which lazbuild); then
source '/etc/os-release'
case ${ID:?} in
debian | ubuntu)
printf '\x1b[32mInstall Lazarus\x1b[0m\n' 1>&2
sudo apt-get update
sudo apt-get install -y lazarus
sudo apt-get install -y lazarus{-ide-qt5,}
;;
esac
fi
declare -r COMPONENTS='use/components.txt'
if [[ -d "${COMPONENTS%%/*}" ]]; then
git submodule update --init --recursive --force --remote
if [[ -f "${COMPONENTS}" ]]; then
printf '\x1b[32mDownwoad packages\x1b[0m\n' 1>&2
while read -r; do
if [[ -n "${REPLY}" ]] &&
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
! (lazbuild --add-package "${REPLY}") &&
! [[ -d "${COMPONENTS%%/*}/${REPLY}" ]]; then
printf '\x1b[32m\tdownwoad package %s\x1b[0m\n' "${REPLY}" 1>&2
declare -A VAR=(
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
[out]=$(mktemp)
)
wget --output-document "${VAR[out]}" "${VAR[url]}" >/dev/null
unzip -o "${VAR[out]}" -d "${COMPONENTS%%/*}/${REPLY}"
rm --verbose "${VAR[out]}"
fi
done < "${COMPONENTS}"
fi
printf '\x1b[32mAdd dependencies\x1b[0m\n' 1>&2
while read -r; do
printf '\x1b[32m\tadd dependence %s\x1b[0m\n' "${REPLY}" 1>&2
lazbuild --add-package "${REPLY}" ||
lazbuild --add-package-link "${REPLY}"
done < <(find "${COMPONENTS%%/*}" -type 'f' -name '*.lpk' | sort)
fi
printf '\x1b[32mBuild projects\x1b[0m\n' 1>&2
while read -r; do
printf '\x1b[32m\tbuild project %s\x1b[0m\n' "${REPLY}" 1>&2
if ! (lazbuild --no-write-project --recursive --no-write-project --widgetset=qt5 --build-mode=release "${REPLY}"); then
lazbuild --no-write-project --recursive --no-write-project --widgetset=qt5 --build-mode=release "${REPLY}" 1>&2
fi
done < <(find 'peazip-sources' -type 'f' -name '*.lpi' | sort)
)

function priv_main
(
set -euo pipefail
if ((${#})); then
case ${1} in
build) pub_build ;;
build) priv_lazbuild ;;
*) priv_clippit ;;
esac
else
priv_clippit
fi
)

function pub_build
(
git submodule update --init --recursive --force --remote
lazbuild --add-package-link 'use/metadarkstyle/metadarkstyle.lpk'
lazbuild --no-write-project --recursive --no-write-project --widgetset=qt5 'peazip-sources/dev/project_peach.lpi'
lazbuild --no-write-project --recursive --no-write-project --widgetset=qt5 'peazip-sources/dev/project_pea.lpi'
)

priv_main "${@}"
priv_main "${@}" >/dev/null
Loading

0 comments on commit 36fff1c

Please sign in to comment.