2
0
Artem V. Ageev 8 сар өмнө
parent
commit
09b2798ad2

+ 38 - 31
make.ps1

@@ -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]
         }
@@ -35,6 +35,19 @@ Function Install-Program {
 }
 
 Function Build-Project {
+    New-Variable -Name VAR -Option Constant -Value @{
+        Src = 'lazpaint'
+        Use = 'use'
+        Pkg = 'use\components.txt'
+    }
+    If (! (Test-Path -Path $Var.Src)) {
+        'Source do not find!' | Out-Host
+        Exit 1
+    }
+    If (Test-Path -Path '.gitmodules') {
+        & git submodule update --init --recursive --force --remote | Out-Host
+        ".... [[$($LastExitCode)]] git submodule update" | Out-Host
+    }
     @(
         @{
             Cmd = 'lazbuild'
@@ -47,24 +60,17 @@ Function Build-Project {
             $Env:PATH+=";$($_.Path)"
             (Get-Command $_.Cmd).Source | Out-Host
         }
-    If (Test-Path -Path '.gitmodules') {
-        & git submodule update --init --recursive --force --remote | Out-Host
-        ".... [[$($LastExitCode)]] git submodule update" | Out-Host
-    }
-    $Env:Src = 'lazpaint'
-    $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 |
+    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 {
@@ -74,31 +80,32 @@ 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-Null
                 Return ".... [$($LastExitCode)] add package link $($_)"
             } | 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) {
+    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'
-                    } Else {
-                        $error = 1
+                        0
+                    }
+                    Default {
                         $Result += $Output | Select-String -Pattern 'Error:', 'Fatal:'
+                        1
                     }
-                    $Result | Out-Host
-                    Return $error
-                } | Measure-Object -Sum
-        ).Sum
-    }
+                }
+                $Result | Out-Host
+                Return $exitCode
+            } | Measure-Object -Sum
+    ).Sum
 }
 
 Function Switch-Action {
@@ -120,4 +127,4 @@ Function Switch-Action {
 }
 
 ##############################################################################################################
-Switch-Action @args | Out-Null
+Switch-Action @args

+ 40 - 35
make.sh

@@ -11,24 +11,28 @@ EOF
 
 function priv_lazbuild
 (
+    declare -rA VAR=(
+        [src]='lazpaint'
+        [use]='use'
+        [pkg]='use/components.txt'
+    )
+    if ! [[ -d "${VAR[src]}" ]]; then
+        printf '\x1b[31m\tSource do not find!\x1b[0m\n' "${?}" "${REPLY}"
+        exit 1
+    fi
+    if [[ -f '.gitmodules' ]]; then
+        git submodule update --init --recursive --force --remote &
+    fi
     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{-ide-qt5,} &
                 ;;
         esac
     fi
-    if [[ -f '.gitmodules' ]]; then
-        git submodule update --init --recursive --force --remote &
-    fi
     wait
-    declare -rA VAR=(
-        [src]='lazpaint'
-        [use]='use'
-        [pkg]='use/components.txt'
-    )
     if [[ -d "${VAR[use]}" ]]; then
         if [[ -f "${VAR[pkg]}" ]]; then
             while read -r; do
@@ -36,38 +40,39 @@ 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
     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
+    declare -i errors=0
+    while read -r; do
+        declare -A TMP=(
+            [out]=$(mktemp)
+        )
+        if (lazbuild --build-all --recursive --no-write-project --build-mode='release' --widgetset='qt5' "${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}"
 )
 
 function priv_main

+ 1 - 1
use/lazpaintcontrols/lcvectorialfillinterface.pas

@@ -1407,6 +1407,6 @@ begin
 end;
 
 begin
-  {$i fillimages.lrs}
+  {$i ../../resources/fillimages.lrs}
 end.