[AWS] "AWS install problems" posted on comp.lang.ada

brett hallett dragoncity at aanet.com.au
Sat May 29 02:21:27 CEST 2010


On Thu, 27 May 2010 15:06:47 +0200
Ludovic Brenta <ludovic at ludovic-brenta.org> wrote:


> 
> brett hallett wrote:
> >> Note that you can edit your project file manually, too.  In my
> >> experience this gives better results and control than the project
> >> files generated by GPS.
> > 
> > I agree that this is probably a better arrangement, rather than
> > fiddling with .profile, however it is not
> > at all clear just what is the minimum .gpr setup to be effective
> > from the documentation, I'll have to study it further. I tried a
> > version of the example from aws.gpr file, but kept getting odd
> > errors, especially "duplicate references", hence I reverted to the
> > EXPORT PATH technique.
> 
> If the example from /usr/share/ada/adainclude/aws.gpr does not work,
> please tell me so I can correct it.  What exact errors did you get?
> Maybe the errors were legitimate, i.e. you duplicated some source
> files from AWS into your program?

I've done a few experiments to get back to the faulty situation,
without total success, but I've noted a few problem areas.

I firstly removed  the EXPORT variables from .profile, to ensure GPS
was only using the ??.gpr setup.

While working on learning Ada I've place each project into its own
unique directory eg: /home/brett/Ada-trymail and all my small related
test programs are kept here.

The current generated trymail.gpr looks like this :
-----------------------------------------------------
with "aws.gpr";

project Trymail is

   type Mode_Type is
      ("Production", "Debug");
   Mode : Mode_Type := external ("BUILD", "Debug");

   case Mode is

      when "Production" =>

      when "Debug" =>
         for Main use ("trymail.adb", "trymailattachment.adb",
      "getmail.adb", "getmail2.adb"); end case;

   package Compiler is

      case Mode is

         when "Production" =>
            for Default_Switches ("ada") use ("-gnatp", "-O2");

         when "Debug" =>
            for Default_Switches ("ada") use ("-g", "-gnato",
         "-fstack-check", "-gnatVa"); end case;
   end Compiler;

   package Ide is
      for Vcs_Kind use "CVS";
   end Ide;

end Trymail;
------------------------------------------

this was auto-generated by GPS
and I simply create a new xxx.adb file to test something and things
appear to work after I add the new .adb file to the projects 'main' file
list.

However I created another directory /home/brett/Ada-trymailx, copied a
running program trymail.adb into it, rename it trymailx.adb and hand
created a new trymailx.gpr file thus:

------------------------------------------
with "aws.gpr";

project TrymailX is

   for Source_Dirs use ("/home/brett/Ada-trymailx");
   for Exec_Dir    use "/home/brett/Ada-trymailx";
   for Object-Dir  use "/home/brett/Ada-trymailx";
   for Main use ("trymailx.adb");

end TrymailX;
-----------------------------------------

However, at some stage I saved the current trymailx.gpr file,
from within GPS and ended up with this !!!
-----------------------------------------
with "aws.gpr";

project TrymailX is

   for Source_Dirs use (".");
   for Exec_Dir use ".";
   for Main use ("trymailx.adb");

end TrymailX;
-----------------------------------------

Then the linker could not find the program to execute OR reported that 
trymailx.adb was not a unit of trymailx.gpr!

After more experiments it seems that GPS does not like file names with
capital letter(s) !! I'd renamed a few test files by adding a 'X" to the
name for quick recognition only to discover that GPS would not display
those files for selection into the 'main' files list. ( not directly
your problem, but interesting none the less ).

So from a beginners point of view there are a number of confusing
project file 'features' :

   the project .gpr file set up is flaky and not consistent !

-- why do capitals cause it problems ?
-- why do some project 'for' commands require ( ) and others do not ?
-- why does project save change the 'use' content so dramatically ?
   ( the Main files list is understandable as I'nm adding new files to
   process.
-- the whole project / properties is quite complex, and a simple
beginners set up option would be useful !, leaving the other options
for when one really need them.

	ie: I set General : Name & path ( to my working directory )
                & Main    : select the .adb files I wish to process
              
	and leave the rest alone. Now it took me some fiddle time to
	figure out this minimum requirement to get a working set up. :-)

==========================

Now to your real question !!

