svn commit: r354203 - in head/devel/gprbuild: . files

John Marino marino at FreeBSD.org
Fri May 16 09:06:17 UTC 2014


Author: marino
Date: Fri May 16 09:06:13 2014
New Revision: 354203
URL: http://svnweb.freebsd.org/changeset/ports/354203
QAT: https://qat.redports.org/buildarchive/r354203/

Log:
  devel/gprbuild: Upgrade version 20130416 (2013) => 20140417 (2014)
  
  Adacore provides annual releases for its major GPL-licensed products.
  GPRBuild is an important tool, but it's source is only exposed once
  per year, in May.  The 2014 release of GPRBuild relies on features in
  Adacore's commercial product, GNAT Pro, that has not yet been migrated
  to FSF GNAT.  I had to patch 2014 to get it to build with FSF GNAT 4.9,
  losing minor new functionality in the process.
  
  My first decision was to simply skip GPRBuild 2014 stay on the 2013
  version, but it turns out packages are already using the new features
  in gprinstall, one of the tools in the GPRBuild package.
  
  Tests on adabooch, aws, asis and opentoken indicate they build fine
  with GPRBuild 2014.

Added:
  head/devel/gprbuild/files/patch-src_gprbuild-compilation-protocol.adb   (contents, props changed)
  head/devel/gprbuild/files/patch-src_gprbuild-main.adb   (contents, props changed)
  head/devel/gprbuild/files/patch-src_gprinstall-install.adb   (contents, props changed)
  head/devel/gprbuild/files/patch-src_gprslave.adb   (contents, props changed)
  head/devel/gprbuild/files/patch-src_rewrite__data.ada   (contents, props changed)
Modified:
  head/devel/gprbuild/Makefile
  head/devel/gprbuild/distinfo
  head/devel/gprbuild/files/patch-Makefile.in
  head/devel/gprbuild/files/patch-gprbuild.gpr
  head/devel/gprbuild/files/patch-share_gprconfig_compilers.xml
  head/devel/gprbuild/files/patch-share_gprconfig_gnat.xml
  head/devel/gprbuild/files/patch-share_gprconfig_linker.xml
  head/devel/gprbuild/files/patch-share_gprconfig_targetset.xml
  head/devel/gprbuild/files/patch-src_gpr__version.adb
  head/devel/gprbuild/files/patch-src_gprlib.adb
  head/devel/gprbuild/pkg-plist

Modified: head/devel/gprbuild/Makefile
==============================================================================
--- head/devel/gprbuild/Makefile	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/Makefile	Fri May 16 09:06:13 2014	(r354203)
@@ -3,23 +3,20 @@
 
 PORTNAME=	gprbuild
 PORTVERSION=	${SNAPSHOT}
-PORTREVISION=	3
 CATEGORIES=	devel
 MASTER_SITES=	http://downloads.dragonlace.net/src/
 DISTNAME=	gprbuild-gpl-${YEAR}-src
-EXTRACT_SUFX=	.tgz
 
 MAINTAINER=	marino at FreeBSD.org
 COMMENT=	Adacore multi-language software build tool
 
 LICENSE=	GPLv3
 
-BUILD_DEPENDS+=	xmlada>=3.2:${PORTSDIR}/textproc/xmlada \
-		gnat_util>=2013:${PORTSDIR}/lang/gnat_util
+BUILD_DEPENDS+=	xmlada>=4.4:${PORTSDIR}/textproc/xmlada \
+		gnat_util>=20140422:${PORTSDIR}/lang/gnat_util
 
-WRKSRC=		${WRKDIR}/gprbuild-${YEAR}-src
-YEAR=		2013
-SNAPSHOT=	20130416
+YEAR=		2014
+SNAPSHOT=	20140417
 GNU_CONFIGURE=	yes
 USES=		ada gmake
 MAKE_ARGS+=	BUILD=production
@@ -33,13 +30,17 @@ OPTIONS_DEFINE=	DOCS EXAMPLES
 
 do-build:
 #	Recreate the do-build target without -j parameter
-#	It interferes with PROCESSORS configure argument
+#	It interferes with PROCESSORS make argument
 	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
 		${MAKE_CMD} ${MAKE_ARGS} ${ALL_TARGET})
 
 post-patch:
 	@${REINPLACE_CMD} -e "s, at AUXPREFIX@,${PREFIX}/gcc-aux," \
