[packages/fpc] - up to 3.2.2

baggins baggins at pld-linux.org
Sun Aug 20 14:49:09 CEST 2023


commit 361caa6b0de4842c199733b2c290845a036417c8
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Aug 20 14:00:13 2023 +0200

    - up to 3.2.2

 fpc-gdb.patch    |  45 -------
 fpc-man.patch    |   5 +-
 fpc-r32374.patch | 225 --------------------------------
 fpc-r34749.patch | 390 -------------------------------------------------------
 fpc.spec         |  66 ++++++----
 5 files changed, 45 insertions(+), 686 deletions(-)
---
diff --git a/fpc.spec b/fpc.spec
index c4757b5..8cec662 100644
--- a/fpc.spec
+++ b/fpc.spec
@@ -1,6 +1,5 @@
 #
 # Conditional build:
-%bcond_without	ide	# FPC IDE
 %bcond_with	gdb	# GDB support in FPC IDE
 %bcond_without	doc	# documentation
 
@@ -9,44 +8,45 @@ Summary(pl.UTF-8):	Free Pascal - 32-bitowy kompilator języka Pascal
 Summary(ru.UTF-8):	Свободный компилятор Pascal
 Summary(uk.UTF-8):	Вільний компілятор Pascal
 Name:		fpc
-Version:	3.0.2
+Version:	3.2.2
 Release:	1
 License:	GPL v2+
 Group:		Development/Languages
 Source0:	ftp://ftp.freepascal.org/pub/fpc/dist/%{version}/source/%{name}build-%{version}.tar.gz
-# Source0-md5:	c0fc1662dbe45c1e3f66ed780a443849
+# Source0-md5:	3681ae4a208be4f64ec65e832a9a702d
 Source1:	ftp://ftp.freepascal.org/pub/fpc/dist/%{version}/i386-linux/%{name}-%{version}.i386-linux.tar
-# Source1-md5:	a58c3a2d7f8625d434abe9518e4ca38c
+# Source1-md5:	18354e51309a34b0efe7702633568a1e
 Source2:	ftp://ftp.freepascal.org/pub/fpc/dist/%{version}/x86_64-linux/%{name}-%{version}.x86_64-linux.tar
-# Source2-md5:	e5721c1843cff301c5b46abfee17c890
+# Source2-md5:	0186779de0c9caee073fc1394afbee56
 Patch0:		%{name}-skip-dev-dot.patch
 Patch1:		%{name}-link.patch
-Patch2:		%{name}-gdb.patch
-Patch3:		fpc-r32374.patch
 Patch4:		fpcdocs-r1260.patch
 Patch5:		fpc-man.patch
-Patch6:		fpc-r34749.patch
 URL:		http://www.freepascal.org/
-BuildRequires:	binutils-devel >= 3:2.17.50
-BuildRequires:	gpm-devel
-BuildRequires:	ncurses-devel
-BuildRequires:	rpmbuild(macros) >= 1.213
-%if %{with ide}
 BuildRequires:	babeltrace-devel
+BuildRequires:	binutils-devel >= 3:2.17.50
 BuildRequires:	expat-devel
-%{?with_gdb:BuildRequires:	gdb-lib >= 7.2-7}
+BuildRequires:	gpm-devel
 BuildRequires:	guile-devel
-BuildRequires:	python-devel
-BuildRequires:	readline-devel
 BuildRequires:	libselinux-devel
+BuildRequires:	ncurses-devel
+BuildRequires:	readline-devel
+BuildRequires:	rpmbuild(macros) >= 1.213
 BuildRequires:	xz-devel
 BuildRequires:	zlib-devel
+%if %{with gdb}
+BuildRequires:	gdb-lib >= 7.2-7}
+BuildRequires:	python-devel
 %endif
 %if %{with doc}
 BuildRequires:	tetex-fonts-jknappen
 BuildRequires:	tetex-format-pdflatex
+BuildRequires:	tetex-latex-imakeidx
 BuildRequires:	tetex-makeindex
 BuildRequires:	tetex-metafont
+BuildRequires:	texlive-latex-enumitem
+BuildRequires:	texlive-latex-ucs
+BuildRequires:	texlive-tex-xkeyval
 BuildRequires:	texlive-xetex
 %endif
 Requires:	binutils
@@ -57,6 +57,8 @@ ExclusiveArch:	%{ix86} %{x8664}
 # ppc64 ftp://ftp.freepascal.org/pub/fpc/dist/3.0.0/powerpc64-linux/fpc-3.0.0.powerpc64-linux.tar
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
+%define		_debugsource_packages	0
+
 %description
 Free Pascal is a 32-bit Pascal compiler. Free Pascal is designed to
 be, as much as possible, source compatible with Turbo Pascal 7.0 and
@@ -135,11 +137,8 @@ Dokumentacja do fpc w formacie PDF.
 %setup -q -n %{name}build-%{version}
 %patch0 -p1
 %patch1 -p1
-%patch2 -p1
-%patch3 -p0
 %patch4 -p0
 %patch5 -p1
-%patch6 -p0
 
 %ifarch %{ix86}
 tar xf %{SOURCE1}
