comp.lang.ada
 help / color / mirror / Atom feed
* Q: Multiple GNAT project files and object directories
@ 2013-07-09 20:44 gautier_niouzes
  2013-07-09 21:27 ` Dmitry A. Kazakov
  2013-07-09 21:42 ` Simon Wright
  0 siblings, 2 replies; 12+ messages in thread
From: gautier_niouzes @ 2013-07-09 20:44 UTC (permalink / raw)


Hello,

Quick question (probably with a long answer ;-) ):
How do I force all object files to land into a single directory, including the object files of "with"-ed projects ?

With
   for Object_Dir use "obj";
only the object files for the project are put into it.
The "with"-ed projects have their own Object_Dir's, and their object files appear there. Fair enough.
Now I have a more complicated situation: a main project with different build modes. So the Object_Dir depends on this build mode:
   case Build_Mode is
      when "Debug" =>
         for Object_Dir use "../obj/debug";
      when "Fast" =>
         for Object_Dir use "../obj/fast";
      when "Profiling" =>
         for Object_Dir use "../obj/profiling";
   end case;
The snag is: the "with"-ed projects do not know about that and use only their own single Object_Dir. GNAT is smart enough to recompile everything in the "with"-ed projects upon a build mode change. But it makes the build very long each time a mode is changed. At worst we would have different sets of compiler options in the object files to be linked.
TIA for any clue...
_________________________ 
Gautier's Ada programming 
http://sf.net/users/gdemont

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-09 20:44 Q: Multiple GNAT project files and object directories gautier_niouzes
@ 2013-07-09 21:27 ` Dmitry A. Kazakov
  2013-07-09 21:42 ` Simon Wright
  1 sibling, 0 replies; 12+ messages in thread
From: Dmitry A. Kazakov @ 2013-07-09 21:27 UTC (permalink / raw)


On Tue, 9 Jul 2013 13:44:26 -0700 (PDT), gautier_niouzes@hotmail.com wrote:

> With
>    for Object_Dir use "obj";
> only the object files for the project are put into it.
> The "with"-ed projects have their own Object_Dir's, and their object files
> appear there. Fair enough.
> Now I have a more complicated situation: a main project with different
> build modes. So the Object_Dir depends on this build mode:
>    case Build_Mode is
>       when "Debug" =>
>          for Object_Dir use "../obj/debug";
>       when "Fast" =>
>          for Object_Dir use "../obj/fast";
>       when "Profiling" =>
>          for Object_Dir use "../obj/profiling";
>    end case;
> The snag is: the "with"-ed projects do not know about that and use only
> their own single Object_Dir. GNAT is smart enough to recompile everything
> in the "with"-ed projects upon a build mode change. But it makes the build
> very long each time a mode is changed. At worst we would have different
> sets of compiler options in the object files to be linked.
> TIA for any clue...

I am using this technique:

with Foo;
project Bar is
   for Object_Dir use ".../.../" & Foo'Object_Dir;
                             ^^^^^ Some path to get to the Foo's directory
from the Bar's directory.

P.S. It would be nice if GPS had a syntax for attributes treated less
literally. I.e. for Foo's Object_Dir meant as a directory rather than mere
a string.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-09 20:44 Q: Multiple GNAT project files and object directories gautier_niouzes
  2013-07-09 21:27 ` Dmitry A. Kazakov
@ 2013-07-09 21:42 ` Simon Wright
  2013-07-10  8:00   ` gautier_niouzes
  2013-07-10  8:28   ` Pascal Obry
  1 sibling, 2 replies; 12+ messages in thread
From: Simon Wright @ 2013-07-09 21:42 UTC (permalink / raw)


gautier_niouzes@hotmail.com writes:

> How do I force all object files to land into a single directory,
> including the object files of "with"-ed projects ?

I think it's a design feature of GNAT Project that you can't.

> With
>    for Object_Dir use "obj";
> only the object files for the project are put into it.

> The "with"-ed projects have their own Object_Dir's, and their object
> files appear there. Fair enough.

> Now I have a more complicated situation: a main project with different
> build modes. So the Object_Dir depends on this build mode:

>    case Build_Mode is
>       when "Debug" =>
>          for Object_Dir use "../obj/debug";
>       when "Fast" =>
>          for Object_Dir use "../obj/fast";
>       when "Profiling" =>
>          for Object_Dir use "../obj/profiling";
>    end case;

> The snag is: the "with"-ed projects do not know about that and use
> only their own single Object_Dir. GNAT is smart enough to recompile
> everything in the "with"-ed projects upon a build mode change. But it
> makes the build very long each time a mode is changed. At worst we
> would have different sets of compiler options in the object files to
> be linked.

Are you sure that GNAT will recompile the 'with'ed projects? I don't
believe I've ever seen it do so.