-	  ${WRKSRC}/share/gprconfig/compilers.xml
+		${WRKSRC}/share/gprconfig/compilers.xml
+	# Try_Help is part of GNAT Pro, but it's not in GCC 4.9 yet
+	# It's not strictly needed. Before it just repeated usage.
+	# There are other messages; just suppress Try_Help on 4 files
+	${REINPLACE_CMD} -e '/Try_Help;/d' ${WRKSRC}/src/*-main.adb
 
 post-install:
 .if !${PORT_OPTIONS:MDOCS}

Modified: head/devel/gprbuild/distinfo
==============================================================================
--- head/devel/gprbuild/distinfo	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/distinfo	Fri May 16 09:06:13 2014	(r354203)
@@ -1,2 +1,2 @@
-SHA256 (gprbuild-gpl-2013-src.tgz) = 7492347462d0a11a3672397a991ce3741347def3a468f850a91a54dfd4349144
-SIZE (gprbuild-gpl-2013-src.tgz) = 2291685
+SHA256 (gprbuild-gpl-2014-src.tar.gz) = 3c8986ff5f83cc0d3ee69f6e71d9f69a7eb1a7e2656493c829b18fb55c4ad5ac
+SIZE (gprbuild-gpl-2014-src.tar.gz) = 2384695

Modified: head/devel/gprbuild/files/patch-Makefile.in
==============================================================================
--- head/devel/gprbuild/files/patch-Makefile.in	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-Makefile.in	Fri May 16 09:06:13 2014	(r354203)
@@ -1,4 +1,4 @@
---- Makefile.in.orig	2013-03-04 17:43:09.000000000 +0000
+--- Makefile.in.orig	2013-12-21 15:45:27.000000000 +0000
 +++ Makefile.in
 @@ -64,7 +64,7 @@ ADA_GEN_SUBDIR=gnat
  

Modified: head/devel/gprbuild/files/patch-gprbuild.gpr
==============================================================================
--- head/devel/gprbuild/files/patch-gprbuild.gpr	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-gprbuild.gpr	Fri May 16 09:06:13 2014	(r354203)
@@ -1,4 +1,4 @@
---- gprbuild.gpr.orig	2013-04-16 14:36:04.000000000 +0000
+--- gprbuild.gpr.orig	2014-04-17 09:50:17.000000000 +0000
 +++ gprbuild.gpr
 @@ -1,4 +1,5 @@
  with "xmlada";

Modified: head/devel/gprbuild/files/patch-share_gprconfig_compilers.xml
==============================================================================
--- head/devel/gprbuild/files/patch-share_gprconfig_compilers.xml	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-share_gprconfig_compilers.xml	Fri May 16 09:06:13 2014	(r354203)
@@ -1,6 +1,6 @@
---- share/gprconfig/compilers.xml.orig	2013-01-09 18:09:30.000000000 +0000
+--- share/gprconfig/compilers.xml.orig	2014-03-21 10:41:06.000000000 +0000
 +++ share/gprconfig/compilers.xml
-@@ -456,16 +456,15 @@
+@@ -657,16 +657,15 @@
      </version>
      <languages>Ada</languages>
      <variable name="gcc_version">

Modified: head/devel/gprbuild/files/patch-share_gprconfig_gnat.xml
==============================================================================
--- head/devel/gprbuild/files/patch-share_gprconfig_gnat.xml	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-share_gprconfig_gnat.xml	Fri May 16 09:06:13 2014	(r354203)
@@ -1,4 +1,4 @@
---- share/gprconfig/gnat.xml.orig	2013-01-16 21:07:55.000000000 +0000
+--- share/gprconfig/gnat.xml.orig	2013-09-16 15:29:28.000000000 +0000
 +++ share/gprconfig/gnat.xml
 @@ -63,7 +63,7 @@
     </config>

Modified: head/devel/gprbuild/files/patch-share_gprconfig_linker.xml
==============================================================================
--- head/devel/gprbuild/files/patch-share_gprconfig_linker.xml	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-share_gprconfig_linker.xml	Fri May 16 09:06:13 2014	(r354203)
@@ -1,6 +1,6 @@
---- share/gprconfig/linker.xml.orig	2013-01-25 17:01:24.000000000 +0000
+--- share/gprconfig/linker.xml.orig	2014-02-13 04:59:56.000000000 +0000
 +++ share/gprconfig/linker.xml
-@@ -519,11 +519,14 @@
+@@ -599,11 +599,14 @@
      </config>
    </configuration>
  
@@ -16,7 +16,7 @@
         <target name="^.*irix.*$" />
      </targets>
      <config>
-@@ -557,10 +560,13 @@
+@@ -675,10 +678,13 @@
      </config>
    </configuration>
  
@@ -31,27 +31,20 @@
      </targets>
      <config>
     for Run_Path_Option  use ("-Wl,-rpath,");
-@@ -888,6 +894,9 @@
+@@ -1181,6 +1187,12 @@
         <target name="^.*mingw.*$" />
         <target name="^.*linux.*$" />
         <target name="^.*freebsd.*$" />
 +       <target name="^.*dragonfly.*$" />
 +       <target name="^.*openbsd.*$" />
 +       <target name="^.*netbsd.*$" />
-      </targets>
-     <compilers negate="true">
-        <compiler language="C++" />
-@@ -929,6 +938,9 @@
-        <target name="^.*mingw.*$" />
-        <target name="^.*linux.*$" />
-        <target name="^.*freebsd.*$" />
 +       <target name="^.*dragonfly.*$" />
 +       <target name="^.*openbsd.*$" />
 +       <target name="^.*netbsd.*$" />
       </targets>
      <compilers negate="true">
         <compiler language="C++" />
-@@ -970,6 +982,9 @@
+@@ -1265,6 +1277,9 @@
         <target name="^.*mingw.*$" />
         <target name="^.*linux.*$" />
         <target name="^.*freebsd.*$" />

Modified: head/devel/gprbuild/files/patch-share_gprconfig_targetset.xml
==============================================================================
--- head/devel/gprbuild/files/patch-share_gprconfig_targetset.xml	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-share_gprconfig_targetset.xml	Fri May 16 09:06:13 2014	(r354203)
@@ -1,6 +1,6 @@
---- share/gprconfig/targetset.xml.orig	2012-12-19 17:55:05.000000000 +0000
+--- share/gprconfig/targetset.xml.orig	2014-02-13 04:59:56.000000000 +0000
 +++ share/gprconfig/targetset.xml
-@@ -52,8 +52,8 @@
+@@ -66,8 +66,8 @@
  
    <!-- x86-solaris -->
    <targetset>
@@ -11,9 +11,12 @@
    </targetset>
  
    <!-- x86-windows (mingw) -->
-@@ -144,10 +144,32 @@
+@@ -156,19 +156,34 @@
+     <target>pent.*-cygwin.*</target>
+   </targetset>
  
-   <!-- Freebsd -->
+-  <!-- x86 Freebsd -->
++  <!-- Freebsd -->
    <targetset>
 -    <target>x86-freebsd</target>
      <target>i.86-.*freebsd.*</target>
@@ -21,12 +24,16 @@
 +    <target>x86_64-.*-freebsd.*</target>
    </targetset>
  
+-  <!-- x86_64 Freebsd -->
 +  <!-- DragonFlyBSD -->
-+  <targetset>
+   <targetset>
+-    <target>x86_64-freebsd</target>
+-    <target>x86_64-.*freebsd.*</target>
+-    <target>amd64-.*freebsd.*</target>
 +    <target>i.86-.*-dragonfly.*</target>
 +    <target>x86_64-.*-dragonfly.*</target>
-+  </targetset>
-+
+   </targetset>
+ 
 +  <!-- NetBSD -->
 +  <targetset>
 +    <target>i.86-.*-netbsd.*</target>

Modified: head/devel/gprbuild/files/patch-src_gpr__version.adb
==============================================================================
--- head/devel/gprbuild/files/patch-src_gpr__version.adb	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-src_gpr__version.adb	Fri May 16 09:06:13 2014	(r354203)
@@ -1,4 +1,4 @@
---- src/gpr_version.adb.orig	2013-04-16 14:36:02.000000000 +0000
+--- src/gpr_version.adb.orig	2014-04-17 09:50:17.000000000 +0000
 +++ src/gpr_version.adb
 @@ -65,14 +65,7 @@ package body GPR_Version is
           end if;

Added: head/devel/gprbuild/files/patch-src_gprbuild-compilation-protocol.adb
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gprbuild/files/patch-src_gprbuild-compilation-protocol.adb	Fri May 16 09:06:13 2014	(r354203)
@@ -0,0 +1,33 @@
+The GNAT.Rewrite_Data package in not in FSF GNAT yet.  Use the local 2013
+version which does not have the Link method.  This essentially changes
+this file back to the GPRBuild 2013 version, so it should be ok.
+
+--- src/gprbuild-compilation-protocol.adb.orig	2014-04-17 09:50:17.000000000 +0000
++++ src/gprbuild-compilation-protocol.adb
+@@ -24,7 +24,7 @@ with Ada.Streams.Stream_IO;
+ with Ada.Strings.Fixed;           use Ada.Strings.Fixed;
+ with Ada.Strings.Maps.Constants;  use Ada.Strings.Maps;
+ 
+-with GNAT.Rewrite_Data;
++with Rewrite_Data;
+ with GNAT.String_Split;     use GNAT.String_Split;
+ 
+ with Gnatvsn;      use Gnatvsn;
+@@ -180,8 +180,6 @@ package body Gprbuild.Compilation.Protoc
+          end Output;
+ 
+       begin
+-         Rewrite_Data.Link (Rewriter, Rewriter_CD'Unchecked_Access);
+-
+          if Dir /= "" and then not Exists (Dir) then
+             Create_Directory (Dir);
+          end if;
+@@ -666,8 +664,6 @@ package body Gprbuild.Compilation.Protoc
+       end Output;
+ 
+    begin
+-      Rewrite_Data.Link (Rewriter, Rewriter_CD'Unchecked_Access);
+-
+       if Exists (Path_Name) then
+          Open (File, In_File, Path_Name);
+ 

Added: head/devel/gprbuild/files/patch-src_gprbuild-main.adb
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gprbuild/files/patch-src_gprbuild-main.adb	Fri May 16 09:06:13 2014	(r354203)
@@ -0,0 +1,14 @@
+It seems GNAT Pro makeutl.adb renamed an argument which hasn't trickled
+back to FSF GCC yet.
+
+--- src/gprbuild-main.adb.orig	2014-04-17 09:50:17.000000000 +0000
++++ src/gprbuild-main.adb
+@@ -2099,7 +2099,7 @@ begin
+ 
+    Do_Compute_Builder_Switches
+      (Project_Tree     => Project_Tree,
+-      Env              => Root_Environment,
++      Root_Environment => Root_Environment,
+       Main_Project     => Main_Project);
+ 
+    Queue.Initialize (Opt.One_Compilation_Per_Obj_Dir);

Added: head/devel/gprbuild/files/patch-src_gprinstall-install.adb
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gprbuild/files/patch-src_gprinstall-install.adb	Fri May 16 09:06:13 2014	(r354203)
@@ -0,0 +1,14 @@
+FSF GNAT 4.9 doesn't have the mode setting capability in Set_Executable
+procedure.  At least GPRBuild 2012 didn't use it.
+
+--- src/gprinstall-install.adb.orig	2014-04-17 09:50:17.000000000 +0000
++++ src/gprinstall-install.adb
+@@ -723,7 +723,7 @@ package body Gprinstall.Install is
+ 
+                if Executable then
+                   Set_Executable
+-                    (Dest_Filename, Mode => S_Owner + S_Group + S_Others);
++                    (Dest_Filename);
+                end if;
+ 
+                --  Add file to manifest

Modified: head/devel/gprbuild/files/patch-src_gprlib.adb
==============================================================================
--- head/devel/gprbuild/files/patch-src_gprlib.adb	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/files/patch-src_gprlib.adb	Fri May 16 09:06:13 2014	(r354203)
@@ -1,6 +1,9 @@
---- src/gprlib.adb.orig	2013-04-16 14:36:02.000000000 +0000
+The brain-dead handling of Rpath continues in GPRBuild 2014
+Bring in the GPRBuild 2012/2013 fix again
+
+--- src/gprlib.adb.orig	2014-04-17 09:50:17.000000000 +0000
 +++ src/gprlib.adb
-@@ -390,6 +390,11 @@ procedure Gprlib is
+@@ -408,6 +408,11 @@ procedure Gprlib is
  
     Separate_Run_Path_Options : Boolean := False;
  
@@ -12,7 +15,7 @@
     Rpath : String_List_Access := null;
     --  Allocated only if Path Option is supported
  
-@@ -1009,7 +1014,12 @@ begin
+@@ -1040,7 +1045,12 @@ begin
                    Use_GNAT_Lib := False;
                 end if;
  
@@ -24,9 +27,9 @@
 +                    (new String'(Line (1 .. Last)));
 +               end if;
  
-             when Library_Path =>
-                Osint.Fail ("library path should not be specified");
-@@ -2127,7 +2137,7 @@ begin
+             when Gprexch.Library_Rpath_Options =>
+                Library_Rpath_Options_Table.Append
+@@ -2166,7 +2176,7 @@ begin
           Library_Switches_Table.Append
             (new String'("-L" & Imported_Library_Directories.Table (J).all));
  

Added: head/devel/gprbuild/files/patch-src_gprslave.adb
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gprbuild/files/patch-src_gprslave.adb	Fri May 16 09:06:13 2014	(r354203)
@@ -0,0 +1,25 @@
+Set_File_Last_Modify_Time_Stamp has been added to GNAT.OS_Lib on GNAT Pro
+but that hasn't made it to gcc 4.9 yet.  For the moment, just disable the
+set file timestamp functionality that it serves here.
+
+--- src/gprslave.adb.orig	2014-04-17 09:50:17.000000000 +0000
++++ src/gprslave.adb
+@@ -1261,17 +1261,8 @@ procedure Gprslave is
+          procedure Set_Stamp
+            (Path_Name : String; Time_Stamp : Time_Stamp_Type)
+          is
+-            TS : constant String := String (Time_Stamp);
+          begin
+-            Set_File_Last_Modify_Time_Stamp
+-              (Path_Name,
+-               GM_Time_Of
+-                 (Year   => Year_Type'Value (TS (1 .. 4)),
+-                  Month  => Month_Type'Value (TS (5 .. 6)),
+-                  Day    => Day_Type'Value (TS (7 .. 8)),
+-                  Hour   => Hour_Type'Value (TS (9 .. 10)),
+-                  Minute => Minute_Type'Value (TS (11 .. 12)),
+-                  Second => Second_Type'Value (TS (13 .. 14))));
++            pragma Unreferenced (Path_Name, Time_Stamp);
+          end Set_Stamp;
+ 
+          ------------------

Added: head/devel/gprbuild/files/patch-src_rewrite__data.ada
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gprbuild/files/patch-src_rewrite__data.ada	Fri May 16 09:06:13 2014	(r354203)
@@ -0,0 +1,288 @@
+This functionality was part of GPRBuild 2013, but it has since moved to
+GNAT itself.  Unfortunately, that's only happened for GNAT Pro so GCC 4.9
+doesn't have this GNAT.Rewrite_Data.  Moveover, the GNAT Pro version has
+been extended since 2013.
+
+Bring in the GNAT 2013 local Rewrite_Data package to build GPRBuild 2014.
+
+--- src/rewrite_data.ads.orig	2014-05-16 07:42:27.000000000 +0000
++++ src/rewrite_data.ads
+@@ -0,0 +1,86 @@
++------------------------------------------------------------------------------
++--                         GNAT COMPILER COMPONENTS                         --
++--                                                                          --
++--                         R E W R I T E _ D A T A                          --
++--                                                                          --
++--                                 S p e c                                  --
++--                                                                          --
++--            Copyright (C) 2012, Free Software Foundation, Inc.            --
++--                                                                          --
++-- This is free software;  you can redistribute it  and/or modify it  under --
++-- terms of the  GNU General Public License as published  by the Free Soft- --
++-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
++-- sion.  This software is distributed in the hope  that it will be useful, --
++-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
++-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
++-- License for  more details.  You should have  received  a copy of the GNU --
++-- General  Public  License  distributed  with  this  software;   see  file --
++-- COPYING3.  If not, go to http://www.gnu.org/licenses for a complete copy --
++-- of the license.                                                          --
++------------------------------------------------------------------------------
++
++with Ada.Streams; use Ada.Streams;
++
++package Rewrite_Data is
++
++   type Buffer
++     (Size, Size_Pattern, Size_Value : Stream_Element_Offset) is
++   limited private;
++
++   function Create
++     (Pattern, Value : String;
++      Size           : Stream_Element_Offset := 1_024) return Buffer;
++   --  Create and return a buffer
++
++   procedure Write
++     (B      : in out Buffer;
++      Data   : Stream_Element_Array;
++      Output : not null access procedure (Data : Stream_Element_Array));
++   --  Write Data into the buffer, call Output for any prepared data
++
++   function Size (B : Buffer) return Natural;
++   --  Returns the current size of the buffer (count of Stream_Array_Element)
++
++   procedure Flush
++     (B      : in out Buffer;
++      Output : not null access procedure (Data : Stream_Element_Array));
++   --  Call Output for all remaining data in the buffer. The buffer is
++   --  reset and ready for another use after this call.
++
++   procedure Reset (B : in out Buffer);
++   pragma Inline (Reset);
++   --  Clear all data in buffer, B is ready for another use. Note that this is
++   --  not needed after a Flush.
++
++   procedure Rewrite
++     (B      : in out Buffer;
++      Input  : not null access procedure
++                 (Buffer : out Stream_Element_Array;
++                  Last   : out Stream_Element_Offset);
++      Output : not null access procedure (Data : Stream_Element_Array));
++   --  Read data from Input, rewrite them and then call Output
++
++private
++
++   type Buffer
++     (Size, Size_Pattern, Size_Value : Stream_Element_Offset) is
++   limited record
++      --  Fully prepared/rewritten data waiting to be output
++      Buffer  : Stream_Element_Array (1 .. Size);
++
++      --  Current data checked, this buffer contains every piece of data
++      --  starting with the pattern. It means that at any point:
++      --  Current (1 .. Pos_C) = Pattern (1 .. Pos_C)
++      Current : Stream_Element_Array (1 .. Size_Pattern);
++
++      --  The pattern to look for
++      Pattern : Stream_Element_Array (1 .. Size_Pattern);
++
++      --  The value the pattern is replaced by
++      Value   : Stream_Element_Array (1 .. Size_Value);
++
++      Pos_C   : Stream_Element_Offset; -- last valid element in Current
++      Pos_B   : Stream_Element_Offset; -- last valid element in Buffer
++   end record;
++
++end Rewrite_Data;
+--- src/rewrite_data.adb.orig	2014-05-16 07:42:21.000000000 +0000
++++ src/rewrite_data.adb
+@@ -0,0 +1,189 @@
++------------------------------------------------------------------------------
++--                         GNAT COMPILER COMPONENTS                         --
++--                                                                          --
++--                         R E W R I T E _ D A T A                          --
++--                                                                          --
++--                                 B o d y                                  --
++--                                                                          --
++--            Copyright (C) 2012, Free Software Foundation, Inc.            --
++--                                                                          --
++-- This is free software;  you can redistribute it  and/or modify it  under --
++-- terms of the  GNU General Public License as published  by the Free Soft- --
++-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
++-- sion.  This software is distributed in the hope  that it will be useful, --
++-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
++-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
++-- License for  more details.  You should have  received  a copy of the GNU --
++-- General  Public  License  distributed  with  this  software;   see  file --
++-- COPYING3.  If not, go to http://www.gnu.org/licenses for a complete copy --
++-- of the license.                                                          --
++------------------------------------------------------------------------------
++
++with Ada.Unchecked_Conversion;
++
++package body Rewrite_Data is
++
++   use Ada;
++
++   subtype SEO is Stream_Element_Offset;
++
++   ------------
++   -- Create --
++   ------------
++
++   function Create
++     (Pattern, Value : String;
++      Size           : Stream_Element_Offset := 1_024) return Buffer
++   is
++
++      subtype SP   is String (1 .. Pattern'Length);
++      subtype SEAP is Stream_Element_Array (1 .. Pattern'Length);
++
++      subtype SV   is String (1 .. Value'Length);
++      subtype SEAV is Stream_Element_Array (1 .. Value'Length);
++
++      function To_SEAP is new Unchecked_Conversion (SP, SEAP);
++      function To_SEAV is new Unchecked_Conversion (SV, SEAV);
++
++   begin
++      return B : Buffer
++        (SEO'Max (Size, SEO (Pattern'Length)), -- can't be smaller than pattern
++         SEO (Pattern'Length),
++         SEO (Value'Length))
++      do
++         B.Pattern := To_SEAP (Pattern);
++         B.Value   := To_SEAV (Value);
++         B.Pos_C   := 0;
++         B.Pos_B   := 0;
++      end return;
++   end Create;
++
++   -----------
++   -- Flush --
++   -----------
++
++   procedure Flush
++     (B      : in out Buffer;
++      Output : not null access procedure (Data : Stream_Element_Array)) is
++   begin
++      if B.Pos_B > 0 then
++         Output (B.Buffer (1 .. B.Pos_B));
++      end if;
++
++      if B.Pos_C > 0 then
++         Output (B.Current (1 .. B.Pos_C));
++      end if;
++
++      Reset (B);
++   end Flush;
++
++   -----------
++   -- Reset --
++   -----------
++
++   procedure Reset (B : in out Buffer) is
++   begin
++      B.Pos_B := 0;
++      B.Pos_C := 0;
++   end Reset;
++
++   -------------
++   -- Rewrite --
++   -------------
++
++   procedure Rewrite
++     (B      : in out Buffer;
++      Input  : not null access procedure
++                 (Buffer : out Stream_Element_Array;
++                  Last   : out Stream_Element_Offset);
++      Output : not null access procedure (Data : Stream_Element_Array))
++   is
++      Buffer : Stream_Element_Array (1 .. B.Size);
++      Last   : Stream_Element_Offset;
++   begin
++      Rewrite_All : loop
++         Input (Buffer, Last);
++         exit Rewrite_All when Last = 0;
++         Write (B, Buffer (1 .. Last), Output);
++      end loop Rewrite_All;
++
++      Flush (B, Output);
++   end Rewrite;
++
++   ----------
++   -- Size --
++   ----------
++
++   function Size (B : Buffer) return Natural is
++   begin
++      return Natural (B.Pos_B + B.Pos_C);
++   end Size;
++
++   -----------
++   -- Write --
++   -----------
++
++   procedure Write
++     (B      : in out Buffer;
++      Data   : Stream_Element_Array;
++      Output : not null access procedure (Data : Stream_Element_Array))
++   is
++
++      procedure Need_Space (Size : Stream_Element_Offset);
++      pragma Inline (Need_Space);
++
++      ----------------
++      -- Need_Space --
++      ----------------
++
++      procedure Need_Space (Size : Stream_Element_Offset) is
++      begin
++         if B.Pos_B + Size > B.Size then
++            Output (B.Buffer (1 .. B.Pos_B));
++            B.Pos_B := 0;
++         end if;
++      end Need_Space;
++
++   begin
++      if B.Size_Pattern = 0 then
++         Output (Data);
++
++      else
++         for K in Data'Range loop
++            if Data (K) = B.Pattern (B.Pos_C + 1) then
++               --  Store possible start of a macth
++               B.Pos_C := B.Pos_C + 1;
++               B.Current (B.Pos_C) := Data (K);
++
++            else
++               --  Not part of pattern, if a start of a match was found,
++               --  remove it.
++
++               if B.Pos_C /= 0 then
++                  Need_Space (B.Pos_C);
++
++                  B.Buffer (B.Pos_B + 1 .. B.Pos_B + B.Pos_C) :=
++                    B.Current (1 .. B.Pos_C);
++                  B.Pos_B := B.Pos_B + B.Pos_C;
++                  B.Pos_C := 0;
++               end if;
++
++               Need_Space (1);
++               B.Pos_B := B.Pos_B + 1;
++               B.Buffer (B.Pos_B) := Data (K);
++            end if;
++
++            if B.Pos_C = B.Size_Pattern then
++               --  The pattern is found
++
++               Need_Space (B.Size_Value);
++
++               B.Buffer (B.Pos_B + 1 .. B.Pos_B + B.Size_Value) := B.Value;
++               B.Pos_C := 0;
++               B.Pos_B := B.Pos_B + B.Size_Value;
++            end if;
++         end loop;
++      end if;
++   end Write;
++
++end Rewrite_Data;

Modified: head/devel/gprbuild/pkg-plist
==============================================================================
--- head/devel/gprbuild/pkg-plist	Fri May 16 08:53:20 2014	(r354202)
+++ head/devel/gprbuild/pkg-plist	Fri May 16 09:06:13 2014	(r354203)
@@ -8,6 +8,7 @@ libexec/gprbuild/gprlib
 share/gpr/_default.gpr
 share/gprconfig/asm.xml
 share/gprconfig/c.xml
+share/gprconfig/clean.xml
 share/gprconfig/compilers.xml
 share/gprconfig/cpp.xml
 share/gprconfig/cross.xml


More information about the svn-ports-all mailing list