@@ -195,12 +194,21 @@ find fpcsrc -name Makefile -o -name fpcmake.ini -o -name fpmkunit.pp | \
 # save for fpc-src
 install -d fpc-src
 cp -af fpcsrc/* fpc-src
-rm -r fpc-src/{ide,tests}
+rm -r fpc-src/tests
 
 %if 0%{?debug:1}
 find fpcsrc -name Makefile | xargs %{__sed} -i -e 's/-Xs//'
 %endif
 
+%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+bash(\s|$),#!/bin/bash\1,' \
+      fpc-src/packages/fpmkunit/examples/ppu2fpmake.sh \
+      fpc-src/packages/gdbint/gen-gdblib-inc.sh \
+      fpc-src/packages/gtk2/src/gtk2x11/scripts/gdkx11_h2pas.sh \
+      fpc-src/rtl/unix/scripts/check_consts.sh \
+      fpc-src/rtl/unix/scripts/check_errno.sh \
+      fpc-src/rtl/unix/scripts/check_errnostr.sh \
+      fpc-src/rtl/unix/scripts/check_sys.sh
+
 %build
 # use ld.bfd
 [ -d our-ld ] || install -d our-ld
@@ -246,10 +254,11 @@ esac
 	rtl_clean \
 	packages_clean \
 	utils_clean \
-	%{?with_ide: ide_clean installer_clean} \
+	installer_clean \
 	rtl_all \
 	packages_all \
-	utils_all %{?with_ide:ide_all installer_all}
+	utils_all \
+	installer_all
 
 %if %{with doc}
 export save_size=10000
@@ -272,7 +281,6 @@ FPCMAKE=`pwd`/fpcsrc/utils/fpcm/bin/%{_barch}-linux/fpcmake
 	compiler_distinstall \
 	rtl_distinstall \
 	packages_distinstall \
-	%{?with_ide:ide_distinstall} \
 	utils_distinstall \
 	PP="$NEWPP" \
 	FPCMAKE="$FPCMAKE" \
@@ -330,6 +338,7 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_bindir}/chmcmd
 %attr(755,root,root) %{_bindir}/chmls
 %attr(755,root,root) %{_bindir}/cldrparser
+%attr(755,root,root) %{_bindir}/compileserver
 %attr(755,root,root) %{_bindir}/data2inc
 %attr(755,root,root) %{_bindir}/delp
 %attr(755,root,root) %{_bindir}/fd2pascal
@@ -341,12 +350,15 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_bindir}/h2pas
 %attr(755,root,root) %{_bindir}/h2paspp
 %attr(755,root,root) %{_bindir}/instantfpc
+%attr(755,root,root) %{_bindir}/json2pas
 %attr(755,root,root) %{_bindir}/makeskel
+%attr(755,root,root) %{_bindir}/mka64ins
 %attr(755,root,root) %{_bindir}/mkarmins
 %attr(755,root,root) %{_bindir}/mkinsadd
 %attr(755,root,root) %{_bindir}/mkx86ins
 %attr(755,root,root) %{_bindir}/pas2fpm
 %attr(755,root,root) %{_bindir}/pas2jni
+%attr(755,root,root) %{_bindir}/pas2js
 %attr(755,root,root) %{_bindir}/pas2ut
 %attr(755,root,root) %{_bindir}/plex
 %attr(755,root,root) %{_bindir}/postw32
@@ -361,10 +373,14 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_bindir}/rstconv
 %attr(755,root,root) %{_bindir}/unihelper
 %attr(755,root,root) %{_bindir}/unitdiff
+%attr(755,root,root) %{_bindir}/webidl2pas
 # TODO: move the below files to data dir
 # - JSON resources(?)
 %{_bindir}/makeskel.rsj
 %{_bindir}/ptop.rsj
+%{_bindir}/pas2ut.rsj
+%{_bindir}/rstconv.rsj
+%{_bindir}/unitdiff.rsj
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fpc.cfg
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fppkg.cfg
 %dir %{_sysconfdir}/fppkg
@@ -379,6 +395,7 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_libdir}/%{name}/%{version}/ld
 %attr(755,root,root) %{_libdir}/%{name}/%{version}/ppc%{_bname}
 %attr(755,root,root) %{_libdir}/%{name}/%{version}/samplecfg
+%attr(755,root,root) %{_libdir}/libpas2jslib.so
 %{_mandir}/man1/bin2obj.1*
 %{_mandir}/man1/chmcmd.1*
 %{_mandir}/man1/chmls.1*
@@ -417,13 +434,13 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man5/fpcmake.5*
 %{_mandir}/man5/ptop.cfg.5*
 
-%if %{with ide}
 %files ide
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_bindir}/fp
 # TODO: move the below files to data dir
 # - ANSI art file used by fp binary
 %{_bindir}/fp.ans
+%{_bindir}/fp.rsj
 # - IDE command templates
 %{_bindir}/cvsco.tdf
 %{_bindir}/cvsdiff.tdf
@@ -436,7 +453,6 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/program.pt
 %{_bindir}/unit.pt
 %{_libdir}/%{name}/%{version}/ide
-%endif
 
 %files src
 %defattr(644,root,root,755)
diff --git a/fpc-gdb.patch b/fpc-gdb.patch
deleted file mode 100644
index 428dc3f..0000000
--- a/fpc-gdb.patch
+++ /dev/null
@@ -1,45 +0,0 @@
---- fpcbuild-2.6.4/fpcsrc/packages/gdbint/src/gdbint.pp~	2016-04-01 17:53:51.000000000 +0900
-+++ fpcbuild-2.6.4/fpcsrc/packages/gdbint/src/gdbint.pp	2016-04-01 23:08:14.978738263 +0900
-@@ -59,6 +59,42 @@
- 
- {$undef GDB_VERSION_RECOGNIZED}
- 
-+{ 8.0 }
-+{$ifdef GDB_V800}
-+  {$info using gdb 8.0.x}
-+  {$define GDB_VERSION_RECOGNIZED}
-+  {$define GDB_VER_GE_800}
-+  {$define NEED_EXTERNAL_CVAR}
-+  {$LINKLIB stdc++}
-+  {$LINKLIB gcc_s}
-+{$endif}
-+
-+{$ifdef GDB_VER_GE_800}
-+  {$define GDB_VER_GE_711}
-+{$endif}
-+
-+{ 7.11.x }
-+{$ifdef GDB_V711}
-+  {$info using gdb 7.11.x}
-+  {$define GDB_VERSION_RECOGNIZED}
-+  {$define GDB_VER_GE_711}
-+{$endif}
-+
-+{$ifdef GDB_VER_GE_711}
-+  {$define GDB_VER_GE_710}
-+{$endif}
-+
-+{ 7.10.x }
-+{$ifdef GDB_V710}
-+  {$info using gdb 7.10.x}
-+  {$define GDB_VERSION_RECOGNIZED}
-+  {$define GDB_VER_GE_710}
-+{$endif}
-+
-+{$ifdef GDB_VER_GE_710}
-+  {$define GDB_VER_GE_709}
-+{$endif}
-+
- { 7.9.x }
- {$ifdef GDB_V709}
-   {$info using gdb 7.9.x}
diff --git a/fpc-man.patch b/fpc-man.patch
index 4fe477e..d1ccc4d 100644
--- a/fpc-man.patch
+++ b/fpc-man.patch
@@ -1,8 +1,11 @@
 --- fpcbuild-3.0.0/install/man/Makefile.orig	2011-06-19 20:40:37.000000000 +0200
 +++ fpcbuild-3.0.0/install/man/Makefile	2016-12-17 20:15:03.522162624 +0100
-@@ -31,5 +31,3 @@
+@@ -31,8 +31,6 @@
  	$(GINSTALL) -d -m 755 $(INSTALL_MANDIR)/man5
  	$(GINSTALL) -c -m 644 man1/*.1 $(INSTALL_MANDIR)/man1
  	$(GINSTALL) -c -m 644 man5/*.5 $(INSTALL_MANDIR)/man5
 -	find man1/*.1 -exec gzip -9f $(INSTALL_MANDIR)/'{}' \;
 -	find man5/*.5 -exec gzip -9f $(INSTALL_MANDIR)/'{}' \;
+ ifdef NOIDE
+ 	rm $(INSTALL_MANDIR)/man1/fp.*
+ endif
diff --git a/fpc-r32374.patch b/fpc-r32374.patch
deleted file mode 100644
index 6207206..0000000
--- a/fpc-r32374.patch
+++ /dev/null
@@ -1,225 +0,0 @@
-Index: utils/fpdoc/dw_html.pp
-===================================================================
---- fpcsrc/utils/fpdoc/dw_html.pp	(revision 32373)
-+++ fpcsrc/utils/fpdoc/dw_html.pp	(revision 32374)
-@@ -2471,7 +2471,7 @@
-     try
-       B.BuildTree(AList);
-       // Classes
--      WriteXMLFile(B.ClassTree,'tree.xml');
-+      // WriteXMLFile(B.ClassTree,'tree.xml');
-       // Dummy TObject
-       E:=B.ClassTree.DocumentElement;
-       PushClassList;
-Index: utils/fpdoc/mkfpdoc.pp
-===================================================================
---- fpcsrc/utils/fpdoc/mkfpdoc.pp	(revision 32373)
-+++ fpcsrc/utils/fpdoc/mkfpdoc.pp	(revision 32374)
-@@ -19,6 +19,8 @@
- 
-   TFPDocCreator = Class(TComponent)
-   Private
-+    FBaseDescrDir: String;
-+    FBaseInputDir: String;
-     FCurPackage : TFPDocPackage;
-     FProcessedUnits : TStrings;
-     FOnLog: TPasParserLogHandler;
-@@ -28,7 +30,11 @@
-     FVerbose: Boolean;
-     function GetOptions: TEngineOptions;
-     function GetPackages: TFPDocPackages;
-+    procedure SetBaseDescrDir(AValue: String);
-+    procedure SetBaseInputDir(AValue: String);
-   Protected
-+    Function FixInputFile(Const AFileName : String) : String;
-+    Function FixDescrFile(Const AFileName : String) : String;
-     Procedure DoBeforeEmitNote(Sender : TObject; Note : TDomElement; Var EmitNote : Boolean); virtual;
-     procedure HandleOnParseUnit(Sender: TObject; const AUnitName: String; out AInputFile, OSTarget, CPUTarget: String);
-     procedure SetVerbose(AValue: Boolean); virtual;
-@@ -49,6 +55,9 @@
-     // Easy access
-     Property Options : TEngineOptions Read GetOptions;
-     Property Packages : TFPDocPackages Read GetPackages;
-+    // When set, they will be prepended to non-absolute filenames.
-+    Property BaseInputDir : String Read FBaseInputDir Write SetBaseInputDir;
-+    Property BaseDescrDir : String Read FBaseDescrDir Write SetBaseDescrDir;
-   end;
- 
- implementation
-@@ -72,13 +81,13 @@
-     end;
- end;
- 
--procedure TFPDocCreator.DoLog(const Msg: String);
-+Procedure TFPDocCreator.DoLog(Const Msg: String);
- begin
-   If Assigned(OnLog) then
-     OnLog(Self,Msg);
- end;
- 
--procedure TFPDocCreator.DoLog(const Fmt: String; Args: array of const);
-+procedure TFPDocCreator.DoLog(Const Fmt: String; Args: Array of Const);
- begin
-   DoLog(Format(Fmt,Args));
- end;
-@@ -103,7 +112,7 @@
-        SplitInputFIleOption(S,UN,Opts);
-        if CompareText(ChangeFileExt(ExtractFileName(Un),''),AUnitName)=0 then
-          begin
--         AInputFile:=S;
-+         AInputFile:=FixInputFile(UN)+' '+Opts;
-          OSTarget:=FProject.Options.OSTarget;
-          CPUTarget:=FProject.Options.CPUTarget;
-          FProcessedUnits.Add(UN);
-@@ -123,13 +132,45 @@
-   Result:=FProject.Packages;
- end;
- 
--procedure TFPDocCreator.DoBeforeEmitNote(Sender: TObject; Note: TDomElement;
--  var EmitNote: Boolean);
-+Function TFPDocCreator.FixInputFile(Const AFileName: String): String;
- begin
-+  Result:=AFileName;
-+  If Result='' then exit;
-+  if (ExtractFileDrive(Result)='') and (Result[1]<>PathDelim) then
-+    Result:=BaseInputDir+Result;
-+end;
-+
-+Function TFPDocCreator.FixDescrFile(Const AFileName: String): String;
-+begin
-+  Result:=AFileName;
-+  If Result='' then exit;
-+  if (ExtractFileDrive(Result)='') and (Result[1]<>PathDelim) then
-+    Result:=BaseDescrDir+Result;
-+end;
-+
-+procedure TFPDocCreator.SetBaseDescrDir(AValue: String);
-+begin
-+  if FBaseDescrDir=AValue then Exit;
-+  FBaseDescrDir:=AValue;
-+  If FBaseDescrDir<>'' then
-+    FBaseDescrDir:=IncludeTrailingPathDelimiter(FBaseDescrDir);
-+end;
-+
-+procedure TFPDocCreator.SetBaseInputDir(AValue: String);
-+begin
-+  if FBaseInputDir=AValue then Exit;
-+  FBaseInputDir:=AValue;
-+  If FBaseInputDir<>'' then
-+    FBaseInputDir:=IncludeTrailingPathDelimiter(FBaseInputDir);
-+end;
-+
-+Procedure TFPDocCreator.DoBeforeEmitNote(Sender: TObject; Note: TDomElement;
-+  Var EmitNote: Boolean);
-+begin
-   EmitNote:=True;
- end;
- 
--constructor TFPDocCreator.Create(AOwner: TComponent);
-+Constructor TFPDocCreator.Create(AOwner: TComponent);
- begin
-   inherited Create(AOwner);
-   FProject:=TFPDocProject.Create(Self);
-@@ -139,7 +180,7 @@
-   FProcessedUnits:=TStringList.Create;
- end;
- 
--destructor TFPDocCreator.Destroy;
-+Destructor TFPDocCreator.Destroy;
- begin
-   FreeAndNil(FProcessedUnits);
-   FreeAndNil(FProject);
-@@ -180,7 +221,8 @@
-     Engine.WriteContentFile(APackage.ContentFile);
- end;
- 
--procedure TFPDocCreator.CreateDocumentation(APackage: TFPDocPackage; ParseOnly : Boolean);
-+Procedure TFPDocCreator.CreateDocumentation(APackage: TFPDocPackage;
-+  ParseOnly: Boolean);
- 
- var
-   i,j: Integer;
-@@ -201,7 +243,7 @@
-       Engine.ReadContentFile(Arg, Cmd);
-       end;
-     for i := 0 to APackage.Descriptions.Count - 1 do
--      Engine.AddDocFile(APackage.Descriptions[i],Options.donttrim);
-+      Engine.AddDocFile(FixDescrFile(APackage.Descriptions[i]),Options.donttrim);
-     Engine.SetPackageName(APackage.Name);
-     Engine.Output:=APackage.Output;
-     Engine.OnLog:=Self.OnLog;
-@@ -216,10 +258,11 @@
-     for i := 0 to APackage.Inputs.Count - 1 do
-       try
-         SplitInputFileOption(APackage.Inputs[i],Cmd,Arg);
-+        Cmd:=FixInputFIle(Cmd);
-         if FProcessedUnits.IndexOf(Cmd)=-1 then
-           begin
-           FProcessedUnits.Add(Cmd);
--          ParseSource(Engine, APackage.Inputs[i], Options.OSTarget, Options.CPUTarget);
-+          ParseSource(Engine,Cmd+' '+Arg, Options.OSTarget, Options.CPUTarget);
-           end;
-       except
-         on e: EParserError do
-@@ -239,7 +282,7 @@
-   end;
- end;
- 
--procedure TFPDocCreator.CreateProjectFile(Const AFileName: string);
-+Procedure TFPDocCreator.CreateProjectFile(Const AFileName: string);
- begin
-   With TXMLFPDocOptions.Create(Self) do
-   try
-@@ -249,7 +292,7 @@
-   end;
- end;
- 
--procedure TFPDocCreator.LoadProjectFile(const AFileName: string);
-+Procedure TFPDocCreator.LoadProjectFile(Const AFileName: string);
- begin
-   With TXMLFPDocOptions.Create(self) do
-     try
-Index: utils/fpdoc/fpdoc.pp
-===================================================================
---- fpcsrc/utils/fpdoc/fpdoc.pp	(revision 32373)
-+++ fpcsrc/utils/fpdoc/fpdoc.pp	(revision 32374)
-@@ -73,6 +73,8 @@
- 
- begin
-   Writeln(Format(SCmdLineHelp,[ExtractFileName(Paramstr(0))]));
-+  Writeln(SUsageOption008);
-+  Writeln(SUsageOption009);
-   Writeln(SUsageOption010);
-   Writeln(SUsageOption020);
-   Writeln(SUsageOption030);
-@@ -311,6 +313,8 @@
-       AddToFileList(SelectedPackage.Descriptions, Arg)
-     else if (Cmd = '--descr-dir') then
-       AddDirToFileList(SelectedPackage.Descriptions, Arg, '*.xml')
-+    else if (Cmd = '--base-descr-dir') then
-+      FCreator.BaseDescrDir:=Arg
-     else if (Cmd = '-f') or (Cmd = '--format') then
-       begin
-       Arg:=UpperCase(Arg);
-@@ -323,6 +327,8 @@
-       FCreator.Options.Language := Arg
-     else if (Cmd = '-i') or (Cmd = '--input') then
-       AddToFileList(SelectedPackage.Inputs, Arg)
-+    else if (Cmd = '--base-input-dir') then
-+      FCreator.BaseInputDir:=Arg
-     else if (Cmd = '--input-dir') then
-       begin
-       AddDirToFileList(SelectedPackage.Inputs, Arg,'*.pp');
-Index: utils/fpdoc/dglobals.pp
-===================================================================
---- fpcsrc/utils/fpdoc/dglobals.pp	(revision 32373)
-+++ fpcsrc/utils/fpdoc/dglobals.pp	(revision 32374)
-@@ -142,6 +142,8 @@
-   SCopyright2      = '(c) 2005 - 2012 various FPC contributors';
- 
-   SCmdLineHelp     = 'Usage: %s [options]';
-+  SUsageOption008  = '--base-descr-dir=DIR prefix all description files with this directory';
-+  SUsageOption009  = '--base-input-dir=DIR prefix all input files with this directory';
-   SUsageOption010  = '--content         Create content file for package cross-references';
-   SUsageOption020  = '--cputarget=value Set the target CPU for the scanner.';
-   SUsageOption030  = '--descr=file      use file as description file, e.g.: ';
diff --git a/fpc-r34749.patch b/fpc-r34749.patch
deleted file mode 100644
index b4919eb..0000000
--- a/fpc-r34749.patch
+++ /dev/null
@@ -1,390 +0,0 @@
-Index: fpcsrc/utils/fpdoc/dglobals.pp
-===================================================================
---- fpcsrc/utils/fpdoc/dglobals.pp	(revision 34748)
-+++ fpcsrc/utils/fpdoc/dglobals.pp	(revision 34749)
-@@ -161,6 +161,7 @@
-   SUsageOption120  = '                  At least one input option is required.';
-   SUsageOption130  = '--input-dir=Dir   Add All *.pp and *.pas files in Dir to list of input files';
-   SUsageOption140  = '--lang=lng        Select output language.';
-+  SUsageOption145  = '--macro=name=value Define a macro to preprocess the project file with.';
-   SUsageOption150  = '--ostarget=value  Set the target OS for the scanner.';
-   SUsageOption160  = '--output=name     use name as the output name.';
-   SUsageOption170  = '                  Each backend interprets this as needed.';
-@@ -183,6 +184,7 @@
-   SUsageFormats        = 'The following output formats are supported by this fpdoc:';
-   SUsageBackendHelp    = 'Specify an output format, combined with --help to get more help for this backend.';
-   SUsageFormatSpecific = 'Output format "%s" supports the following options:';
-+  SCmdLineErrInvalidMacro     = 'Macro needs to be in the form name=value';
- 
-   SCmdLineInvalidOption       = 'Ignoring unknown option "%s"';
-   SCmdLineInvalidFormat       = 'Invalid format "%s" specified';
-Index: fpcsrc/utils/fpdoc/mkfpdoc.pp
-===================================================================
---- fpcsrc/utils/fpdoc/mkfpdoc.pp	(revision 34748)
-+++ fpcsrc/utils/fpdoc/mkfpdoc.pp	(revision 34749)
-@@ -26,6 +26,7 @@
-     FOnLog: TPasParserLogHandler;
-     FPParserLogEvents: TPParserLogEvents;
-     FProject : TFPDocProject;
-+    FProjectMacros: TStrings;
-     FScannerLogEvents: TPScannerLogEvents;
-     FVerbose: Boolean;
-     function GetOptions: TEngineOptions;
-@@ -32,6 +33,7 @@
-     function GetPackages: TFPDocPackages;
-     procedure SetBaseDescrDir(AValue: String);
-     procedure SetBaseInputDir(AValue: String);
-+    procedure SetProjectMacros(AValue: TStrings);
-   Protected
-     Function FixInputFile(Const AFileName : String) : String;
-     Function FixDescrFile(Const AFileName : String) : String;
-@@ -58,6 +60,8 @@
-     // When set, they will be prepended to non-absolute filenames.
-     Property BaseInputDir : String Read FBaseInputDir Write SetBaseInputDir;
-     Property BaseDescrDir : String Read FBaseDescrDir Write SetBaseDescrDir;
-+    // Macros used when loading the project file
-+    Property ProjectMacros : TStrings Read FProjectMacros Write SetProjectMacros;
-   end;
- 
- implementation
-@@ -81,13 +85,13 @@
-     end;
- end;
- 
--Procedure TFPDocCreator.DoLog(Const Msg: String);
-+procedure TFPDocCreator.DoLog(const Msg: String);
- begin
-   If Assigned(OnLog) then
-     OnLog(Self,Msg);
- end;
- 
--procedure TFPDocCreator.DoLog(Const Fmt: String; Args: Array of Const);
-+procedure TFPDocCreator.DoLog(const Fmt: String; Args: array of const);
- begin
-   DoLog(Format(Fmt,Args));
- end;
-@@ -132,7 +136,7 @@
-   Result:=FProject.Packages;
- end;
- 
--Function TFPDocCreator.FixInputFile(Const AFileName: String): String;
-+function TFPDocCreator.FixInputFile(const AFileName: String): String;
- begin
-   Result:=AFileName;
-   If Result='' then exit;
-@@ -140,7 +144,7 @@
-     Result:=BaseInputDir+Result;
- end;
- 
--Function TFPDocCreator.FixDescrFile(Const AFileName: String): String;
-+function TFPDocCreator.FixDescrFile(const AFileName: String): String;
- begin
-   Result:=AFileName;
-   If Result='' then exit;
-@@ -164,13 +168,19 @@
-     FBaseInputDir:=IncludeTrailingPathDelimiter(FBaseInputDir);
- end;
- 
--Procedure TFPDocCreator.DoBeforeEmitNote(Sender: TObject; Note: TDomElement;
--  Var EmitNote: Boolean);
-+procedure TFPDocCreator.SetProjectMacros(AValue: TStrings);
- begin
-+  if FProjectMacros=AValue then Exit;
-+  FProjectMacros.Assign(AValue);
-+end;
-+
-+procedure TFPDocCreator.DoBeforeEmitNote(Sender: TObject; Note: TDomElement;
-+  var EmitNote: Boolean);
-+begin
-   EmitNote:=True;
- end;
- 
--Constructor TFPDocCreator.Create(AOwner: TComponent);
-+constructor TFPDocCreator.Create(AOwner: TComponent);
- begin
-   inherited Create(AOwner);
-   FProject:=TFPDocProject.Create(Self);
-@@ -178,12 +188,14 @@
-   FProject.Options.CPUTarget:=DefCPUTarget;
-   FProject.Options.OSTarget:=DefOSTarget;
-   FProcessedUnits:=TStringList.Create;
-+  FProjectMacros:=TStringList.Create;
- end;
- 
--Destructor TFPDocCreator.Destroy;
-+destructor TFPDocCreator.Destroy;
- begin
-   FreeAndNil(FProcessedUnits);
-   FreeAndNil(FProject);
-+  FreeAndNil(FProjectMacros);
-   inherited Destroy;
- end;
- 
-@@ -221,7 +233,7 @@
-     Engine.WriteContentFile(APackage.ContentFile);
- end;
- 
--Procedure TFPDocCreator.CreateDocumentation(APackage: TFPDocPackage;
-+procedure TFPDocCreator.CreateDocumentation(APackage: TFPDocPackage;
-   ParseOnly: Boolean);
- 
- var
-@@ -282,7 +294,7 @@
-   end;
- end;
- 
--Procedure TFPDocCreator.CreateProjectFile(Const AFileName: string);
-+procedure TFPDocCreator.CreateProjectFile(const AFileName: string);
- begin
-   With TXMLFPDocOptions.Create(Self) do
-   try
-@@ -292,11 +304,14 @@
-   end;
- end;
- 
--Procedure TFPDocCreator.LoadProjectFile(Const AFileName: string);
-+procedure TFPDocCreator.LoadProjectFile(const AFileName: string);
- begin
-   With TXMLFPDocOptions.Create(self) do
-     try
--      LoadOptionsFromFile(FProject,AFileName);
-+      if (ProjectMacros.Count>0) then
-+        LoadOptionsFromFile(FProject,AFileName,ProjectMacros)
-+      else
-+        LoadOptionsFromFile(FProject,AFileName,Nil);
-     finally
-       Free;
-     end;
-Index: fpcsrc/utils/fpdoc/fpdoc.pp
-===================================================================
---- fpcsrc/utils/fpdoc/fpdoc.pp	(revision 34748)
-+++ fpcsrc/utils/fpdoc/fpdoc.pp	(revision 34749)
-@@ -90,6 +90,7 @@
-   Writeln(SUsageOption120);
-   Writeln(SUsageOption130);
-   Writeln(SUsageOption140);
-+  Writeln(SUsageOption145);
-   Writeln(SUsageOption150);
-   Writeln(SUsageOption160);
-   Writeln(SUsageOption170);
-@@ -181,11 +182,12 @@
- Const
-   SOptProject = '--project=';
-   SOptPackage = '--package=';
--  
-+  SOptMacro = '--macro=';
-+
-   Function ProjectOpt(Const s : string) : boolean;
- 
-   begin
--    Result:=(Copy(s,1,3)='-p=') or (Copy(s,1,Length(SOptProject))=SOptProject);
-+    Result:=(Copy(s,1,3)='-p=') or (Copy(s,1,Length(SOptProject))=SOptProject) or (Copy(s,1,Length(SOptMacro))=SOptMacro);
-   end;
- 
-   Function PackageOpt(Const s : string) : boolean;
-@@ -286,7 +288,7 @@
- 
- var
-   i: Integer;
--  Cmd, Arg: String;
-+  ProjectFileName,Cmd, Arg: String;
- 
- begin
-   if (s = '-h') or (s = '--help') then
-@@ -325,6 +327,12 @@
-       AddDirToFileList(SelectedPackage.Descriptions, Arg, '*.xml')
-     else if (Cmd = '--base-descr-dir') then
-       FCreator.BaseDescrDir:=Arg
-+    else if (Cmd = '--macro') then
-+      begin
-+      If Pos('=',Arg)=0 then
-+        WriteLn(StdErr, Format(SCmdLineErrInvalidMacro, [Arg]));
-+      FCreator.ProjectMacros.Add(Arg);
-+      end
-     else if (Cmd = '-f') or (Cmd = '--format') then
-       begin
-       Arg:=UpperCase(Arg);
-@@ -384,23 +392,28 @@
- Procedure TFPDocApplication.DoRun;
- 
- begin
--{$IFDEF Unix}
--  gettext.TranslateResourceStrings('/usr/local/share/locale/%s/LC_MESSAGES/fpdoc.mo');
--{$ELSE}
--  gettext.TranslateResourceStrings('intl/fpdoc.%s.mo');
--{$ENDIF}
--  WriteLn(STitle);
--  WriteLn(Format(SVersion, [DefFPCVersion, DefFPCDate]));
--  WriteLn(SCopyright1);
--  WriteLn(SCopyright2);
--  WriteLn;
--  ParseCommandLine;
--  if (FWriteProjectFile<>'') then
--    FCreator.CreateProjectFile(FWriteProjectFile)
--  else
--    FCreator.CreateDocumentation(FPackage,FDryRun);
--  WriteLn(SDone);
--  Terminate;
-+  try
-+  {$IFDEF Unix}
-+    gettext.TranslateResourceStrings('/usr/local/share/locale/%s/LC_MESSAGES/fpdoc.mo');
-+  {$ELSE}
-+    gettext.TranslateResourceStrings('intl/fpdoc.%s.mo');
-+  {$ENDIF}
-+    WriteLn(STitle);
-+    WriteLn(Format(SVersion, [DefFPCVersion, DefFPCDate]));
-+    WriteLn(SCopyright1);
-+    WriteLn(SCopyright2);
-+    WriteLn;
-+    ParseCommandLine;
-+    if (FWriteProjectFile<>'') then
-+      FCreator.CreateProjectFile(FWriteProjectFile)
-+    else
-+      FCreator.CreateDocumentation(FPackage,FDryRun);
-+    WriteLn(SDone);
-+    Terminate;
-+  except
-+    ExitCode:=1;
-+    Raise;
-+  end;
- end;
- 
- constructor TFPDocApplication.Create(AOwner: TComponent);
-Index: fpcsrc/utils/fpdoc/fpdocxmlopts.pas
-===================================================================
---- fpcsrc/utils/fpdoc/fpdocxmlopts.pas	(revision 34748)
-+++ fpcsrc/utils/fpdoc/fpdocxmlopts.pas	(revision 34749)
-@@ -13,6 +13,7 @@
-   TXMLFPDocOptions = Class(TComponent)
-   private
-   Protected
-+    Function PreProcessFile(const AFileName: String; Macros: TStrings): TStream; virtual;
-     Procedure Error(Const Msg : String);
-     Procedure Error(Const Fmt : String; Args : Array of Const);
-     Procedure LoadPackage(APackage : TFPDocPackage; E : TDOMElement); virtual;
-@@ -24,7 +25,7 @@
-     procedure SaveInputFile(const AInputFile: String; XML: TXMLDocument; AParent: TDOMElement);virtual;
-     Procedure SavePackage(APackage : TFPDocPackage; XML : TXMLDocument; AParent : TDOMElement); virtual;
-   Public
--    Procedure LoadOptionsFromFile(AProject : TFPDocProject; Const AFileName : String);
-+    Procedure LoadOptionsFromFile(AProject : TFPDocProject; Const AFileName : String; Macros : TStrings = Nil);
-     Procedure LoadFromXML(AProject : TFPDocProject; XML : TXMLDocument); virtual;
-     Procedure SaveOptionsToFile(AProject : TFPDocProject; Const AFileName : String);
-     procedure SaveToXML(AProject : TFPDocProject; ADoc: TXMLDocument); virtual;
-@@ -65,7 +66,7 @@
- end;
- 
- 
--procedure TXMLFPDocOptions.Error(Const Msg: String);
-+procedure TXMLFPDocOptions.Error(const Msg: String);
- begin
-   Raise EXMLFPDoc.Create(Msg);
- end;
-@@ -248,7 +249,8 @@
-     end;
- end;
- 
--Procedure TXMLFPDocOptions.SaveEngineOptions(Options : TEngineOptions; XML : TXMLDocument; AParent : TDOMElement);
-+procedure TXMLFPDocOptions.SaveEngineOptions(Options: TEngineOptions;
-+  XML: TXMLDocument; AParent: TDOMElement);
- 
-   procedure AddStr(const n, v: string);
-   var
-@@ -288,7 +290,8 @@
- end;
- 
- 
--Procedure TXMLFPDocOptions.SaveInputFile(Const AInputFile : String; XML : TXMLDocument; AParent: TDOMElement);
-+procedure TXMLFPDocOptions.SaveInputFile(const AInputFile: String;
-+  XML: TXMLDocument; AParent: TDOMElement);
- 
- Var
-   F,O : String;
-@@ -299,7 +302,8 @@
-   AParent['options']:=O;
- end;
- 
--Procedure TXMLFPDocOptions.SaveDescription(Const ADescription : String; XML : TXMLDocument; AParent: TDOMElement);
-+procedure TXMLFPDocOptions.SaveDescription(const ADescription: String;
-+  XML: TXMLDocument; AParent: TDOMElement);
- 
- begin
-   AParent['file']:=ADescription;
-@@ -317,7 +321,8 @@
-   AParent['prefix']:=Copy(AImportFile,i+1,Length(AImportFile));
- end;
- 
--Procedure TXMLFPDocOptions.SavePackage(APackage: TFPDocPackage; XML : TXMLDocument; AParent: TDOMElement);
-+procedure TXMLFPDocOptions.SavePackage(APackage: TFPDocPackage;
-+  XML: TXMLDocument; AParent: TDOMElement);
- 
- 
- var
-@@ -358,17 +363,55 @@
- end;
- 
- 
-+Function TXMLFPDocOptions.PreprocessFile(const AFileName: String; Macros : TStrings) : TStream;
- 
--procedure TXMLFPDocOptions.LoadOptionsFromFile(AProject: TFPDocProject; const AFileName: String);
-+Var
-+  F : TFileStream;
-+  P : TTemplateParser;
-+  I : Integer;
-+  N,V : String;
- 
-+begin
-+  Result:=Nil;
-+  P:=Nil;
-+  F:=TFileStream.Create(AFileName,fmOpenRead or fmShareDenyWrite);
-+  try
-+    P:=TTemplateParser.Create;
-+    P.AllowTagParams:=False;
-+    P.StartDelimiter:='{{';
-+    P.EndDelimiter:='}}';
-+    For I:=0 to Macros.Count-1 do
-+      begin
-+      Macros.GetNameValue(I,N,V);
-+      P.Values[N]:=V;
-+      end;
-+    Result:=TMemoryStream.Create;
-+    P.ParseStream(F,Result);
-+    Result.Position:=0;
-+  finally
-+    FreeAndNil(F);
-+    FreeAndNil(P);
-+  end;
-+end;
-+
-+procedure TXMLFPDocOptions.LoadOptionsFromFile(AProject: TFPDocProject;
-+  const AFileName: String; Macros: TStrings = Nil);
-+
- Var
-   XML : TXMLDocument;
-+  S : TStream;
- 
- begin
--  ReadXMLFile(XML,AFileName);
-+  XML:=Nil;
-+  if Macros=Nil then
-+    S:=TFileStream.Create(AFileName,fmOpenRead or fmShareDenyWrite)
-+  else
-+    S:=PreProcessFile(AFileName,Macros);
-   try
-+    ReadXMLFile(XML,S);
-     LoadFromXML(AProject,XML);
-   finally
-+    FreeAndNil(S);
-     FreeAndNil(XML);
-   end;
- end;
-@@ -393,7 +436,8 @@
-     LoadEngineOptions(AProject.Options,N as TDOMElement);
- end;
- 
--Procedure TXMLFPDocOptions.SaveOptionsToFile(AProject: TFPDocProject; const AFileName: String);
-+procedure TXMLFPDocOptions.SaveOptionsToFile(AProject: TFPDocProject;
-+  const AFileName: String);
- 
- Var
-   XML : TXMLDocument;
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/fpc.git/commitdiff/361caa6b0de4842c199733b2c290845a036417c8



More information about the pld-cvs-commit mailing list