diff --git a/.github/workflows/make.json b/.github/workflows/make.json deleted file mode 100644 index 232b2e95..00000000 --- a/.github/workflows/make.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "app" : "examples", - "lib" : "package", - "tst" : "tst", - "pkg" : [ - ] -} diff --git a/.github/workflows/make.pas b/.github/workflows/make.pas new file mode 100644 index 00000000..64e0be80 --- /dev/null +++ b/.github/workflows/make.pas @@ -0,0 +1,204 @@ +program Make; +{$mode objfpc}{$H+} + +uses + Classes, + SysUtils, + StrUtils, + FileUtil, + Zipper, + fphttpclient, + RegExpr, + openssl, + LazUTF8, + opensslsockets, + eventlog, + Process; + +const + Target: string = '.'; + Dependencies: array of string = (); + +type + Output = record + Success: boolean; + Output: string; + end; + + function OutLog(const Knd: TEventType; const Msg: string): string; + begin + case Knd of + etError: Result := #27'[31m%s'#27'[0m'; + etInfo: Result := #27'[32m%s'#27'[0m'; + etDebug: Result := #27'[33m%s'#27'[0m'; + end; + Writeln(stderr, UTF8ToConsole(Format(Result, [Msg]))); + end; + + function CheckModules: string; + begin + if FileExists('.gitmodules') then + if RunCommand('git', ['submodule', 'update', '--init', '--recursive', + '--force', '--remote'], Result, []) then + OutLog(etInfo, Result) + else + OutLog(etError, Result); + end; + + function AddPackage(const Path: string): string; + begin + if RunCommand('lazbuild', ['--add-package-link', Path], Result, []) then + OutLog(etDebug, 'Add package:'#9 + Path); + end; + + function SelectString(const Input, Reg: string): string; + var + Line: string; + begin + Result := EmptyStr; + for Line in Input.Split(LineEnding) do + with TRegExpr.Create do + begin + Expression := Reg; + if Exec(Line) then + Result += Line + LineEnding; + Free; + end; + end; + + function RunTest(const Path: String): string; + begin + OutLog(etDebug, #9'run:'#9 + Path); + if RunCommand(Path, ['--all', '--format=plain'], Result, []) then + OutLog(etInfo, #9'success!') + else + begin + ExitCode += 1; + OutLog(etError, Result); + end; + end; + + function AddDDL(const Path: String): string; + begin + OutLog(etDebug, #9'add:'#9 + Path); + if RunCommand('sudo', ['bash', '-c', Format('cp %s /usr/lib/; ldconfig --verbose', [Path])], Result, []) then + OutLog(etInfo, #9'success!') + else + begin + ExitCode += 1; + OutLog(etError, Result); + end; + end; + + function BuildProject(const Path: string): Output; + begin + OutLog(etDebug, 'Build from:'#9 + Path); + Result.Success := RunCommand('lazbuild', + ['--build-all', '--recursive', '--no-write-project', Path], Result.Output, []); + Result.Output := SelectString(Result.Output, '(Fatal:|Error:|Linking)'); + if Result.Success then + begin + Result.Output := Result.Output.Split(' ')[2].Replace(LineEnding, EmptyStr); + OutLog(etInfo, #9'to:'#9 + Result.Output); + if ContainsStr(ReadFileToString(Path.Replace('.lpi', '.lpr')), 'consoletestrunner') then + RunTest(Result.Output) + else if (ContainsStr(ReadFileToString(Path.Replace('.lpi', '.lpr')), 'exports')) then + AddDDL(Result.Output) + end + else + begin + ExitCode += 1; + OutLog(etError, Result.Output); + end; + end; + + function DownloadFile(const Uri: string): string; + var + OutFile: TStream; + begin + InitSSLInterface; + Result := GetTempFileName; + OutFile := TFileStream.Create(Result, fmCreate or fmOpenWrite); + with TFPHttpClient.Create(nil) do + begin + try + AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)'); + AllowRedirect := True; + Get(Uri, OutFile); + OutLog(etDebug, 'Download from ' + Uri + ' to ' + Result); + finally + Free; + OutFile.Free; + end; + end; + end; + + procedure UnZip(const ZipFile, ZipPath: string); + begin + with TUnZipper.Create do + begin + try + FileName := ZipFile; + OutputPath := ZipPath; + Examine; + UnZipAllFiles; + OutLog(etDebug, 'Unzip from'#9 + ZipFile + #9'to'#9 + ZipPath); + DeleteFile(ZipFile); + finally + Free; + end; + end; + end; + + function InstallOPM(const Path: string): string; + begin + Result := + {$IFDEF MSWINDOWS} + GetEnvironmentVariable('APPDATA') + '\.lazarus\onlinepackagemanager\packages\' + {$ELSE} + GetEnvironmentVariable('HOME') + '/.lazarus/onlinepackagemanager/packages/' + {$ENDIF} + + Path; + if not DirectoryExists(Result) then + begin + if ForceDirectories(Result) then + UnZip(DownloadFile('https://packages.lazarus-ide.org/' + Path + '.zip'), Result); + end; + end; + + function BuildAll: string; + var + List: TStringList; + DT: TDateTime; + begin + DT := Time; + CheckModules; + List := FindAllFiles(GetCurrentDir, '*.lpk', True); + try + for Result in Dependencies do + List.AddStrings(FindAllFiles(InstallOPM(Result), '*.lpk', True)); + for Result in List do + AddPackage(Result); + List := FindAllFiles(Target, '*.lpi', True); + List.Sort; + for Result in List do + BuildProject(Result); + finally + List.Free; + end; + OutLog(etDebug, 'Duration:'#9 + FormatDateTime('hh:nn:ss', DT - Time)); + end; + +begin + try + BuildAll + case ExitCode of + 0: OutLog(etInfo, 'Errors:'#9 + IntToStr(ExitCode)); + else + OutLog(etError, 'Errors:'#9 + IntToStr(ExitCode)); + end; + except + on E: Exception do + Writeln(E.ClassName, #9, E.Message); + end; +end. diff --git a/.github/workflows/make.ps1 b/.github/workflows/make.ps1 deleted file mode 100644 index 5458c87e..00000000 --- a/.github/workflows/make.ps1 +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env pwsh -############################################################################################################## - -Function Show-Usage { - " -vagrant = 'it-gro/win10-ltsc-eval' -download = 'https://microsoft.com/en-us/evalcenter' -package = 'https://learn.microsoft.com/en-us/mem/configmgr/develop/apps/how-to-create-the-windows-installer-file-msi' -shell = 'https://learn.microsoft.com/en-us/powershell' - -Usage: pwsh -File $($PSCommandPath) [OPTIONS] -Options: - build - lint -" | Out-Host -} - -Function Build-Project { - New-Variable -Option Constant -Name VAR -Value (Get-Content -Path $PSCommandPath.Replace('ps1', 'json') | ConvertFrom-Json) - If (! (Test-Path -Path $Var.app)) { - "$([char]27)[31m.... $($Var.app) did not find!$([char]27)[0m" | Out-Host - Exit 1 - } - If (Test-Path -Path '.gitmodules') { - & git submodule update --init --recursive --force --remote | Out-Host - "$([char]27)[33m.... [[$($LastExitCode)]] git submodule update$([char]27)[0m" | Out-Host - } - @( - @{ - Cmd = 'lazbuild' - Url = 'https://fossies.org/windows/misc/lazarus-3.6-fpc-3.2.2-win64.exe' - Path = "C:\Lazarus" - } - ) | Where-Object { - ! (Test-Path -Path $_.Path) - } | ForEach-Object { - $_.Url | Request-File | Install-Program - $Env:PATH+=";$($_.Path)" - Return (Get-Command $_.Cmd).Source - } | Out-Host - $VAR.Pkg | ForEach-Object { - @{ - Name = $_ - Uri = "https://packages.lazarus-ide.org/$($_).zip" - Path = "$($Env:HOME)\.lazarus\onlinepackagemanager\packages\$($_)" - OutFile = (New-TemporaryFile).FullName - } - } | Where-Object { - ! (Test-Path -Path $_.Path) && - ! (& lazbuild --verbose-pkgsearch $_.Name ) && - ! (& lazbuild --add-package $_.Name) - } | ForEach-Object -Parallel { - Invoke-WebRequest -OutFile $_.OutFile -Uri $_.Uri - New-Item -Type Directory -Path $_.Path | Out-Null - Expand-Archive -Path $_.OutFile -DestinationPath $_.Path - Remove-Item $_.OutFile - (Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $_.Path).FullName | - ForEach-Object { - & lazbuild --add-package-link $_ | Out-Null - Return "$([char]27)[33m.... [$($LastExitCode)] add package link $($_)$([char]27)[0m" - } - } | Out-Host - If (Test-Path -Path $VAR.lib) { - (Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $VAR.lib).FullName | - ForEach-Object { - & lazbuild --add-package-link $_ | Out-Null - Return "$([char]27)[33m.... [$($LastExitCode)] add package link $($_)$([char]27)[0m" - } | Out-Host - } - Exit $(Switch (Test-Path -Path $Var.tst) { - true { - $Output = ( - & lazbuild --build-all --recursive --no-write-project $VAR.tst | - Where-Object { - $_.Contains('Linking') - } | ForEach-Object { - $_.Split(' ')[2].Replace('bin', 'bin\.') - } - ) - $Output = (& $Output --all --format=plain --progress) - $exitCode = Switch ($LastExitCode) { - 0 {0} - Default { - 1 - } - } - $Output | Out-Host - Return $exitCode -K } - Default {0} - }) + ( - (Get-ChildItem -Filter '*.lpi' -Recurse -File –Path $Var.app).FullName | - ForEach-Object { - $Output = (& lazbuild --build-all --recursive --no-write-project $_) - $Result = @("$([char]27)[32m.... [$($LastExitCode)] build project $($_)$([char]27)[0m") - $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 Request-File { - While ($Input.MoveNext()) { - New-Variable -Option Constant -Name VAR -Value @{ - Uri = $Input.Current - OutFile = (Split-Path -Path $Input.Current -Leaf).Split('?')[0] - } - Invoke-WebRequest @VAR - Return $VAR.OutFile - } -} - -Function Install-Program { - While ($Input.MoveNext()) { - Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) { - 'msi' { - & msiexec /passive /package $Input.Current | Out-Null - } - Default { - & ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Null - } - } - Remove-Item $Input.Current - } -} - -Function Request-URL([Switch] $Post) { - $VAR = Switch ($Post) { - true { - @{ - Method = 'POST' - Headers = @{ - ContentType = 'application/json' - } - Uri = 'https://postman-echo.com/post' - Body = @{ - One = '1' - } | ConvertTo-Json - } - } - false { - @{ - Uri = 'https://postman-echo.com/get' - } - } - } - Return (Invoke-WebRequest @VAR | ConvertFrom-Json).Headers -} - -Function Switch-Action { - $ErrorActionPreference = 'stop' - Set-PSDebug -Strict #-Trace 1 - Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath - If ($args.count -gt 0) { - Switch ($args[0]) { - 'lint' { - Invoke-ScriptAnalyzer -EnableExit -Recurse -Path '.' - (Get-ChildItem -Filter '*.ps1' -Recurse -Path '.').FullName | - ForEach-Object { - Invoke-Formatter -ScriptDefinition $(Get-Content -Path $_ | Out-String) | - Set-Content -Path $_ - } - } - 'build' { - Build-Project - } - Default { - Show-Usage - } - } - } Else { - Show-Usage - } -} - -############################################################################################################## -Switch-Action @args diff --git a/.github/workflows/make.sh b/.github/workflows/make.sh deleted file mode 100644 index 04643b47..00000000 --- a/.github/workflows/make.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env bash -############################################################################################################## - -function priv_clippit -( - cat <&2 - if [[ -f '.gitmodules' ]]; then - git submodule update --init --recursive --force --remote & - fi - if ! (command -v lazbuild); then - # shellcheck source=/dev/null - source '/etc/os-release' - case ${ID:?} in - debian | ubuntu) - sudo apt-get update - sudo apt-get install -y lazarus{-ide-qt5,} & - ;; - esac - fi &>/dev/null - wait - while read -r; do - ( - declare -rA TMP=( - [url]="https://packages.lazarus-ide.org/${REPLY}.zip" - [dir]="${HOME}/.lazarus/onlinepackagemanager/packages/${REPLY}" - [out]=$(mktemp) - ) - if ! [[ -d "${TMP[dir]}" ]] && - ! (lazbuild --verbose-pkgsearch "${REPLY}") && - ! (lazbuild --add-package "${REPLY}"); then - wget --quiet --output-document "${TMP[out]}" "${TMP[url]}" - mkdir --parents "${TMP[dir]}" - unzip -o "${TMP[out]}" -d "${TMP[dir]}" - rm --verbose "${TMP[out]}" - find "${TMP[dir]}" -type 'f' -name '*.lpk' -printf '\033[33m\tadd package link\t%p\033[0m\n' -exec \ - lazbuild --add-package-link {} + >&2 - fi - ) & - done < <(jq --raw-output --exit-status '.pkg[]' <<< "${MAPFILE[@]}") - wait - if [[ -d "${VAR[lib]}" ]]; then - find "${VAR[lib]}" -type 'f' -name '*.lpk' -printf '\033[33m\tadd package link\t%p\033[0m\n' -exec \ - lazbuild --add-package-link {} + >&2 - fi - declare -i exitCode=0 - if [[ -f "${VAR[tst]}" ]]; then - declare -A TMP=( - [tst]=$( - lazbuild --build-all --recursive --no-write-project "${VAR[tst]}" | - awk '/Linking/{print $3}' - ) - ) - if ! ("${TMP[tst]}" --all --format=plain --progress >&2); then - ((exitCode+=1)) - fi - fi - while read -r; do - declare -A TMP=( - [out]=$(mktemp) - ) - if (lazbuild --build-all --recursive --no-write-project "${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]}" - ((exitCode+=1)) - fi >&2 - rm "${TMP[out]}" - done < <(find "${VAR[app]}" -type 'f' -name '*.lpi') - exit "${exitCode}" -) - -function priv_main -( - set -euo pipefail - if ((${#})); then - case ${1} in - build) priv_lazbuild ;; - *) priv_clippit ;; - esac - else - priv_clippit - fi -) - -############################################################################################################## -priv_main "${@}" >/dev/null diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 006d55cd..8ca1afde 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -24,7 +24,7 @@ jobs: matrix: os: - ubuntu-latest - - windows-latest + steps: - name: Checkout uses: actions/checkout@v4 @@ -32,18 +32,9 @@ jobs: submodules: true - name: Build on Linux - if: runner.os == 'Linux' shell: bash - run: bash .github/workflows/make.sh build - - - name: Build on Windows - if: runner.os == 'Windows' - shell: powershell - run: pwsh -File .github/workflows/make.ps1 build - - - name: Archive - if: runner.os == 'Windows' - uses: actions/upload-artifact@v4 - with: - retention-days: 1 - path: src\bin\*.exe + run: | + set -xeuo pipefail + sudo bash -c 'apt-get update; apt-get install -y lazarus' >/dev/null + instantfpc -Fu/usr/lib/lazarus/*/components/lazutils \ + -B '.github/workflows/make.pas' diff --git a/examples/core/core_vr_simulator/core_vr_simulator.lpr b/examples/core/core_vr_simulator/core_vr_simulator.lpr index 566dbabd..f3b05c0b 100644 --- a/examples/core/core_vr_simulator/core_vr_simulator.lpr +++ b/examples/core/core_vr_simulator/core_vr_simulator.lpr @@ -44,7 +44,7 @@ device.vResolution := 1200; // Vertical resolution in pixels device.hScreenSize := 0.133793; // Horizontal size in meters device.vScreenSize := 0.0669; // Vertical size in meters - device.vScreenCenter := 0.04678; // Screen center in meters + //device.vScreenCenter := 0.04678; // Screen center in meters device.eyeToScreenDistance := 0.041; // Distance between eye and display in meters device.lensSeparationDistance := 0.07; // Lens separation distance in meters device.interpupillaryDistance := 0.07; // IPD (distance between pupils) in meters diff --git a/examples/models/models_gpu_skinning/models_gpu_skinning.lpr b/examples/models/models_gpu_skinning/models_gpu_skinning.lpr index 7924fb98..4504446f 100644 --- a/examples/models/models_gpu_skinning/models_gpu_skinning.lpr +++ b/examples/models/models_gpu_skinning/models_gpu_skinning.lpr @@ -86,7 +86,7 @@ // Update model animation anim := modelAnimations[animIndex]; animCurrentFrame := animCurrentFrame + 1 mod anim.frameCount; - UpdateModelAnimationBoneMatrices(characterModel, anim, animCurrentFrame); + UpdateModelAnimationBones(characterModel, anim, animCurrentFrame); // Draw BeginDrawing(); @@ -96,7 +96,7 @@ BeginMode3D(camera); // Draw character characterModel.transform := MatrixTranslate(position.x, position.y, position.z); - UpdateModelAnimationBoneMatrices(characterModel, anim, animCurrentFrame); + UpdateModelAnimationBones(characterModel, anim, animCurrentFrame); DrawMesh(characterModel.meshes[0], characterModel.materials[1], characterModel.transform); DrawGrid(10, 1.0); EndMode3D();