comp.lang.ada
 help / color / mirror / Atom feed
* Compiling Ada from another directory
@ 2007-09-12 21:59 rotinom
  2007-09-12 23:01 ` Georg Bauhaus
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: rotinom @ 2007-09-12 21:59 UTC (permalink / raw)


Hey all.  I'm working with a build tool that pretty much requires me
to build from a single directory, and I'd like to place the objects in
another directory.  This has proven great with everything else, but
when it comes to Ada, I'm hitting a brick wall.

So my command lines so far are:



gcc -c -o _build/Bottles.o src/Bottles.adb
Bottles.adb:6:11: warning: file name does not match unit name, should
be "bottles.adb"
gnatbind -o _build/b~Bottles.adb _build/Bottles.ali
gnatlink -o _build/Bottles.exe _build/Bottles.ali
gnatlink: Failed to open binder output


(Yes, _build/b~Bottles.adb/ads/ali  all exist)

It would seem that I'm missing a command line switch or something
here.  Any help would be greatly appreciated.

Thanks!




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

* Re: Compiling Ada from another directory
  2007-09-12 21:59 Compiling Ada from another directory rotinom
@ 2007-09-12 23:01 ` Georg Bauhaus
  2007-09-12 23:17   ` rotinom
  2007-09-13  0:01 ` Jeffrey R. Carter
  2007-09-13  0:02 ` anon
  2 siblings, 1 reply; 10+ messages in thread
From: Georg Bauhaus @ 2007-09-12 23:01 UTC (permalink / raw)


On Wed, 2007-09-12 at 14:59 -0700, rotinom wrote:
> Hey all.  I'm working with a build tool that pretty much requires me
> to build from a single directory, and I'd like to place the objects in
> another directory.  This has proven great with everything else, but
> when it comes to Ada, I'm hitting a brick wall.

(Maybe this is an effect of assuming that you need to use
similar build tools ;-)

> It would seem that I'm missing a command line switch or something
> here.  Any help would be greatly appreciated.

It seems you are using GNAT. The easiest way to organize
your files into directories of your choice is to create
a minimal project file. The project file will have phrases
such as,

project MyProject is

  For Source_Dirs use (...);
  For Object_Dir use ...;

After you have the project file myproject.gpr , run
$ gnatmake -Pmyproject
or make it part of your build setup. This will read and
write files where you want them.

See
http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Introduction.html#Introduction

Switches on the command line will work, too, but they create
too much noise and complications for my taste, so I hesitate
to mention them.





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

* Re: Compiling Ada from another directory
  2007-09-12 23:01 ` Georg Bauhaus
@ 2007-09-12 23:17   ` rotinom
  0 siblings, 0 replies; 10+ messages in thread
From: rotinom @ 2007-09-12 23:17 UTC (permalink / raw)


> (Maybe this is an effect of assuming that you need to use
> similar build tools ;-)

Quite possibly :)

We operate in a mixed source environment, and we've invested in using
SCons (http://www.scons.org) as our primary build tool.  SCons is
great with it's support with a variety of languages, however Ada was
never picked up (until now).  I'll try to not bore you with details,
but it takes much (if not all) of the "bind" functionality of ada, and
makes it available for other languages.  We're heavily invested into
it, and it's helped us out tremendously with our large project. (It's
really nice to touch one of our heavily depended files, and see a near
entire rebuild of our source tree, because everything is now out of
date).


I've gotten gnatlink to spit out the command line that it's trying to
use, by specifying the -v option.  However, I'm hitting a wall with
the bind file.


The "bad" lines are:
1: pragma Source_File_Name (ada_main, Spec_File_Name => "_build/
b~Bottles.ads");
2: pragma Source_File_Name (ada_main, Body_File_Name => "_build/
b~Bottles.adb");

When I try to compile it, I get:

gcc -c -gnatA -gnatWb -gnatiw -mtune=pentiumpro -gnatws _build/
b~Bottles.adb
b~Bottles.adb:1:61: directory separator character not allowed
b~Bottles.adb:2:61: directory separator character not allowed



TIA




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

* Re: Compiling Ada from another directory
  2007-09-12 21:59 Compiling Ada from another directory rotinom
  2007-09-12 23:01 ` Georg Bauhaus
@ 2007-09-13  0:01 ` Jeffrey R. Carter
  2007-09-13  0:02 ` anon
  2 siblings, 0 replies; 10+ messages in thread
From: Jeffrey R. Carter @ 2007-09-13  0:01 UTC (permalink / raw)


rotinom wrote:
> Hey all.  I'm working with a build tool that pretty much requires me
> to build from a single directory, and I'd like to place the objects in
> another directory.  This has proven great with everything else, but
> when it comes to Ada, I'm hitting a brick wall.

You should understand that this is not an Ada question. This is a 
compiler question. Different compilers will handle this differently. You 
really should specify your compiler, compiler version, and host and 
target platforms.

 From your examples, I'm going to guess that you're using some version 
of GNAT, self targeted on some version of Windows.

