|
| 1 | +#!/usr/bin/env pwsh |
| 2 | +############################################################################################################## |
| 3 | + |
| 4 | +Function PrivClipper { |
| 5 | + Return " |
| 6 | +Usage: pwsh -File $($PSCommandPath) [OPTIONS] |
| 7 | +Options: |
| 8 | + build Build program |
| 9 | +" |
| 10 | +} |
| 11 | + |
| 12 | +Function PrivWget { |
| 13 | + ForEach ($REPLY in $args) { |
| 14 | + $params = @{ |
| 15 | + Uri = $REPLY |
| 16 | + OutFile = (Split-Path -Path $REPLY -Leaf).Split('?')[0] |
| 17 | + } |
| 18 | + Invoke-WebRequest @params | Out-Null |
| 19 | + Return $params.OutFile |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +Function PrivMsiexec { |
| 24 | + While ($Input.MoveNext()) { |
| 25 | + $params = @{} |
| 26 | + Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) { |
| 27 | + 'msi' { |
| 28 | + $params = @{ |
| 29 | + FilePath = 'msiexec' |
| 30 | + ArgumentList = '/passive', '/package', $Input.Current |
| 31 | + } |
| 32 | + } |
| 33 | + 'exe' { |
| 34 | + $params = @{ |
| 35 | + FilePath = $Input.Current |
| 36 | + ArgumentList = '/SP-', '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART' |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | + Start-Process -PassThru -Wait @params |
| 41 | + Remove-Item $Input.Current |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +Function PrivLazBuild { |
| 46 | + $VAR = @{ |
| 47 | + Cmd = 'lazbuild' |
| 48 | + 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' |
| 49 | + Path = "C:\Lazarus" |
| 50 | + } |
| 51 | + If (-not (Get-Command $VAR.Cmd -ea 'continue')) { |
| 52 | + PrivWget $VAR.Url | PrivMsiexec |
| 53 | + $env:PATH+=";$($VAR.Path)" |
| 54 | + Get-Command $VAR.Cmd |
| 55 | + } |
| 56 | + If ( Test-Path -Path 'use\components.txt' ) { |
| 57 | + Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--init' |
| 58 | + Start-Process -Wait -FilePath 'git' -ArgumentList 'submodule', 'update', '--recursive', '--remote' |
| 59 | + Get-Content -Path 'use\components.txt' | ForEach-Object { |
| 60 | + If (-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--verbose-pkgsearch', $_)) -and |
| 61 | + (-not (Start-Process -ea 'continue' -Wait -FilePath 'lazbuild' -ArgumentList '--add-package', $_)) -and |
| 62 | + (-not (Test-Path -Path 'use\components.txt')) { |
| 63 | + $OutFile = PrivWget "https://packages.lazarus-ide.org/$($_).zip" |
| 64 | + Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force |
| 65 | + Remove-Item $OutFile |
| 66 | + } |
| 67 | + } |
| 68 | + Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object { |
| 69 | + Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--add-package-link', $_.Name |
| 70 | + } |
| 71 | + } |
| 72 | + Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object { |
| 73 | + Start-Process -Wait -FilePath 'lazbuild' -ArgumentList '--no-write-project', '--recursive', '--build-mode=release', $_.Name |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +Function PrivMain { |
| 78 | + $ErrorActionPreference = 'stop' |
| 79 | + Set-PSDebug -Strict -Trace 1 |
| 80 | + Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath |
| 81 | + If ($args.count -gt 0) { |
| 82 | + Switch ($args[0]) { |
| 83 | + 'build' { |
| 84 | + PrivLazBuild |
| 85 | + } |
| 86 | + Default { |
| 87 | + PrivClipper |
| 88 | + } |
| 89 | + } |
| 90 | + } Else { |
| 91 | + PrivClipper |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +############################################################################################################## |
| 96 | +PrivMain @args |
0 commit comments