comp.lang.ada
 help / color / mirror / Atom feed
* Ada to Ada Pragma Export/Import
@ 2006-08-09 22:05 AskeyAJ
  2006-08-09 23:26 ` Jeffrey Creem
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: AskeyAJ @ 2006-08-09 22:05 UTC (permalink / raw)


I need to deliver object files (coded in Ada) to another team who will
access the public routines in their Ada code.  I cannot deliver the
package bodies (but can deliver the object files, the specs, and the
ALI files).  For example, suppose I want do deliver the hello_pkg.o and
hello_pkg.ads from the code below.

My assumption is that I need to export the Say_It procedure in the
spec, and then the other team would need to import this procedure into
their code.  Is this correct?  And what is the syntax required?  I've
tried the following but can't figure it out.

Thanx much for any help.
Andy
askeyaj@gmail.com

--------

with Text_Io;
package Hello_Pkg is
   pragma Export (Ada, Say_It, "say_it"); -- CORRECT???
   procedure Say_It;
end Hello_Pkg;
package body Hello_Pkg is
   procedure Say_It is
      begin
         Text_Io.Put_Line("Hello World.");
      end Say_It;
end Hello_Pkg;


with Hello_Pkg;
procedure Test_Hello is
   pragma Import (Ada, Say_It, "say_it"); -- NOT SURE WHAT TO DO HERE
begin
   Say_It;
end Test_Hello;




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-09 22:05 Ada to Ada Pragma Export/Import AskeyAJ
@ 2006-08-09 23:26 ` Jeffrey Creem
  2006-08-09 23:48 ` Georg Bauhaus
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Jeffrey Creem @ 2006-08-09 23:26 UTC (permalink / raw)


AskeyAJ@gmail.com wrote:
> I need to deliver object files (coded in Ada) to another team who will
> access the public routines in their Ada code.  I cannot deliver the
> package bodies (but can deliver the object files, the specs, and the
> ALI files).  For example, suppose I want do deliver the hello_pkg.o and
> hello_pkg.ads from the code below.
> 
> My assumption is that I need to export the Say_It procedure in the
> spec, and then the other team would need to import this procedure into
> their code.  Is this correct?  And what is the syntax required?  I've
> tried the following but can't figure it out.
> 


The problem with this approach is that the elaboration code will not get 
called correctly.

What you are doing is complicated enough (and clearly not open source) 
that I would think  you would want/have a support contract from AdaCore. 
They would be good people to ask.

Having said that, take a look at

http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gnat_ugn_unw/Stand_002dalone-Ada-Libraries.html#Stand_002dalone-Ada-Libraries

I've not done the exact thing you are doing, nor have I ever done what 
is described on that page but I have created a windows dll and provided 
an interface to it for use through C using related methods.

I'd recommend that you deliver the library file and the spec files that 
are designed to link against that library.

You will not (I think) be able to provide generics to the other team. 
That is not the same thing as saying that you can't program using 
generics. Just that you will have to provide (in the library) 
instantiations of any generic packages for them.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-09 22:05 Ada to Ada Pragma Export/Import AskeyAJ
  2006-08-09 23:26 ` Jeffrey Creem
@ 2006-08-09 23:48 ` Georg Bauhaus
  2006-08-10 12:00 ` Stephen Leake
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Georg Bauhaus @ 2006-08-09 23:48 UTC (permalink / raw)


On Wed, 2006-08-09 at 15:05 -0700, AskeyAJ@gmail.com wrote:
> I need to deliver object files (coded in Ada) to another team who will
> access the public routines in their Ada code.  I cannot deliver the
> package bodies (but can deliver the object files, the specs, and the
> ALI files). 

Seems sufficient to me, except you won't need pragma Export
at all. If the Ada library files and the object files have
proper time stamps, the compiler won't have to compile
the body files again.

-- Georg 





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-09 22:05 Ada to Ada Pragma Export/Import AskeyAJ
  2006-08-09 23:26 ` Jeffrey Creem
  2006-08-09 23:48 ` Georg Bauhaus