Unless, of course, the 'with'ed projects use a common project to pick up
the compiler options they're supposed to use.

In which case, why not use the common project to specify an object
subdirectory?

project Common is
   type Modes is ("debug", "profiling", "fast");
   Mode : Modes := external ("MODE", "debug");
   for Source_Files use ();
end Common;

with "common";
project User is
   for Main use ("hello.adb");
   for Object_Dir use ".user/" & Common.Mode;
   for Exec_Dir use ".";
end User;

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-09 21:42 ` Simon Wright
@ 2013-07-10  8:00   ` gautier_niouzes
  2013-07-10  8:28   ` Pascal Obry
  1 sibling, 0 replies; 12+ messages in thread
From: gautier_niouzes @ 2013-07-10  8:00 UTC (permalink / raw)


> Are you sure that GNAT will recompile the 'with'ed projects? I don't
> believe I've ever seen it do so.

Atleast GNAT GPL 2013 for Windows does when I'm with-ing the GWindows project.
I would like to access third-party projects, visible through Ada_Project_Path.
So no in influence on those projects' .gpr (no "common" etc.).

But actually all I need is those projects' source files, so I'll go with Ada_Include_Path. (Since it is an open-source main project, I look for a solution that is easy to set up).

Thanks for the brainstorming :-)

G.
__
PS: perhaps a cool thing in the .gpr system would be a "with" working like Ada "with", and not "use" :-). In this case I just could add GWindows'Source_Dir to the main project's Source_Dir

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-09 21:42 ` Simon Wright
  2013-07-10  8:00   ` gautier_niouzes
@ 2013-07-10  8:28   ` Pascal Obry
  2013-07-10 12:37     ` Simon Wright
  1 sibling, 1 reply; 12+ messages in thread
From: Pascal Obry @ 2013-07-10  8:28 UTC (permalink / raw)


Le 09/07/2013 23:42, Simon Wright a écrit :
> Are you sure that GNAT will recompile the 'with'ed projects? I don't
> believe I've ever seen it do so.

Sure it does, except if the attribute Externally_Built is set. Or
alternatively the .ali are set read-only.

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://v2p.fr.eu.org
  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-10  8:28   ` Pascal Obry
@ 2013-07-10 12:37     ` Simon Wright
  2013-07-10 13:34       ` gautier_niouzes
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Wright @ 2013-07-10 12:37 UTC (permalink / raw)


Pascal Obry <pascal@obry.net> writes:

> Le 09/07/2013 23:42, Simon Wright a écrit :
>> Are you sure that GNAT will recompile the 'with'ed projects? I don't
>> believe I've ever seen it do so.
>
> Sure it does, except if the attribute Externally_Built is set. Or
> alternatively the .ali are set read-only.

It will rebuild if needed (the compiler has changed, or a source of the
'with'ed project has changed, or any other reason).

