diff --git a/make.ps1 b/make.ps1 index 7a14631..f43c4f0 100644 --- a/make.ps1 +++ b/make.ps1 @@ -1,7 +1,7 @@ #!/usr/bin/env pwsh ############################################################################################################## -Function PrivClipper { +Function Show-Usage { Return " Usage: pwsh -File $($PSCommandPath) [OPTIONS] Options: @@ -9,7 +9,7 @@ Options: " } -Function PrivWget { +Function Request-File { ForEach ($REPLY in $args) { $params = @{ Uri = $REPLY @@ -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 diff --git a/make.sh b/make.sh index 9f5d98c..bf2e4e2 100644 --- a/make.sh +++ b/make.sh @@ -24,19 +24,18 @@ 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 @@ -44,7 +43,6 @@ function priv_lazbuild -exec lazbuild --no-write-project --recursive --no-write-project --build-mode=release {} + 1>&2 ) - function priv_dpkg ( # Linux shell script to create .deb package