Project files provide a simple way to specify that GNAT's compilation 
artifacts (.o and .ali) go in a different directory. A careful reading 
of the secret documentation (probably the GNAT Users Guide) will tell 
you about switches such as -I that give you further control over where 
it will look for things.

-- 
Jeff Carter
"Go and boil your bottoms."
Monty Python & the Holy Grail
01



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

* Re: Compiling Ada from another directory
  2007-09-12 21:59 Compiling Ada from another directory rotinom
  2007-09-12 23:01 ` Georg Bauhaus
  2007-09-13  0:01 ` Jeffrey R. Carter
@ 2007-09-13  0:02 ` anon
  2007-09-13 14:16   ` rotinom
  2 siblings, 1 reply; 10+ messages in thread
From: anon @ 2007-09-13  0:02 UTC (permalink / raw)



#
# The "bind" and "link" functions do not require command line options 
#
gcc -c -o _build/Bottles.o src/Bottles.adb
gnatbind _build/Bottles.ali
gnatlink _build/Bottles.ali


# The simpler way or with users defined packages:
#
# object_directory => is the directory for *.ali and *.o and executable
# source_directory => is the directory with all user's Ada source files
# unit.adb => user main compilation_unit

cd object_directory 
gnatmake ../source_directory/unit.adb 

#
# for a compile list of command line options
#
# gnatmake -help 
# 


In <1189634389.893905.5800@50g2000hsm.googlegroups.com>,  rotinom <rotinom@gmail.com> writes:
>Hey all.  I'm working with a build tool that pretty much requires me
>to build from a single directory, and I'd like to place the objects in
>another directory.  This has proven great with everything else, but
>when it comes to Ada, I'm hitting a brick wall.
>
>So my command lines so far are:
>
>
>
>gcc -c -o _build/Bottles.o src/Bottles.adb
>Bottles.adb:6:11: warning: file name does not match unit name, should
>be "bottles.adb"
>gnatbind -o _build/b~Bottles.adb _build/Bottles.ali
>gnatlink -o _build/Bottles.exe _build/Bottles.ali
>gnatlink: Failed to open binder output
>
>
>(Yes, _build/b~Bottles.adb/ads/ali  all exist)
>
>It would seem that I'm missing a command line switch or something
>here.  Any help would be greatly appreciated.
>
>Thanks!
>




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

* Re: Compiling Ada from another directory
  2007-09-13  0:02 ` anon
@ 2007-09-13 14:16   ` rotinom
  2007-09-13 15:01     ` Markus E L
  2007-09-13 22:22     ` Simon Wright
  0 siblings, 2 replies; 10+ messages in thread
From: rotinom @ 2007-09-13 14:16 UTC (permalink / raw)


On Sep 12, 7:02 pm, a...@anon.org (anon) wrote:
> #
> # The "bind" and "link" functions do not require command line options
> #
> gcc -c -o _build/Bottles.o src/Bottles.adb
> gnatbind _build/Bottles.ali
> gnatlink _build/Bottles.ali
>

I played with the project files yesterday, and they do what I want,
however I would then have to maintain them, and they

After playing around with it, it appears that this is the *best*
solution.  The downside however, is that gnatbind creates the b~*
"temporary" files in the current directory.  gnatlink is kind enough
to remove them, however it still sort of stinks. I'd need to go back
and check, but I seem to recall that if I "slowed" gnatmake -P
<project file> down to build one step at a time, it was able to place
the b~* files in the "Object" directory.

Thanks for the help everyone.




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

* Re: Compiling Ada from another directory
  2007-09-13 14:16   ` rotinom
@ 2007-09-13 15:01     ` Markus E L
  2007-09-17 19:08       ` rotinom
  2007-09-13 22:22     ` Simon Wright
  1 sibling, 1 reply; 10+ messages in thread
From: Markus E L @ 2007-09-13 15:01 UTC (permalink / raw)



rotinom wrote:

> On Sep 12, 7:02 pm, a...@anon.org (anon) wrote:
>> #
>> # The "bind" and "link" functions do not require command line options
>> #
>> gcc -c -o _build/Bottles.o src/Bottles.adb
>> gnatbind _build/Bottles.ali
>> gnatlink _build/Bottles.ali
>>
>
> I played with the project files yesterday, and they do what I want,
> however I would then have to maintain them, and they

I'm not sure I understand your problem: I think you want to keep the
source at some other place than the objects? Then you can build in the
object directory and use -I to pull in (various) source trees, e.g:

  cd $OBJECTDIR

  gnatmake -I$PLATFORM_SOURCES -I$LIBRARY_SOURCES -IPROGRAM_SOURCES $PROGRAM

In this case you wouldn't have to maintain project files. And all
object an temporary files are build in the current directory.

Regards -- Markus



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

* Re: Compiling Ada from another directory
  2007-09-13 14:16   ` rotinom
  2007-09-13 15:01     ` Markus E L
