Skip to content

Commit

Permalink
fix make files
Browse files Browse the repository at this point in the history
  • Loading branch information
theavege committed Nov 10, 2024
1 parent b2dbe30 commit b2913e6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 46 deletions.
58 changes: 25 additions & 33 deletions make.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env pwsh
##############################################################################################################

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

Function PrivWget {
Function Request-File {
ForEach ($REPLY in $args) {
$params = @{
Uri = $REPLY
Expand All @@ -20,79 +20,71 @@ Function PrivWget {
}
}

Function PrivMsiexec {
Function Install-Program {
While ($Input.MoveNext()) {
$params = @{}
Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) {
'msi' {
$params = @{
FilePath = 'msiexec'
ArgumentList = '/passive', '/package', $Input.Current
}
& msiexec /passive /package $Input.Current | Out-Host
}
'exe' {
$params = @{
FilePath = $Input.Current
ArgumentList = '/SP-', '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART'
}
& ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Host
}
}
Start-Process -PassThru -Wait @params
Remove-Item $Input.Current
}
}

Function PrivLazBuild {
Function Build-Project {
$VAR = @{
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"
}
If (-not (Get-Command $VAR.Cmd -ea 'continue')) {
PrivWget $VAR.Url | PrivMsiexec
Try {
Get-Command $VAR.Cmd
} Catch {
Request-File $VAR.Url | Install-Program
$env:PATH+=";$($VAR.Path)"
Get-Command $VAR.Cmd
}
If ( Test-Path -Path 'use\components.txt' ) {
Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--init'
Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--remote'
& git submodule update --recursive --init | Out-Host
& git submodule update --recursive --remote | Out-Host
Get-Content -Path 'use\components.txt' | ForEach-Object {
If (-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--verbose-pkgsearch', $_)) {
If (-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--add-package', $_)) {
If (-not (Test-Path -Path 'use\components.txt')) {
$OutFile = PrivWget "https://packages.lazarus-ide.org/$($_).zip"
Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force
Remove-Item $OutFile
}
If ((-not (& lazbuild --verbose-pkgsearch $_ | Out-Null)) -and
(-not (& lazbuild --add-package $_ | Out-Null)) -and
(-not (Test-Path -Path 'use\components.txt'))) {
$OutFile = Request-File "https://packages.lazarus-ide.org/$($_).zip"
Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force
Remove-Item $OutFile
}
}
}
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object {
Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--add-package-link', $_.Name
& lazbuild --add-package-link $_ | Out-Host
}
}
Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object {
Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--no-write-project', '--recursive', '--build-mode=release', $_.Name
& lazbuild --no-write-project --recursive --build-mode=release $_ | Out-Host
}
}

Function PrivMain {
Function Switch-Action {
$ErrorActionPreference = 'stop'
Set-PSDebug -Strict -Trace 1
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
If ($args.count -gt 0) {
Switch ($args[0]) {
'build' {
PrivLazBuild
Build-Project
}
Default {
PrivClipper
Show-Usage
}
}
} Else {
PrivClipper
Show-Usage
}
}

##############################################################################################################
PrivMain @args
Switch-Action @args | Out-Null
24 changes: 11 additions & 13 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,25 @@ function priv_lazbuild
git submodule update --init --recursive
git submodule update --recursive --remote
while read -r; do
if ! (lazbuild --verbose-pkgsearch "${REPLY}"); then
if ! (lazbuild --add-package "${REPLY}"); then
if ! [[ -f "use/${REPLY}" ]]; then
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 "use/${REPLY}"
rm --verbose "${VAR[out]}"
fi
if [[ -n "${REPLY}" ]] &&
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
! (lazbuild --add-package "${REPLY}") &&
! [[ -f "use/${REPLY}" ]]; then
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 "use/${REPLY}"
rm --verbose "${VAR[out]}"
fi
fi
done < 'use/components.txt'
find 'use' -type 'f' -name '*.lpk' -exec lazbuild --add-package-link {} +
fi
find 'src' -type 'f' -name '*.lpi' \
-exec lazbuild --no-write-project --recursive --no-write-project --build-mode=release {} + 1>&2
)


function priv_dpkg
(
# Linux shell script to create .deb package
Expand Down

0 comments on commit b2913e6

Please sign in to comment.