From 1d94eb277369da04ffabab5118393123cfeb2bc8 Mon Sep 17 00:00:00 2001 From: "Artem V. Ageev" Date: Fri, 27 Dec 2024 17:05:23 +0200 Subject: [PATCH] add github-actions --- .github/dependabot.yml | 7 +++ .github/workflows/make.yml | 42 +++++++++++++ .gitmodules | 3 + make.ps1 | 118 +++++++++++++++++++++++++++++++++++++ make.sh | 84 ++++++++++++++++++++++++++ use/LazMapViewer | 1 + use/components.txt | 3 + 7 files changed, 258 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/make.yml create mode 100644 .gitmodules create mode 100644 make.ps1 create mode 100644 make.sh create mode 160000 use/LazMapViewer create mode 100644 use/components.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..64284b9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml new file mode 100644 index 0000000..6c7e6a2 --- /dev/null +++ b/.github/workflows/make.yml @@ -0,0 +1,42 @@ +--- +name: Make + +on: + schedule: + - cron: '0 0 1 * *' + push: + branches: + - "**" + pull_request: + branches: + - master + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ${{ matrix.os }} + timeout-minutes: 120 + strategy: + 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 make.sh build + + - name: Build on Windows + if: runner.os == 'Windows' + shell: powershell + run: pwsh -File make.ps1 build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a16b233 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "use/LazMapViewer"] + path = use/LazMapViewer + url = git@github.com:wp-xyz/LazMapViewer.git diff --git a/make.ps1 b/make.ps1 new file mode 100644 index 0000000..bdbc7d5 --- /dev/null +++ b/make.ps1 @@ -0,0 +1,118 @@ +#!/usr/bin/env pwsh +############################################################################################################## + +Function Show-Usage { + " +Usage: pwsh -File $($PSCommandPath) [OPTIONS] +Options: + build Build program +" | Out-Host +} + +Function Request-File { + While ($Input.MoveNext()) { + $VAR = @{ + Uri = $Input.Current + OutFile = (Split-Path -Path $Input.Current -Leaf).Split('?')[0] + } + Invoke-WebRequest @VAR + Return $VAR.OutFile + } +} + +Function Install-Program { + While ($Input.MoveNext()) { + Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) { + 'msi' { + & msiexec /passive /package $Input.Current | Out-Null + } + Default { + & ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Null + } + } + Remove-Item $Input.Current + } +} + +Function Build-Project { + @( + @{ + Cmd = 'lazbuild' + Url = 'https://fossies.org/windows/misc/lazarus-3.6-fpc-3.2.2-win64.exe' + Path = "C:\Lazarus" + } + ) | Where-Object { ! (Test-Path -Path $_.Path) } | + ForEach-Object { + $_.Url | Request-File | Install-Program + $Env:PATH+=";$($_.Path)" + (Get-Command $_.Cmd).Source | Out-Host + } + If (Test-Path -Path '.gitmodules') { + & git submodule update --init --recursive --force --remote | Out-Host + ".... [[$($LastExitCode)]] git submodule update" | Out-Host + } + $Env:Ext = '0' + $Env:Src = 'src' + $Env:Use = 'use' + $Env:Pkg = 'use\components.txt' + If (Test-Path -Path $Env:Use) { + If (Test-Path -Path $Env:Pkg) { + Get-Content -Path $Env:Pkg | + Where-Object { + ! (Test-Path -Path "$($Env:Use)\$($_)") && + ! (& lazbuild --verbose-pkgsearch $_ ) && + ! (& lazbuild --add-package $_) + } | ForEach-Object { + Return @{ + Uri = "https://packages.lazarus-ide.org/$($_).zip" + Path = "$($Env:Use)\$($_)" + OutFile = (New-TemporaryFile).FullName + } + } | ForEach-Object -Parallel { + Invoke-WebRequest -OutFile $_.OutFile -Uri $_.Uri + Expand-Archive -Path $_.OutFile -DestinationPath $_.Path + Remove-Item $_.OutFile + Return ".... download $($_.Uri)" + } | Out-Host + } + (Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $Env:Use).FullName | + ForEach-Object { + & lazbuild --add-package-link $_ | Out-Host + Return ".... [$($LastExitCode)] add package link $($_)" + } | Out-Host + } + (Get-ChildItem -Filter '*.lpi' -Recurse -File –Path $Env:Src).FullName | + ForEach-Object { + $Output = (& lazbuild --build-all --recursive --no-write-project --build-mode='release' $_) + $Result = @(".... [$($LastExitCode)] build project $($_)") + If ($LastExitCode -eq 0) { + $Result += $Output | Select-String -Pattern 'Linking' + } Else { + $Env:Ext = [Int]$Env:Ext + 1 + $Result += $Output | Select-String -Pattern 'Error:', 'Fatal:' + } + $Result | Out-Host + } + Exit [Int]$Env:Ext +} + +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 diff --git a/make.sh b/make.sh new file mode 100644 index 0000000..d28151f --- /dev/null +++ b/make.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +function priv_clippit +( + cat <&2 + fi + declare -i errors=0 + while read -r; do + declare -A TMP=( + [out]=$(mktemp) + ) + if (lazbuild --build-all --recursive --no-write-project --build-mode='release' --widgetset='qt5' "${REPLY}" > "${TMP[out]}"); then + printf '\x1b[32m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY}" + grep --color='always' 'Linking' "${TMP[out]}" + else + printf '\x1b[31m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY}" + grep --color='always' --extended-regexp '(Error|Fatal):' "${TMP[out]}" + ((errors+=1)) + fi 1>&2 + rm "${TMP[out]}" + done < <(find "${VAR[src]}" -type 'f' -name '*.lpi' | sort) + exit "${errors}" +) + +function priv_main +( + set -euo pipefail + if ((${#})); then + case ${1} in + build) priv_lazbuild ;; + *) priv_clippit ;; + esac + else + priv_clippit + fi +) + +priv_main "${@}" >/dev/null diff --git a/use/LazMapViewer b/use/LazMapViewer new file mode 160000 index 0000000..7a1464e --- /dev/null +++ b/use/LazMapViewer @@ -0,0 +1 @@ +Subproject commit 7a1464ec8a666980884e1a9e1c4583107597fdaf diff --git a/use/components.txt b/use/components.txt new file mode 100644 index 0000000..679162f --- /dev/null +++ b/use/components.txt @@ -0,0 +1,3 @@ +RichMemo +LazRGBGraphics +BGRABitmap