I think the newcomer is confused when directed to the aws.gpr file for
an example of 'how to use this project file' because although you see
the comment , you also see the quite complex aws.gpr setup as well and
its NOT apparent how this related to YOUR ( my) project.

Instead of the embedded comment I think you should direct the reader of
aws.gpr to a small text/doc file which contains an example xxx.gpr &
xxx.adb files of a working complete program using AWS. I had to trawl
through lots of documents to figure out as much as I have, and required
your help as well, so using AWS.GPR is not at all clear in my opinion.

Here is an example program, which works from GPS and as ./getmail2
in a Konsole. :-)

------------------- .prg ------------------

with "aws.gpr";

project trymail is

   for Source_Dirs use ("/home/you/trymail");
   for Object_Dir  use "/home/you/trymail";
   for Exec_Dir    use "/home/you/trymail";
   for Main        use ( "getmail.adb");

end trymail;


------------------  .adb ------------------

-- getmail.adb : test AWS POP email access functions
-- connect to a Internet Mailbox using POP (Post Office Protocol) and
-- loop thru all mail messages and print summary, do not remove
--   message(s) .
-- also print current date & time using Calendar package
-- brett Hallett May 2010

with Ada.Text_IO, Ada.Integer_Text_IO;
-- to access some standard input/output functions
with Ada.Calendar, Ada.Calendar.formatting, GNAT.Calendar.Time_IO;
-- to print formatted date & time information
with AWS, Aws.POP;
-- to access the AWS POP functions

use Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Calendar, Ada.Calendar.formatting, GNAT.Calendar.Time_IO;
use AWS, AWS.POP;


 procedure getmail2 is

   POP_Server : constant String := "mail.xxnet.com.xx";
   POP_User   : constant String := "yourself at xxnet.com.xx";
   POP_Pass   : constant String := "blahblahblah";

-- change above to your ISP's mail access parameters as required


Mailbox : AWS.POP.Mailbox := AWS.POP.Initialize ( POP_Server, POP_User,
POP_Pass); 
-- set up a Mailbox to collect from the AWS.POP server for
this user 

N       : constant Natural := POP.Message_Count ( Mailbox);
-- collect the number of eMail messages
Message : constant POP.Message := POP.get ( Mailbox, 1, Remove =>
         false); 

-- collect the first message ( there may be none ! which causes
-- runtime error  which is not checked for in this program )

   procedure print_date_time is
   begin
       put(" at: ");
 	put_time (Ada.Calendar.Clock , Picture =>  "%T"  );
	-- output current clock time as HH:MM:SS
 	put(" on: ");
 	put_time (Ada.Calendar.Clock, European_Date);
        -- output current date as DD/MM/YY
 	new_line;
	end print_date_time;

  procedure Print_Report_Heading is
  begin
     Set_Col ( 1 );
     put ( "Seq#");
     Set_Col ( 9 );
     Put ("Subject");
     set_col ( 45 );
     put (" From ");
     new_line;
   end Print_Report_Heading;

  procedure Print_Subject
		( Message	: in POP.Message;
                  Index         : in Positive;
                  Quit          : in out Boolean ) is
  begin
     Set_Col ( 1 );
     put ( Index, 5);               -- print current message number
     Set_Col ( 8 );
     put (" | ");
     Put ( POP.Subject ( Message )); -- print current messages 'subject'
     set_col ( 45 );
     put (" | ");
     put ( POP.From ( message ));    -- print current messages 'from'
     new_line;
  end Print_Subject;

  Procedure Print_All_Subjects is
    new POP.For_Every_Message ( Print_Subject);
-- link the action (Print_Subject) to the iterator
                         POP.For_Every_Message 
-- note the parameters from Print_All_Subjects
--  are also passed -- ( somehow ! )


begin
 put_line("** getmail2 **");
 put ("Number of messages :");  put ( N, 3 );
 print_date_time;

 Print_Report_Heading;

 Print_All_Subjects ( Mailbox, Remove => false );
 -- iterate over every message in the Mailbox, do not remove

 Aws.Pop.Close(Mailbox);
end getmail2;
-----------------------------------------------------------

Your example project file is most likely correct, as long as the
beginner does not fall into simple traps like I did.


> 

Hope this is of some use and not complete rubbish !!

-- 
Cheers,
Brett


More information about the AWS mailing list