But it won't rebuild if this project is built with ("-g", "-O0") and the
'with'ed project is built with ("-O2"), which is the sort of change that
OP was talking about. (By "won't rebuild" I mean, I just tried it and it
didn't).

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-10 12:37     ` Simon Wright
@ 2013-07-10 13:34       ` gautier_niouzes
  2013-07-10 17:44         ` J-P. Rosen
  2013-07-10 19:53         ` Simon Wright
  0 siblings, 2 replies; 12+ messages in thread
From: gautier_niouzes @ 2013-07-10 13:34 UTC (permalink / raw)


Le mercredi 10 juillet 2013 14:37:11 UTC+2, Simon Wright a écrit :

> But it won't rebuild if this project is built with ("-g", "-O0") and the
> 'with'ed project is built with ("-O2"), which is the sort of change that
> OP was talking about. (By "won't rebuild" I mean, I just tried it and it
> didn't).

Right - I also just tried.
But GNAT GPL 2012 (not 2013) did (I also tried)!
Anyway neither behaviour is satisfactory (either recompilation with no source change, or no recompilation but mix of .o files with very different compiler options).
Now, the solution with the good old Ada_Include_Path is working perfectly.
Is is even easier than the solution with Ada_Project_Path ...
An example:
http://sf.net/p/azip/code/152/tree/trunk/gwindows/azip_gwindows.gpr
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address


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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-10 13:34       ` gautier_niouzes
@ 2013-07-10 17:44         ` J-P. Rosen
  2013-07-10 19:45           ` Simon Wright
  2013-07-11  3:45           ` gautier_niouzes
  2013-07-10 19:53         ` Simon Wright
  1 sibling, 2 replies; 12+ messages in thread
From: J-P. Rosen @ 2013-07-10 17:44 UTC (permalink / raw)


Le 10/07/2013 15:34, gautier_niouzes@hotmail.com a écrit :
> Le mercredi 10 juillet 2013 14:37:11 UTC+2, Simon Wright a écrit :
> 
>> > But it won't rebuild if this project is built with ("-g", "-O0") and the
>> > 'with'ed project is built with ("-O2"), which is the sort of change that
>> > OP was talking about. (By "won't rebuild" I mean, I just tried it and it
>> > didn't).
> Right - I also just tried.
> But GNAT GPL 2012 (not 2013) did (I also tried)!
Did you notice in "Edit project properties/switches/gnatmake" the option
"recompile if switch changes" ?

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-10 17:44         ` J-P. Rosen
@ 2013-07-10 19:45           ` Simon Wright
  2013-07-11  3:45           ` gautier_niouzes
  1 sibling, 0 replies; 12+ messages in thread
From: Simon Wright @ 2013-07-10 19:45 UTC (permalink / raw)


"J-P. Rosen" <rosen@adalog.fr> writes:

> Le 10/07/2013 15:34, gautier_niouzes@hotmail.com a écrit :
>> Le mercredi 10 juillet 2013 14:37:11 UTC+2, Simon Wright a écrit :
>> 
>>> > But it won't rebuild if this project is built with ("-g", "-O0") and the
>>> > 'with'ed project is built with ("-O2"), which is the sort of change that
>>> > OP was talking about. (By "won't rebuild" I mean, I just tried it and it
>>> > didn't).
>> Right - I also just tried.
>> But GNAT GPL 2012 (not 2013) did (I also tried)!
> Did you notice in "Edit project properties/switches/gnatmake" the option
> "recompile if switch changes" ?

But my point is that changing switches in the 'with'ing project has no
automatic effect on the switches used in the 'with'ed project.

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-10 13:34       ` gautier_niouzes
  2013-07-10 17:44         ` J-P. Rosen
@ 2013-07-10 19:53         ` Simon Wright
  2013-07-11  4:21           ` gautier_niouzes
  1 sibling, 1 reply; 12+ messages in thread
From: Simon Wright @ 2013-07-10 19:53 UTC (permalink / raw)


gautier_niouzes@hotmail.com writes:

> Le mercredi 10 juillet 2013 14:37:11 UTC+2, Simon Wright a écrit :
>
>> But it won't rebuild if this project is built with ("-g", "-O0") and the
>> 'with'ed project is built with ("-O2"), which is the sort of change that
>> OP was talking about. (By "won't rebuild" I mean, I just tried it and it
>> didn't).
>
> Right - I also just tried.
> But GNAT GPL 2012 (not 2013) did (I also tried)!

Not here.

Did you perhaps just change the compiler? that would cause everything to
be rebuilt.


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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-10 17:44         ` J-P. Rosen
  2013-07-10 19:45           ` Simon Wright
@ 2013-07-11  3:45           ` gautier_niouzes
  1 sibling, 0 replies; 12+ messages in thread
From: gautier_niouzes @ 2013-07-11  3:45 UTC (permalink / raw)


Le mercredi 10 juillet 2013 19:44:20 UTC+2, J-P. Rosen a écrit :

> Did you notice in "Edit project properties/switches/gnatmake" the option
> "recompile if switch changes" ?

No trace of the "-s" gnatmake option, neither in the main project, nor in the "with"-ed projects (including recursion of "with"-ing)...

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

* Re: Q: Multiple GNAT project files and object directories
  2013-07-10 19:53         ` Simon Wright
@ 2013-07-11  4:21           ` gautier_niouzes
  0 siblings, 0 replies; 12+ messages in thread
From: gautier_niouzes @ 2013-07-11  4:21 UTC (permalink / raw)


Le mercredi 10 juillet 2013 21:53:51 UTC+2, Simon Wright a écrit :

> Not here.
> 
> Did you perhaps just change the compiler? that would cause everything to
> be rebuilt.

It was not due to a compiler change. Whenever I switched (and again and again...) the build mode, it recompiled (only) the "with"-ed project's.
Now I try to reproduce that: path only with GPL 2012, first build which as expected recompiles everything because of compiler change, then flipping the switch (from the command line this time) - no recompile. Aaaaargh!

G.

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

end of thread, other threads:[~2013-07-11  4:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-09 20:44 Q: Multiple GNAT project files and object directories gautier_niouzes
2013-07-09 21:27 ` Dmitry A. Kazakov
2013-07-09 21:42 ` Simon Wright
2013-07-10  8:00   ` gautier_niouzes
2013-07-10  8:28   ` Pascal Obry
2013-07-10 12:37     ` Simon Wright
2013-07-10 13:34       ` gautier_niouzes
2013-07-10 17:44         ` J-P. Rosen
2013-07-10 19:45           ` Simon Wright
2013-07-11  3:45           ` gautier_niouzes
2013-07-10 19:53         ` Simon Wright
2013-07-11  4:21           ` gautier_niouzes

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