@ 2006-08-10 12:00 ` Stephen Leake
  2006-08-10 13:06 ` gautier_niouzes
  2006-08-10 16:49 ` Martin Krischik
  4 siblings, 0 replies; 11+ messages in thread
From: Stephen Leake @ 2006-08-10 12:00 UTC (permalink / raw)


"AskeyAJ@gmail.com" <AskeyAJ@gmail.com> writes:

> I need to deliver object files (coded in Ada) to another team who will
> access the public routines in their Ada code.  I cannot deliver the
> package bodies (but can deliver the object files, the specs, and the
> ALI files).  For example, suppose I want do deliver the hello_pkg.o and
> hello_pkg.ads from the code below.
>
> My assumption is that I need to export the Say_It procedure in the
> spec, and then the other team would need to import this procedure into
> their code.  Is this correct?  

No. just deliver a normal Ada spec; see below.

package Hello_Pkg is
   procedure Say_It;
end Hello_Pkg;

with Ada.Text_Io;
package body Hello_Pkg is
   procedure Say_It is
      begin
         Ada.Text_Io.Put_Line("Hello World.");
      end Say_It;
end Hello_Pkg;


with Hello_Pkg;
procedure Test_Hello is
begin
   Hello_Pkg.Say_It;
end Test_Hello;


-- 
-- Stephe



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-09 22:05 Ada to Ada Pragma Export/Import AskeyAJ
                   ` (2 preceding siblings ...)
  2006-08-10 12:00 ` Stephen Leake
@ 2006-08-10 13:06 ` gautier_niouzes
  2006-08-10 16:49 ` Martin Krischik
  4 siblings, 0 replies; 11+ messages in thread
From: gautier_niouzes @ 2006-08-10 13:06 UTC (permalink / raw)


AskeyAJ@gmail.com schrieb:

> I need to deliver object files (coded in Ada) to another team who will
> access the public routines in their Ada code.  I cannot deliver the
> package bodies (but can deliver the object files, the specs, and the
> ALI files).  For example, suppose I want do deliver the hello_pkg.o and
> hello_pkg.ads from the code below.
>
> My assumption is that I need to export the Say_It procedure in the
> spec, and then the other team would need to import this procedure into
> their code.  Is this correct?  And what is the syntax required?  I've
> tried the following but can't figure it out.

You shouldn't need it, being from a certain Ada compiler to itself.
With GNAT, the trick is to make the .ali files read-only, then it is
sufficient to deliver the .ads, .o and .ali files of units. It is
surely documented in the GNAT docs (where ?)

HTH, Gautier
______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-09 22:05 Ada to Ada Pragma Export/Import AskeyAJ
                   ` (3 preceding siblings ...)
  2006-08-10 13:06 ` gautier_niouzes
@ 2006-08-10 16:49 ` Martin Krischik
  2006-08-11 14:02   ` AskeyAJ
  4 siblings, 1 reply; 11+ messages in thread
From: Martin Krischik @ 2006-08-10 16:49 UTC (permalink / raw)


Am 10.08.2006, 01:05 Uhr, schrieb AskeyAJ@gmail.com <AskeyAJ@gmail.com>:

> I need to deliver object files (coded in Ada) to another team who will
> access the public routines in their Ada code.  I cannot deliver the
> package bodies (but can deliver the object files, the specs, and the
> ALI files).  For example, suppose I want do deliver the hello_pkg.o and
> hello_pkg.ads from the code below.
>
> My assumption is that I need to export the Say_It procedure in the
> spec, and then the other team would need to import this procedure into
> their code.  Is this correct?  And what is the syntax required?  I've
> tried the following but can't figure it out.

If the procedure/type/etc. pp. is mentioned in the spec then simple export  
is assumed and an explicit pragma is only needed when special - like C or  
Fortran compatibility - is needed. So you don't need pragma Export and it  
is better not to use it.

Apart from that you are on the right track

Martin
-- 
Martin Krischik
krischik@users.sourceforge.net



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-10 16:49 ` Martin Krischik
@ 2006-08-11 14:02   ` AskeyAJ
  2006-08-11 14:22     ` Ludovic Brenta
  2006-08-11 16:35     ` Martin Krischik
  0 siblings, 2 replies; 11+ messages in thread
From: AskeyAJ @ 2006-08-11 14:02 UTC (permalink / raw)


Thanx to all who responded.  I got it working without the pragma, but I
get a warning during the compile that the body does not exist.  (I
thought this was a problem but I now see it is not.)  This doesn't
matter as gnatbind and gnatlink work when I point to the .o and .ali
where the body was compiled.  I suppose I could find a way to turn off
this warning during gnatmake if the other team complains.

Thanx much again.
Andy




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-11 14:02   ` AskeyAJ
@ 2006-08-11 14:22     ` Ludovic Brenta
  2006-08-11 16:55       ` AskeyAJ
  2006-08-11 16:35     ` Martin Krischik
  1 sibling, 1 reply; 11+ messages in thread
From: Ludovic Brenta @ 2006-08-11 14:22 UTC (permalink / raw)


AskeyAJ@gmail.com a écrit :
> Thanx to all who responded.  I got it working without the pragma, but I
> get a warning during the compile that the body does not exist.  (I
> thought this was a problem but I now see it is not.)  This doesn't
> matter as gnatbind and gnatlink work when I point to the .o and .ali
> where the body was compiled.  I suppose I could find a way to turn off
> this warning during gnatmake if the other team complains.

Did you make the .ali files read-only?

-- 
Ludovic Brenta.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-11 14:02   ` AskeyAJ
  2006-08-11 14:22     ` Ludovic Brenta
@ 2006-08-11 16:35     ` Martin Krischik
  2006-08-11 16:58       ` AskeyAJ
  1 sibling, 1 reply; 11+ messages in thread
From: Martin Krischik @ 2006-08-11 16:35 UTC (permalink / raw)


Am 11.08.2006, 17:02 Uhr, schrieb AskeyAJ@gmail.com <AskeyAJ@gmail.com>:

> Thanx to all who responded.  I got it working without the pragma, but I
> get a warning during the compile that the body does not exist.  (I
> thought this was a problem but I now see it is not.)  This doesn't
> matter as gnatbind and gnatlink work when I point to the .o and .ali
> where the body was compiled.  I suppose I could find a way to turn off
> this warning during gnatmake if the other team complains.

You might consider greating a library. The GNAT project manager can do  
this for most targest. When a library is created the .ads and .ali are  
together with the library file are automaticly copied into a distribution  
directory and made read only.

Once they are read only GNAT will not try to compile them again.

You then just send your customer the content of thar directoy and be done.

See AdaCL [1] if you need examples on how to create the needed project  
manager (adacl.gpr) files.


Martin

[1] adacl.sf.net
-- 
Martin Krischik
krischik@users.sourceforge.net



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-11 14:22     ` Ludovic Brenta
@ 2006-08-11 16:55       ` AskeyAJ
  0 siblings, 0 replies; 11+ messages in thread
From: AskeyAJ @ 2006-08-11 16:55 UTC (permalink / raw)


I thought I did, but I guess I didn't do it right.  I tried it again
this morning with read only ALI files and it didn't complain about the
missing body.  Thank much.

Andy


Ludovic Brenta wrote:
> AskeyAJ@gmail.com a écrit :
> > Thanx to all who responded.  I got it working without the pragma, but I
> > get a warning during the compile that the body does not exist.  (I
> > thought this was a problem but I now see it is not.)  This doesn't
> > matter as gnatbind and gnatlink work when I point to the .o and .ali
> > where the body was compiled.  I suppose I could find a way to turn off
> > this warning during gnatmake if the other team complains.
> 
> Did you make the .ali files read-only?
> 
> -- 
> Ludovic Brenta.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada to Ada Pragma Export/Import
  2006-08-11 16:35     ` Martin Krischik
