[AWS] gnatmake works, project file does not

Marius Amado-Alves marius at amado-alves.info
Thu Jan 24 23:33:36 CET 2013


Posting here first because I suspect this is somehow AWS-related and I
know some people here are GNAT experts anyway.
Please feel free to ignore.

I'm stuck and desperate. I can build a test program with gnatmake the old way:

C:\Users\Marius\Dropbox\PhD\KAUS\System2>gnatmake
aa-universal_identifier-test -gnat2012
-I"c:\Users\Marius\aalibrary-code"
gcc -c -gnat2012 -Ic:\Users\Marius\aalibrary-code
aa-universal_identifier-test.adb
gnatbind -Ic:\Users\Marius\aalibrary-code -x aa-universal_identifier-test.ali
gnatlink aa-universal_identifier-test.ali

But with a project file it gives this strange error:

C:\Users\Marius\Dropbox\PhD\KAUS\System2>gnatmake -P system -gnat2012
gcc -c -gnat2012 -I- -gnatA
C:\Users\Marius\Dropbox\PhD\KAUS\System2\aa-universal_identifier-test.adb
gnat-secure_hashes.ads:175:07: missing full declaration for deferred
constant (RM 7.4)
gnatmake: "C:\Users\Marius\Dropbox\PhD\KAUS\System2\aa-universal_identifier-test.adb"
compilation error

I did tamper with g-sechas.ads and friends before, but now I have
reinstalled GNAT and verified all such files are the originals.

This test does not include AWS. But AWS is the reason I need to build
via GNAT projects. I want to build an AWS application, and I could not
find a way to do that the old way.

Any ideas? Thanks a lot.

project System is
   for Main use ("aa-universal_identifier-test.adb");
   for Source_Dirs use ("C:\Users\Marius\aalibrary-code");
end System;

with Ada.Text_IO; use Ada.Text_IO;
procedure AA.Universal_Identifier.Test is
   function Integer_ID is new Generic_ID (Integer);
begin
   Put_Line ("OK");
end;

--  The AA Library is at
--    http://sourceforge.net/p/aalibrary
--  but this site does not seem to be working well so here are the
involved units.

package AA is
   --  A multi-purpose library.
   --  (C) 2012 Marius Amado-Alves

   type Root_T is abstract tagged null record;
end;

with Ada.Containers;
with Ada.Strings.Hash;
with GNAT.SHA1;

package AA.Universal_Identifier is
   package SHA renames GNAT.SHA1;
   --  This renaming is a device to easily change SHA variant.
   --  SHA variants available include GNAT.SHA1, GNAT.SHA256, etc.

   subtype UID_T is SHA.Message_Digest;
   --  A fixed-length string of (lowercase) hexadecimal digits.

   Null_UID : constant UID_T := (others => '0');

   function New_UID return UID_T;

   generic
      type User_Defined_Type_T (<>) is private;
   function
      Generic_ID (Value : User_Defined_Type_T) return UID_T;

   function Valid (UID : UID_T) return Boolean;
end;

with Ada.Calendar;
with Ada.Characters.Handling;
with Ada.Streams;

package body AA.Universal_Identifier is

   type SHA_Stream_T is new Ada.Streams.Root_Stream_Type with
     record
        Context : SHA.Context := SHA.Initial_Context;
     end record;

   procedure Read
     (SHA_Stream : in out SHA_Stream_T;
      Item : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset);
   --  We have to declare a Read operation because the parent is abstract.
   --  But we don't need it.  We'll make it raise an error.

   procedure Write
     (SHA_Stream : in out SHA_Stream_T;
      Item : in Ada.Streams.Stream_Element_Array);

   procedure Read
     (SHA_Stream : in out SHA_Stream_T;
      Item : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset) is
   begin
      raise Program_Error with "SHA_Stream_T is write-only";
   end;

   procedure Write
     (SHA_Stream : in out SHA_Stream_T;
      Item : in Ada.Streams.Stream_Element_Array) is
   begin
      SHA.Update (C => SHA_Stream.Context, Input => Item);
   end;

   -----------
   --  UID  --
   -----------

   function Generic_ID (Value : User_Defined_Type_T) return UID_T is
      SHA_Stream : aliased SHA_Stream_T;
   begin
      User_Defined_Type_T'Output (SHA_Stream'Access, Value);
      return SHA.Digest (SHA_Stream.Context);
   end;

   function Time_ID is new Generic_ID (Ada.Calendar.Time);

   function New_UID return UID_T is
   begin
      delay 0.000_000_001;
      return Time_ID (Ada.Calendar.Clock);
   end;
   --  We are GNAT-dependent here too. We are using the fact that on GNAT
   --  "Time is represented as a signed 64 bit integer count of nano-
   --  seconds since the start of Ada time (1901-01-01 00:00:00.0 UTC)"
   --  (Ada.Calendar)

   function Valid (UID : UID_T) return Boolean is
      use Ada.Characters.Handling;
   begin
      for I in UID'Range loop
         if not Is_Hexadecimal_Digit (UID (I)) then
            return False;
         end if;
      end loop;
      return True;
   end;
end;


More information about the AWS mailing list