Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 36 additions & 26 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Options:

Function Request-File {
While ($Input.MoveNext()) {
$VAR = @{
New-Variable -Name VAR -Option Constant -Value @{
Uri = $Input.Current
OutFile = (Split-Path -Path $Input.Current -Leaf).Split('?')[0]
}
Expand Down Expand Up @@ -51,21 +51,22 @@ Function Build-Project {
& 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 |
New-Variable -Name VAR -Option Constant -Value @{
Src = 'src'
Use = 'use'
Pkg = 'use\components.txt'
}
If (Test-Path -Path $VAR.Use) {
If (Test-Path -Path $VAR.Pkg) {
Get-Content -Path $VAR.Pkg |
Where-Object {
! (Test-Path -Path "$($Env:Use)\$($_)") &&
! (Test-Path -Path "$($VAR.Use)\$($_)") &&
! (& lazbuild --verbose-pkgsearch $_ ) &&
! (& lazbuild --add-package $_)
} | ForEach-Object {
Return @{
Uri = "https://packages.lazarus-ide.org/$($_).zip"
Path = "$($Env:Use)\$($_)"
Path = "$($VAR.Use)\$($_)"
OutFile = (New-TemporaryFile).FullName
}
} | ForEach-Object -Parallel {
Expand All @@ -75,25 +76,34 @@ Function Build-Project {
Return ".... download $($_.Uri)"
} | Out-Host
}
(Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $Env:Use).FullName |
(Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $VAR.Use).FullName |
ForEach-Object {
& lazbuild --add-package-link $_ | Out-Host
& lazbuild --add-package-link $_ | Out-Null
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
If (Test-Path -Path $Var.Src) {
Exit (
(Get-ChildItem -Filter '*.lpi' -Recurse -File –Path $Var.Src).FullName |
Sort-Object |
ForEach-Object {
$Output = (& lazbuild --build-all --recursive --no-write-project --build-mode='release' $_)
$Result = @(".... [$($LastExitCode)] build project $($_)")
$exitCode = Switch ($LastExitCode) {
0 {
$Result += $Output | Select-String -Pattern 'Linking'
0
}
Default {
$Result += $Output | Select-String -Pattern 'Error:', 'Fatal:'
1
}
}
$Result | Out-Host
Return $exitCode
} | Measure-Object -Sum
).Sum
}
}

Function Switch-Action {
Expand All @@ -115,4 +125,4 @@ Function Switch-Action {
}

##############################################################################################################
Switch-Action @args
Switch-Action @args
23 changes: 13 additions & 10 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function priv_lazbuild
wget https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/fpc-laz_3.2.2-210709_amd64.deb/download -O fpc-laz_3.2.2-210709_amd64.deb
wget https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/fpc-src_3.2.2-210709_amd64.deb/download -O fpc-src_3.2.2-210709_amd64.deb
sudo apt-get update
sudo apt-get install -y ./fpc-src_3.2.2-210709_amd64.deb
sudo apt-get install -y ./fpc-src_3.2.2-210709_amd64.deb
sudo apt-get install -y ./fpc-laz_3.2.2-210709_amd64.deb
sudo apt-get install -y ./lazarus-project_3.6.0-0_amd64.deb
;;
Expand All @@ -41,16 +41,19 @@ function priv_lazbuild
! [[ -d "${VAR[use]}/${REPLY}" ]] &&
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
! (lazbuild --add-package "${REPLY}"); then
declare -A TMP=(
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
[dir]="${VAR[use]}/${REPLY}"
[out]=$(mktemp)
)
wget --quiet --output-document "${TMP[out]}" "${TMP[url]}"
unzip -o "${TMP[out]}" -d "${TMP[dir]}"
rm --verbose "${TMP[out]}"
(
declare -A TMP=(
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
[dir]="${VAR[use]}/${REPLY}"
[out]=$(mktemp)
)
wget --quiet --output-document "${TMP[out]}" "${TMP[url]}"
unzip -o "${TMP[out]}" -d "${TMP[dir]}"
rm --verbose "${TMP[out]}"
) &
fi
done < "${VAR[pkg]}"
wait
fi
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
Expand Down Expand Up @@ -86,4 +89,4 @@ function priv_main
fi
)

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