@ 2006-08-11 16:58       ` AskeyAJ
  0 siblings, 0 replies; 11+ messages in thread
From: AskeyAJ @ 2006-08-11 16:58 UTC (permalink / raw)


Martin,

Great idea.  I'll get someone on that this afternoon.

Thanx.
Andy


Martin Krischik wrote:

> You might consider greating a library. The GNAT project manager can do
> this for most targest. When a library is created the .ads and .ali are
> together with the library file are automaticly copied into a distribution
> directory and made read only.
>
> Once they are read only GNAT will not try to compile them again.
>
> You then just send your customer the content of thar directoy and be done.
>
> See AdaCL [1] if you need examples on how to create the needed project
> manager (adacl.gpr) files.
>
>
> Martin
>
> [1] adacl.sf.net
> -- 
> Martin Krischik
> krischik@users.sourceforge.net




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-08-11 16:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-09 22:05 Ada to Ada Pragma Export/Import AskeyAJ
2006-08-09 23:26 ` Jeffrey Creem
2006-08-09 23:48 ` Georg Bauhaus
2006-08-10 12:00 ` Stephen Leake
2006-08-10 13:06 ` gautier_niouzes
2006-08-10 16:49 ` Martin Krischik
2006-08-11 14:02   ` AskeyAJ
2006-08-11 14:22     ` Ludovic Brenta
2006-08-11 16:55       ` AskeyAJ
2006-08-11 16:35     ` Martin Krischik
2006-08-11 16:58       ` AskeyAJ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox