comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Card <thehouseofcards@remove.this.part.mac.com>
Subject: Building a minimal-source-code Ada library with GNAT
Date: Fri, 08 Mar 2002 05:45:18 GMT
Date: 2002-03-08T05:45:18+00:00	[thread overview]
Message-ID: <080320020044528204%thehouseofcards@remove.this.part.mac.com> (raw)

Hello CLA-

I am trying to do something with GNAT 3.14 that I have not done before
and I am hoping someone out there has done this and can point me in the
right direction. Google searches for this info have proved fruitless.

What I am trying to do is build a GNAT Ada library that contains all of
the .o and .ali files for a re-usable software component and as little
of the re-usable component's source code as possible. What I did to
build the library was to compile all of the source code and then delete
the .adb (body) files that a user would not need to see from the
directory containing the GNAT Ada library. The code is something like
this:

top_level_pkg.ads -- root pkg user withs in
top_level_pkg.adb -- root pkg body, deleted user doesn't need it
top_level_pkg-public_generic_child_1.ads -- spec of generic child user
will need to instantiate
top_level_pkg-public_generic_child_1.adb -- body of generic child 1
top_level_pkg-public_generic_child_2.ads -- another generic for user
top_level_pkg-public_generic_child_2.adb -- body of generic child 2
top_level_pkg-private_child_1.ads -- spec of private pkg, included
because bodies of public generics with this in
top_level_pkg-private_child_1.adb -- deleted, user doesn't need it
top_level_pkg-private_child_2.ads -- 2nd private pkg withed in by
bodies of public generic child pkgs
top_level_pkg-private_child_2.adb -- deleted, user doesn't need it

The code is compiled simply like this:

foreach f (*.ad{s,b})
   gcc -c $f
end

and the un-needed .adb files are deleted.

The idea is to expose only the code you want the user to see, hiding
the rest of the source and providing only .ali and .o files for the
removed .adb files. Since none of the bodies removed are necessary for
a user to compile against the library, it seems like this should work.

When I try a gnatmake against such a library, however, the compilation
goes fine but the gnatbind fails in an interesting way. It gives errors
like this:

error: filename.adb needs to be recompiled

The interesting thing is that filename.adb may be one of the removed
files, but I built a library leaving in the files it complained about
and still got this error. For the gnatmake, I used the -A<path to Ada
library> option to point to these Ada libraries, as it looked like this
was what I should use. For example:

gnatmake -g -gnatE my_application -A/path_to_library
-A/path_to_library_2 -largs -lsocket -lnsl

Again, the compilation goes fine even with these .adb files removed, th
eproblem is in gnatbind. I also tried using the -x and -t options on
gnatbind but got the same error:

gnatmake -g -gnatE my_application -A/path_to_library
-A/path_to_library_2 -largs -lsocket -lnsl -bargs -x -t

Has anyone else ever tried this? I assume it must be possible to
release a library in GNAT without providing ALL of the source code, but
I cannot figure out how to do this. Any guidanace would be much
appreciated!

Thanks,

Mike



             reply	other threads:[~2002-03-08  5:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-08  5:45 Michael Card [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-03-08  7:52 Building a minimal-source-code Ada library with GNAT Christoph Grein
2002-03-09  2:24 ` Michael Card
2002-03-09 15:45   ` Wes Groleau
2002-03-10  2:28     ` Michael Card
replies disabled

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