diff --git a/.github/workflows/make.pas b/.github/workflows/make.pas index d949007..2ddd588 100644 --- a/.github/workflows/make.pas +++ b/.github/workflows/make.pas @@ -5,7 +5,6 @@ Classes, SysUtils, StrUtils, - FileUtil, Zipper, fphttpclient, RegExpr, @@ -26,18 +25,90 @@ // Package path filter — skip platform-incompatible and template packages PackageExcludePattern = - {$IFDEF MSWINDOWS} + {$IF DEFINED(MSWINDOWS)} '(cocoa|x11|_template)' - {$ELSE} + {$ELSEIF DEFINED(DARWIN)} + '(gdi|x11|_template)' + {$ELSE} '(cocoa|gdi|_template)' - {$ENDIF} - ; + {$IFEND} + ; OPMBaseUrl = 'https://packages.lazarus-ide.org/'; var ErrorCount: Integer = 0; +// --------------------------------------------------------------------------- +// FCL/RTL-only helpers (replace FileUtil usage) +// --------------------------------------------------------------------------- + +function ReadFileToString(const AFileName: string): string; +var + Stream: TFileStream; + Size: Int64; +begin + Result := ''; + Stream := TFileStream.Create(AFileName, fmOpenRead or fmShareDenyNone); + try + Size := Stream.Size; + if Size <= 0 then + Exit; + SetLength(Result, Size); + Stream.Position := 0; + Stream.ReadBuffer(Pointer(Result)^, Size); + finally + Stream.Free; + end; +end; + +function MatchesMaskSimple(const AFileName, AMask: string): Boolean; +var + LExt: string; +begin + LExt := LowerCase(ExtractFileExt(AFileName)); + + if AMask = '*.lpk' then + Exit(LExt = '.lpk'); + + if AMask = '*.lpi' then + Exit(LExt = '.lpi'); + + Result := False; +end; + +procedure FindAllFilesRecursive(const ADir, AMask: string; AList: TStrings); +var + Search: TSearchRec; + DirPath: string; + EntryPath: string; +begin + DirPath := IncludeTrailingPathDelimiter(ExpandFileName(ADir)); + + if FindFirst(DirPath + '*', faAnyFile, Search) = 0 then + try + repeat + if (Search.Name = '.') or (Search.Name = '..') then + Continue; + + EntryPath := DirPath + Search.Name; + + if (Search.Attr and faDirectory) <> 0 then + FindAllFilesRecursive(EntryPath, AMask, AList) + else if MatchesMaskSimple(Search.Name, AMask) then + AList.Add(EntryPath); + until FindNext(Search) <> 0; + finally + FindClose(Search); + end; +end; + +function FindAllFilesList(const ASearchDir, AMask: string): TStringList; +begin + Result := TStringList.Create; + FindAllFilesRecursive(ASearchDir, AMask, Result); +end; + // --------------------------------------------------------------------------- // Logging helpers // --------------------------------------------------------------------------- @@ -279,7 +350,7 @@ procedure RegisterAllPackages(const ASearchDir: string); List: TStringList; Each: string; begin - List := FindAllFiles(ASearchDir, '*.lpk', True); + List := FindAllFilesList(ASearchDir, '*.lpk'); try for Each in List do RegisterPackage(Each); @@ -297,7 +368,7 @@ procedure BuildAllProjects; List: TStringList; Each: string; begin - List := FindAllFiles(Target, '*.lpi', True); + List := FindAllFilesList(Target, '*.lpi'); try for Each in List do if IsTestProject(Each) then diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index caa6810..9a2d598 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -25,10 +25,11 @@ jobs: - ubuntu-latest - ubuntu-24.04-arm - windows-latest + - macos-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: true @@ -38,7 +39,7 @@ jobs: run: | set -xeuo pipefail sudo bash -c 'apt-get update; apt-get install -y lazarus' >/dev/null - instantfpc -Fu/usr/lib/lazarus/*/components/lazutils .github/workflows/make.pas + instantfpc .github/workflows/make.pas - name: Build on Linux (AArch64) if: runner.os == 'Linux' && runner.arch == 'ARM64' @@ -46,7 +47,21 @@ jobs: run: | set -xeuo pipefail sudo bash -c 'apt-get update; apt-get install -y lazarus' >/dev/null - instantfpc -Fu/usr/lib/lazarus/*/components/lazutils .github/workflows/make.pas + instantfpc .github/workflows/make.pas + + - name: Install Lazarus on macOS + if: runner.os == 'macOS' + uses: gcarreno/setup-lazarus@v3 + with: + lazarus-version: stable + with-cache: false + + - name: Build on macOS + if: runner.os == 'macOS' + shell: bash + run: | + set -xeuo pipefail + instantfpc .github/workflows/make.pas - name: Build on Windows if: runner.os == 'Windows' @@ -72,4 +87,4 @@ jobs: Get-Command instantfpc Write-Host "Building make.pas..." - instantfpc '-FuC:\Lazarus\components\lazutils' .github/workflows/make.pas \ No newline at end of file + instantfpc .github/workflows/make.pas \ No newline at end of file