Skip to content

Commit

Permalink
Merge pull request #14 from theavege/fix/ci
Browse files Browse the repository at this point in the history
Fix/ci
  • Loading branch information
circular17 authored Dec 29, 2024
2 parents 211b863 + 028a1e1 commit 2a5d179
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
11 changes: 10 additions & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name: Make

on:
schedule:
- cron: '0 0 1 * *'
push:
branches:
- "**"
Expand Down Expand Up @@ -32,9 +34,16 @@ jobs:
- name: Build on Linux
if: runner.os == 'Linux'
shell: bash
run: bash -x make.sh build
run: bash make.sh build

- name: Build on Windows
if: runner.os == 'Windows'
shell: powershell
run: pwsh -File make.ps1 build

- name: Archive
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
retention-days: 1
path: src\bin\*.exe
20 changes: 12 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
src/backup/
src/lib/
src/bin/
src/*.lps
src/*.res
src/*.o
src/*.ppu
use/*/
.DS_Store
**/backup/
**/lib/
**/bin/
*.res
*.dbg
*.lps
*.compiled
*.o
*.or
*.so
*.ppu

112 changes: 71 additions & 41 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,108 @@
##############################################################################################################

Function Show-Usage {
Return "
"
Usage: pwsh -File $($PSCommandPath) [OPTIONS]
Options:
build Build program
"
" | Out-Host
}

Function Request-File {
ForEach ($REPLY in $args) {
$params = @{
Uri = $REPLY
OutFile = (Split-Path -Path $REPLY -Leaf).Split('?')[0]
While ($Input.MoveNext()) {
$VAR = @{
Uri = $Input.Current
OutFile = (Split-Path -Path $Input.Current -Leaf).Split('?')[0]
}
Invoke-WebRequest @params | Out-Null
Return $params.OutFile
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-Host
& msiexec /passive /package $Input.Current | Out-Null
}
'exe' {
& ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Host
Default {
& ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Null
}
}
Remove-Item $Input.Current
}
}

Function Build-Project {
$VAR = @{
Use = 'use'
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 $($VAR.Use)) {
@(
@{
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
$COMPONENTS = "$($VAR.Use)\components.txt"
If (Test-Path -Path $COMPONENTS) {
Get-Content -Path $COMPONENTS | ForEach-Object {
If ((! (& $VAR.Cmd --verbose-pkgsearch $_ | Out-Null)) &&
(! (& $VAR.Cmd --add-package $_ | Out-Null)) &&
(! (Test-Path -Path "$($VAR.Use)\$($_)"))) {
$OutFile = Request-File "https://packages.lazarus-ide.org/$($_).zip"
Expand-Archive -Path $OutFile -DestinationPath "$($VAR.Use)\$($_)" -Force
Remove-Item $OutFile
".... [[$($LastExitCode)]] git submodule update" | Out-Host
}
$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
}
}
}
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object {
& $VAR.Cmd --add-package-link $_ | Out-Host
} | 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-Null
Return ".... [$($LastExitCode)] add package link $($_)"
} | Out-Host
}
Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object {
& $VAR.Cmd --no-write-project --recursive $_ | Out-Host
If (Test-Path -Path $Env:Src) {
Exit (
(Get-ChildItem -Filter '*.lpi' -Recurse -File –Path $Env:Src).FullName |
Sort-Object |
ForEach-Object {
$error = 0
$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 {
$error = 1
$Result += $Output | Select-String -Pattern 'Error:', 'Fatal:'
}
$Result | Out-Host
Return $error
} | Measure-Object -Sum
).Sum
}
}

Function Switch-Action {
$ErrorActionPreference = 'stop'
Set-PSDebug -Strict -Trace 1
Set-PSDebug -Strict #-Trace 1
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
If ($args.count -gt 0) {
Switch ($args[0]) {
Expand Down
58 changes: 41 additions & 17 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,63 @@ EOF

function priv_lazbuild
(
if ! (which lazbuild); then
if ! (command -v lazbuild); then
source '/etc/os-release'
case ${ID:?} in
debian | ubuntu)
sudo apt-get update
sudo apt-get install -y lazarus
sudo apt-get install -y lazarus &
;;
esac
fi
declare -r COMPONENTS='use/components.txt'
if [[ -d "${COMPONENTS%%/*}" ]]; then
git submodule update --init --recursive --force --remote
if [[ -f "${COMPONENTS}" ]]; then
if [[ -f '.gitmodules' ]]; then
git submodule update --init --recursive --force --remote &
fi
wait
declare -rA VAR=(
[src]='src'
[use]='use'
[pkg]='use/components.txt'
)
if [[ -d "${VAR[use]}" ]]; then
if [[ -f "${VAR[pkg]}" ]]; then
while read -r; do
if [[ -n "${REPLY}" ]] &&
! [[ -d "${VAR[use]}/${REPLY}" ]] &&
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
! (lazbuild --add-package "${REPLY}") &&
! [[ -d "${COMPONENTS%%/*}/${REPLY}" ]]; then
declare -A VAR=(
! (lazbuild --add-package "${REPLY}"); then
declare -A TMP=(
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
[dir]="${VAR[use]}/${REPLY}"
[out]=$(mktemp)
)
wget --output-document "${VAR[out]}" "${VAR[url]}" >/dev/null
unzip -o "${VAR[out]}" -d "${COMPONENTS%%/*}/${REPLY}"
rm --verbose "${VAR[out]}"
wget --quiet --output-document "${TMP[out]}" "${TMP[url]}"
unzip -o "${TMP[out]}" -d "${TMP[dir]}"
rm --verbose "${TMP[out]}"
fi
done < "${COMPONENTS}"
done < "${VAR[pkg]}"
fi
find "${COMPONENTS%%/*}" -type 'f' -name '*.lpk' -exec \
lazbuild --add-package-link {} +
find "${VAR[use]}" -type 'f' -name '*.lpk' -printf '\033[32m\tadd package link\t%p\033[0m\n' -exec \
lazbuild --add-package-link {} + 1>&2
fi
if [[ -d "${VAR[src]}" ]]; then
declare -i errors=0
while read -r; do
declare -A TMP=(
[out]=$(mktemp)
)
if (lazbuild --build-all --recursive --no-write-project --build-mode='release' "${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}"
fi
find 'src' -type 'f' -name '*.lpi' -exec \
lazbuild --no-write-project --recursive --no-write-project {} + 1>&2
)

function priv_main
Expand Down
10 changes: 5 additions & 5 deletions src/dim.pas
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ generic TFactoredPowerUnit<BaseU: TFactoredUnit> = class(TCompoundFactoredUnit
class operator :=(const ASelf: TSelf): TRatio;
{$IFDEF FACTORED_QTY_INTF}
class operator :=(const ASelf: TSelf): TBaseRatio;
class function From(const AQuantity: TBaseRatio): TSelf; static; inline;
class function From(const AQuantity: TBaseRatio): TSelf; static;
{$ENDIF}
{$ENDIF}{$UNDEF RATIO_QTY_INTF}
{$IFDEF QTY_PROD_INTF}
Expand All @@ -181,7 +181,7 @@ generic TFactoredPowerUnit<BaseU: TFactoredUnit> = class(TCompoundFactoredUnit
class operator :=(const ASelf: TSelf): TProduct;
{$IFDEF FACTORED_QTY_INTF}
class operator :=(const ASelf: TSelf): TBaseProduct;
class function From(const AQuantity: TBaseProduct): TSelf; static; inline;
class function From(const AQuantity: TBaseProduct): TSelf; static;
{$ENDIF}
{$ENDIF}{$UNDEF QTY_PROD_INTF}
{$IFDEF RECIP_QTY_INTF}
Expand All @@ -193,7 +193,7 @@ generic TFactoredPowerUnit<BaseU: TFactoredUnit> = class(TCompoundFactoredUnit
function ToBase: TBaseQuantity;
constructor Assign(const AQuantity: TBaseQuantity); overload;
class operator :=(const AQuantity: TSelf): TBaseQuantity;
class function From(const AQuantity: TBaseQuantity): TSelf; static; inline;
class function From(const AQuantity: TBaseQuantity): TSelf; static;
{$ENDIF}{$UNDEF FACTORED_QTY_INTF}
{$IFNDEF DIM}{$DEFINE DIM}

Expand Down Expand Up @@ -391,7 +391,7 @@ generic TRightFactoredQuantityProduct<BaseU1, BaseU2: TUnit; U2: TFactoredUnit
class operator =(const {%H-}TheUnit1, {%H-}TheUnit2: TSelf): boolean;
class function Name: string; inline; static;
class function Symbol: string; inline; static;
class function From(const AQuantity: TQuantity): TQuantity; inline; static;
class function From(const AQuantity: TQuantity): TQuantity; static;
{$ENDIF}{$UNDEF UNIT_ID_INTF}
{$IFDEF POWERABLE_UNIT_ID_INTF}
class operator *(const {%H-}TheUnit1, {%H-}TheUnit2: TSelf): TSquareId;
Expand All @@ -411,7 +411,7 @@ generic TRightFactoredQuantityProduct<BaseU1, BaseU2: TUnit; U2: TFactoredUnit
function CubicRoot(const ACubicQuantity: TCubicQuantity): TQuantity;
{$ENDIF}{$UNDEF POWERABLE_UNIT_ID_INTF}
{$IFDEF FACTORED_UNIT_ID_INTF}
class function From(const AQuantity: TBaseQuantity): TQuantity; inline; static;
class function From(const AQuantity: TBaseQuantity): TQuantity; static;
class function BaseUnit: TBaseUnitId; inline; static;
class function Factor: double; inline; static;
{$ENDIF}{$UNDEF FACTORED_UNIT_ID_INTF}
Expand Down
4 changes: 2 additions & 2 deletions src/unitsOfMeasurement.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="unitsOfMeasurement"/>
<Filename Value="bin/unitsOfMeasurement"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
Expand Down Expand Up @@ -113,7 +113,7 @@
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="unitsOfMeasurement"/>
<Filename Value="bin/unitsOfMeasurement"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
Expand Down

0 comments on commit 2a5d179

Please sign in to comment.