@ 2007-09-13 22:22     ` Simon Wright
  1 sibling, 0 replies; 10+ messages in thread
From: Simon Wright @ 2007-09-13 22:22 UTC (permalink / raw)


rotinom <rotinom@gmail.com> writes:

> On Sep 12, 7:02 pm, a...@anon.org (anon) wrote:
>> #
>> # The "bind" and "link" functions do not require command line options
>> #
>> gcc -c -o _build/Bottles.o src/Bottles.adb
>> gnatbind _build/Bottles.ali
>> gnatlink _build/Bottles.ali
>>
>
> I played with the project files yesterday, and they do what I want,
> however I would then have to maintain them, and they
>
> After playing around with it, it appears that this is the *best*
> solution.  The downside however, is that gnatbind creates the b~*
> "temporary" files in the current directory.  gnatlink is kind enough
> to remove them, however it still sort of stinks. I'd need to go back
> and check, but I seem to recall that if I "slowed" gnatmake -P
> <project file> down to build one step at a time, it was able to place
> the b~* files in the "Object" directory.

I really think you should reconsider.

If you don't use GPRs you're going to have to use Makefile equivalents
which will be hugely more complicated to get right.

gnatmake always puts b~ files in the object directory.

Just as a 'simple' self-contained example,

   project EWS is

     for Main use ("ews-server-test", "ews-make_htdocs");
     for Exec_Dir use ".";

     for Source_Dirs use
       (
        ".",
        external ("HOME") & "/bc",
        external ("HOME") & "/xmlada/**"
       );

     for Object_Dir use ".build";

     --  GLIDE (GPS?) configuration.
     package IDE is

        for Compiler_Command ("ada") use "gnatmake";
        for Gnatlist use "gnatls";

     end IDE;

     --  GNATMAKE configuration options.
     package Builder is

        for Default_Switches ("ada") use
          (
           "-g",
           "-j2",
           "-m"
          );

     end Builder;

     --  GCC configuration options.
     package Compiler is

        for Default_Switches ("ada") use
          (
           "-gnatqQafoy",
           "-gnatwaL",
           "-O2"
          );

     end Compiler;

     -- GNATBIND configuration options.
     package Binder is

        for Default_Switches ("ada") use ("-E");

     end Binder;

     --  GNATLINK configuration options.
     package Linker is

     end Linker;

   end EWS;



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

* Re: Compiling Ada from another directory
  2007-09-13 15:01     ` Markus E L
@ 2007-09-17 19:08       ` rotinom
  2007-09-18 21:21         ` Simon Wright
  0 siblings, 1 reply; 10+ messages in thread
From: rotinom @ 2007-09-17 19:08 UTC (permalink / raw)



RE: Simon

You're right that the Project files are rather trivial, and the
easiest way to go.  However I am using a build tool called SCons, and
adding Ada support to that.  It has support for dozens of languages,
and handles the dependency issues that gnatmake does by itself.  I'm
just figuring out what the gnattools do under the hood, and adding
that support in.


RE: Markus

A few days late, but the basic problem is that the SCons tool runs
everything out of the directory where the SConstruct file is located
(e.g.: The build root.).

A typical tree layout is:

/src/
/build_dir/
/SConstruct

so, when you build, all commands run as if you were sitting in / .
There is only ever one "current" directory, but SCons can (and
typically does) run with multiple threads at the same time (I've run
it with up to 50 simultaneous threads).  If each Action being run were
to change directory, it would cause havok, so it is really to be
avoided at all costs.

I was having problems getting the correct commands to run as I needed
them to run from this build root.





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

* Re: Compiling Ada from another directory
  2007-09-17 19:08       ` rotinom
@ 2007-09-18 21:21         ` Simon Wright
  0 siblings, 0 replies; 10+ messages in thread
From: Simon Wright @ 2007-09-18 21:21 UTC (permalink / raw)


rotinom <rotinom@gmail.com> writes:

> You're right that the Project files are rather trivial, and the
> easiest way to go.  However I am using a build tool called SCons, and
> adding Ada support to that.  It has support for dozens of languages,
> and handles the dependency issues that gnatmake does by itself.  I'm
> just figuring out what the gnattools do under the hood, and adding
> that support in.

Sounds like a lot of work to do that! Have to deal with generics,
inlining, all sorts of stuff; gnatbind will say 'no, you should have
recompiled foo.adb' and isn't likely to say '... because it withs Bar,
which has an inlined subprogram, and bar.adb has been changed in a
non-trivial way'.

We used Ant (I've only just figured out that the reason I have so much
trouble grasping Ant is that it's procedural rather than
declarative!), and had targets to use gnatmake to build the Ada bits.

You used to have to do clever stuff with the gnat tools when the main
program wasn't in Ada, but I believe that's much easier now (not
working on that project any more, hence the vagueness).



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

end of thread, other threads:[~2007-09-18 21:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-12 21:59 Compiling Ada from another directory rotinom
2007-09-12 23:01 ` Georg Bauhaus
2007-09-12 23:17   ` rotinom
2007-09-13  0:01 ` Jeffrey R. Carter
2007-09-13  0:02 ` anon
2007-09-13 14:16   ` rotinom
2007-09-13 15:01     ` Markus E L
2007-09-17 19:08       ` rotinom
2007-09-18 21:21         ` Simon Wright
2007-09-13 22:22     ` Simon Wright

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