Browse Source

return use/bgrabitmap and use/bgracontrols

Artem V. Ageev 7 months ago
parent
commit
cbfde42522
4 changed files with 69 additions and 77 deletions
  1. 61 77
      .github/workflows/make.pas
  2. 6 0
      .gitmodules
  3. 1 0
      use/bgrabitmap
  4. 1 0
      use/bgracontrols

+ 61 - 77
.github/workflows/make.pas

@@ -15,12 +15,22 @@ uses
 
 const
   Target: string = 'lazpaint';
-  Dependencies: array of string = ('BGRAControls', 'BGRABitmap');
+  Dependencies: array of string = ();
 
 type
+  TLog = (audit, info, error);
   Output = record
-    Code: boolean;
-    Output: ansistring;
+    Success: boolean;
+    Output: string;
+  end;
+
+  procedure OutLog(Knd: TLog; Msg: string);
+  begin
+    case Knd of
+        error: Writeln(stderr, #27'[31m', Msg, #27'[0m');
+        info:  Writeln(stderr, #27'[32m', Msg, #27'[0m');
+        audit: Writeln(stderr, #27'[33m', Msg, #27'[0m');
+    end;
   end;
 
   function CheckModules: Output;
@@ -28,7 +38,7 @@ type
     if FileExists('.gitmodules') then
       if RunCommand('git', ['submodule', 'update', '--init', '--recursive',
         '--force', '--remote'], Result.Output) then
-        Writeln(stderr, #27'[33m', Result.Output, #27'[0m');
+        OutLog(info, Result.Output);
   end;
 
   function AddPackage(Path: string): Output;
@@ -37,14 +47,14 @@ type
     begin
       Expression :=
         {$IFDEF MSWINDOWS}
-        '(cocoa|x11|_template)'
-      {$ELSE}
-        '(cocoa|gdi|_template)'
-      {$ENDIF}
+          '(cocoa|x11|_template)'
+        {$ELSE}
+          '(cocoa|gdi|_template)'
+        {$ENDIF}
       ;
       if not Exec(Path) and RunCommand('lazbuild', ['--add-package-link', Path],
         Result.Output) then
-        Writeln(stderr, #27'[33m', 'added ', Path, #27'[0m');
+        OutLog(audit, 'added ' + Path);
       Free;
     end;
   end;
@@ -53,17 +63,17 @@ type
   var
     Line: string;
   begin
-    Write(stderr, #27'[33m', 'build from ', Path, #27'[0m');
+    OutLog(audit, 'build from ' + Path);
     try
-      Result.Code := RunCommand('lazbuild', ['--build-all', '--recursive',
+      Result.Success := RunCommand('lazbuild', ['--build-all', '--recursive',
         '--no-write-project', Path], Result.Output);
-      if Result.Code then
+      if Result.Success then
         for Line in SplitString(Result.Output, LineEnding) do
         begin
           if ContainsStr(Line, 'Linking') then
           begin
             Result.Output := SplitString(Line, ' ')[2];
-            Writeln(stderr, #27'[32m', ' to ', Result.Output, #27'[0m');
+            OutLog(info, ' to ' + Result.Output);
             break;
           end;
         end
@@ -75,16 +85,13 @@ type
           begin
             Expression := '(Fatal|Error):';
             if Exec(Line) then
-            begin
-              WriteLn(stderr);
-              Writeln(stderr, #27'[31m', Line, #27'[0m');
-            end;
+              OutLog(error, #10 + Line);
             Free;
           end;
       end;
     except
       on E: Exception do
-        WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message);
+        OutLog(error, E.ClassName + #13#10 + E.Message);
     end;
   end;
 
@@ -94,22 +101,22 @@ type
   begin
     Result := BuildProject(Path);
     Temp:= Result.Output;
-    if Result.Code then
+    if Result.Success then
         try
           if not RunCommand(Temp, ['--all', '--format=plain', '--progress'], Result.Output) then
-            begin
-              ExitCode += 1;
-              WriteLn(stderr, Result.Output);
-            end;
+          begin
+            ExitCode += 1;
+            OutLog(error, Result.Output);
+          end;
         except
           on E: Exception do
-            WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message);
+            OutLog(error, E.ClassName + #13#10 + E.Message);
         end;
   end;
 
-  function AddOPM(Each: string): string;
+  function InstallOPM(Each: string): string;
   var
-    TempFile, Url: string;
+    OutFile, Uri: string;
     Zip: TStream;
   begin
     Result :=
@@ -119,18 +126,18 @@ type
       GetEnvironmentVariable('HOME') + '/.lazarus/onlinepackagemanager/packages/'
       {$ENDIF}
       + Each;
-    TempFile := GetTempFileName;
-    Url := 'https://packages.lazarus-ide.org/' + Each + '.zip';
+    OutFile := GetTempFileName;
+    Uri := 'https://packages.lazarus-ide.org/' + Each + '.zip';
     if not DirectoryExists(Result) then
     begin
-      Zip := TFileStream.Create(TempFile, fmCreate or fmOpenWrite);
+      Zip := TFileStream.Create(OutFile, fmCreate or fmOpenWrite);
       with TFPHttpClient.Create(nil) do
       begin
         try
           AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)');
           AllowRedirect := True;
-          Get(Url, Zip);
-          WriteLn(stderr, 'Download from ', Url, ' to ', TempFile);
+          Get(Uri, Zip);
+          OutLog(audit, 'Download from ' + Uri + ' to ' + OutFile);
         finally
           Free;
         end;
@@ -140,62 +147,62 @@ type
       with TUnZipper.Create do
       begin
         try
-          FileName := TempFile;
+          FileName := OutFile;
           OutputPath := Result;
           Examine;
           UnZipAllFiles;
-          WriteLn(stderr, 'Unzip from ', TempFile, ' to ', Result);
+          OutLog(audit, 'Unzip from ' + OutFile + ' to ' + Result);
         finally
           Free;
         end;
       end;
-      DeleteFile(TempFile);
+      DeleteFile(OutFile);
     end;
   end;
 
   function LintPython(Path: string): Output;
   begin
-    WriteLn(stderr, #27'[33m', 'Linting Python file: ', Path, #27'[0m');
+    OutLog(audit, 'Linting Python file: ' + Path);
     if not RunCommand('python3', ['-m', 'pylint', Path], Result.Output) then
       begin
-        Writeln(stderr, #27'[31m', Result.Output, #27'[0m');
+        OutLog(error, Result.Output);
         //ExitCode += 1;
       end
   end;
 
   function LintC(Path: string): Output;
   begin
-    WriteLn(stderr, #27'[33m', 'Linting C file: ', Path, #27'[0m');
+    OutLog(audit, 'Linting C file: ' + Path);
     if not RunCommand('cppcheck', ['--language=c', '--enable=warning,style', '--template=gcc', Path], Result.Output) then
       begin
-        Writeln(stderr, #27'[31m', Result.Output, #27'[0m');
+        OutLog(error, Result.Output);
         //ExitCode += 1;
       end
   end;
 
   function LintShell(Path: string): Output;
   begin
-    WriteLn(stderr, #27'[33m', 'Linting Shell file: ', Path, #27'[0m');
+    OutLog(audit, 'Linting Shell file: ' + Path);
     if not RunCommand('shellcheck', ['--external-sources', Path], Result.Output) then
       begin
-        Writeln(stderr, #27'[31m', Result.Output, #27'[0m');
+        OutLog(error, Result.Output);
         //ExitCode += 1;
       end
   end;
 
-  procedure Main;
+  procedure BuildAll;
   var
     Each, Item: string;
     List: TStringList;
   begin
     CheckModules;
     InitSSLInterface;
-    for Each in Dependencies do
+    for Item in Dependencies do
     begin
-      List := FindAllFiles(AddOPM(Each), '*.lpk', True);
+      List := FindAllFiles(InstallOPM(Item), '*.lpk', True);
       try
-        for Item in List do
-          AddPackage(Item);
+        for Each in List do
+          AddPackage(Each);
       finally
         List.Free;
       end;
@@ -210,44 +217,21 @@ type
     List := FindAllFiles(Target, '*.lpi', True);
     try
       for Each in List do
-        if ContainsStr(ReadFileToString(ReplaceStr(Each, '.lpi', '.lpr')),
-          'consoletestrunner') then
-          RunTest(Each)
-        else
-          BuildProject(Each);
-    finally
-      List.Free;
-    end;
-    {$IFDEF LINUX}
-    List := FindAllFiles(GetCurrentDir, '*.py', True);
-    try
-      for Each in List do
-        LintPython(Each);
-    finally
-      List.Free;
-    end;
-    List := FindAllFiles(GetCurrentDir, '*.c', True);
-    try
-      for Each in List do
-        LintC(Each);
-    finally
-      List.Free;
-    end;
-    List := FindAllFiles(GetCurrentDir, '*.sh', True);
-    try
-      for Each in List do
-        LintShell(Each);
+        if not ContainsStr(Each, 'zengl') then
+          if ContainsStr(ReadFileToString(ReplaceStr(Each, '.lpi', '.lpr')),
+            'consoletestrunner') then
+            RunTest(Each)
+          else
+            BuildProject(Each);
     finally
       List.Free;
     end;
-    {$ENDIF}
-    WriteLn(stderr);
     if ExitCode <> 0 then
-      WriteLn(stderr, #27'[31m', 'Errors: ', ExitCode, #27'[0m')
+      OutLog(error, #10 + 'Errors: ' + IntToStr(ExitCode))
     else
-      WriteLn(stderr, #27'[32m', 'Errors: ', ExitCode, #27'[0m');
+      OutLog(info, #10 + 'Errors: ' + IntToStr(ExitCode));
   end;
 
 begin
-  Main;
+  BuildAll;
 end.

+ 6 - 0
.gitmodules

@@ -0,0 +1,6 @@
+[submodule "use/bgrabitmap"]
+	path = use/bgrabitmap
+	url = [email protected]:bgrabitmap/bgrabitmap.git
+[submodule "use/bgracontrols"]
+	path = use/bgracontrols
+	url = [email protected]:bgrabitmap/bgracontrols.git

+ 1 - 0
use/bgrabitmap

@@ -0,0 +1 @@
+Subproject commit 311fa8d5f9b2baabdb3490ded5f721e68ea67ae2

+ 1 - 0
use/bgracontrols

@@ -0,0 +1 @@
+Subproject commit 555c0df8e2c52c60a9099d1bfd7b14c19852d5a4