comp.lang.ada
 help / color / mirror / Atom feed
* [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH
@ 2013-08-25  7:02 gautier_niouzes
  2013-08-26  1:22 ` Stephen Leake
  0 siblings, 1 reply; 7+ messages in thread
From: gautier_niouzes @ 2013-08-25  7:02 UTC (permalink / raw)


The title says most, except it is through a GNAT project (.gpr).

More precisely, all compiled files land into the directory specified in
  for Object_Dir use ...;
That's OK.
But the compiler options specified in

  package Compiler is
    for Default_Switches ("ada") use (...);
  end Compiler;

are applied only to the sources found in
  for Source_Dirs use (...);
and not to sources found in ADA_INCLUDE_PATH.
Bug ? Feature ?
Any way to have the compiler options applied to all sources ?
_________________________
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] 7+ messages in thread

* Re: [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH
  2013-08-25  7:02 [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH gautier_niouzes
@ 2013-08-26  1:22 ` Stephen Leake
  2013-08-26  6:42   ` gautier_niouzes
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2013-08-26  1:22 UTC (permalink / raw)


gautier_niouzes@hotmail.com writes:

> The title says most, except it is through a GNAT project (.gpr).
>
> More precisely, all compiled files land into the directory specified in
>   for Object_Dir use ...;
> That's OK.
> But the compiler options specified in
>
>   package Compiler is
>     for Default_Switches ("ada") use (...);
>   end Compiler;
>
> are applied only to the sources found in
>   for Source_Dirs use (...);
> and not to sources found in ADA_INCLUDE_PATH.

As expected; the options specified in a project file apply to sources
included in the project file. That way, you can have several project
files, each with a list of sources and options.

ADA_INCLUDE_PATH is a hold-over from pre-project-file times.

> Bug ? Feature ?

Feature.

> Any way to have the compiler options applied to all sources ?

Create a project file for the sources now in ADA_INCLUDE_PATH, and
'with' that project file from your main project file.

If you want the same options (sounds like you do), create an 'options'
project file that just defines some variables, and use those variables
in the other project files.    

-- 
-- Stephe


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

* Re: [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH
  2013-08-26  1:22 ` Stephen Leake
@ 2013-08-26  6:42   ` gautier_niouzes
  2013-08-26  7:37     ` Simon Wright
  2013-08-27 12:42     ` Stephen Leake
  0 siblings, 2 replies; 7+ messages in thread
From: gautier_niouzes @ 2013-08-26  6:42 UTC (permalink / raw)


Le lundi 26 août 2013 03:22:14 UTC+2, Stephen Leake a écrit :

[...]
Thanks for the explanations.

> If you want the same options (sounds like you do), create an 'options'
> project file that just defines some variables, and use those variables
> in the other project files.    

There is a snag here. "The other project files" can be XMLAda and many others.
XMLAda only depends on several project files:
xmlada.gpr
xmlada_dom.gpr
xmlada_input.gpr
xmlada_sax.gpr
xmlada_schema.gpr
xmlada_shared.gpr
xmlada_unicode.gpr
So I would need to to special versions of dozens of project files (xmlada2.gpr, ...) for having a reference to options.gpr ?
Then have installation instructions for the users of my project regarding where to place those special project files ?
Do changes in xmlada2.gpr etc. each time xmlada.gpr etc. are changing ?
I seems a bit complicated (to be polite)...
It's very fine when all projects are yours, but if you use many external projects, it is not practical.
Thanks anyway for the explanations. I think I'll stick to ADA_INCLUDE_PATH and a main project and have a script to precompile those library items.
_________________________
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] 7+ messages in thread

* Re: [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH
  2013-08-26  6:42   ` gautier_niouzes
@ 2013-08-26  7:37     ` Simon Wright
  2013-08-26 11:21       ` gautier_niouzes
  2013-08-27 12:42     ` Stephen Leake
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Wright @ 2013-08-26  7:37 UTC (permalink / raw)


gautier_niouzes@hotmail.com writes:

> Le lundi 26 août 2013 03:22:14 UTC+2, Stephen Leake a écrit :
>
> [...]
> Thanks for the explanations.
>
>> If you want the same options (sounds like you do), create an 'options'
>> project file that just defines some variables, and use those variables
>> in the other project files.    
>
> There is a snag here. "The other project files" can be XMLAda and many others.
> XMLAda only depends on several project files:
> xmlada.gpr
> xmlada_dom.gpr
> xmlada_input.gpr
> xmlada_sax.gpr
> xmlada_schema.gpr
> xmlada_shared.gpr
> xmlada_unicode.gpr
> So I would need to to special versions of dozens of project files
> (xmlada2.gpr, ...) for having a reference to options.gpr ?
> Then have installation instructions for the users of my project
> regarding where to place those special project files ?
> Do changes in xmlada2.gpr etc. each time xmlada.gpr etc. are changing ?
> I seems a bit complicated (to be polite)...
> It's very fine when all projects are yours, but if you use many
> external projects, it is not practical.
> Thanks anyway for the explanations. I think I'll stick to
> ADA_INCLUDE_PATH and a main project and have a script to precompile
> those library items.

What are these special compiler options that mean you have to go to all
this trouble? ...

Anyway, if you're using a recent GNAT, consider external_as_list[1] in
your own project file:

   for Source_Dirs use (".") & external_as_list("ADA_SOURCE_PATH", ":");

(NB, *not* ADA_INCLUDE_PATH!)

The ":" would need to be ";" on Windows; I believe there's a trick using
a Windows-only environment variable that lets you determine this in the
project file.

[1] http://docs.adacore.com/gprbuild-docs/html/gprbuild_ug.html#External-Values


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

* Re: [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH
  2013-08-26  7:37     ` Simon Wright
@ 2013-08-26 11:21       ` gautier_niouzes
  2013-08-26 19:21         ` briot.emmanuel
  0 siblings, 1 reply; 7+ messages in thread
From: gautier_niouzes @ 2013-08-26 11:21 UTC (permalink / raw)


Le lundi 26 août 2013 09:37:41 UTC+2, Simon Wright a écrit :

> What are these special compiler options that mean you have to go to all
> this trouble? ...

Only fully normal options: in a "Fast" mode, optimisations and less checks, in a "Debug" mode, the most checks possible, including overflow checks and validity checks.

> Anyway, if you're using a recent GNAT, consider external_as_list[1] in
> your own project file:
> 
>    for Source_Dirs use (".") & external_as_list("ADA_SOURCE_PATH", ":");
 
Thanks *a lot*, it is exactly what I need!
G.


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

* Re: [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH
  2013-08-26 11:21       ` gautier_niouzes
@ 2013-08-26 19:21         ` briot.emmanuel
  0 siblings, 0 replies; 7+ messages in thread
From: briot.emmanuel @ 2013-08-26 19:21 UTC (permalink / raw)


> Only fully normal options: in a "Fast" mode, optimisations and less checks, in a "Debug" mode, the most checks possible, including overflow checks and validity checks.

But it doesn't make sense to change the option in the xmlada project files. That will not automatically recompile XML/Ada (for this, you would need to change the way XML/Ada was compiled and installed).

So I think the answer to your initial question is that you don't want to use ADA_INCLUDE_PATH (which makes your project file harder to distribute for instance), because you don't really need to change the compiler options in the other projects, which are not meant to recompile the corresponding library.


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

* Re: [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH
  2013-08-26  6:42   ` gautier_niouzes
  2013-08-26  7:37     ` Simon Wright
@ 2013-08-27 12:42     ` Stephen Leake
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Leake @ 2013-08-27 12:42 UTC (permalink / raw)


gautier_niouzes@hotmail.com writes:

> Le lundi 26 août 2013 03:22:14 UTC+2, Stephen Leake a écrit :
>
>> If you want the same options (sounds like you do), create an 'options'
>> project file that just defines some variables, and use those variables
>> in the other project files.    
>
> There is a snag here. "The other project files" can be XMLAda and many others.
> XMLAda only depends on several project files:
> xmlada.gpr
> xmlada_dom.gpr
> xmlada_input.gpr
> xmlada_sax.gpr
> xmlada_schema.gpr
> xmlada_shared.gpr
> xmlada_unicode.gpr
> So I would need to to special versions of dozens of project files
> (xmlada2.gpr, ...) for having a reference to options.gpr ?

Why do you want to change the options in those files?

If you really do need to change them, then yes, you need to create lots
of new project files. 

Or just one, that includes all the sources. It depends on why they
were split up in the first place.

Or edit the existing project files in place; use a .diff so you can
apply the same changes in the future.

> Then have installation instructions for the users of my project
> regarding where to place those special project files ?
> Do changes in xmlada2.gpr etc. each time xmlada.gpr etc. are changing ?
> I seems a bit complicated (to be polite)...

Which is why you should not change options in external packages.

You are trusting the package providers to provide good .ad? files; why
do you not trust the .gpr files?

You could lobby upstream to provide hooks for this, although I'm not
clear what that would look like.

> It's very fine when all projects are yours, but if you use many
> external projects, it is not practical.
> Thanks anyway for the explanations. I think I'll stick to
> ADA_INCLUDE_PATH and a main project and have a script to precompile
> those library items.

So you are using one project file to compile all the sources, ignoring
the provided package files. That may be dangerous; some of the packages
may set options that are important (bug workarounds, for example).

You cannot expect users to ignore the project files in xmlada. On
Debian, for example, they are available pre-compiled. And the GNAT
installer compiles them with the provided project files. 

GNAT and Debian (and probably most distributions) provide a standard
place to put project files, so just "with xmlada;" in your project
works. Why are you not doing that?

If you really insist on doing things wrong, just create one project file
that has Source_Dirs set to the same list as your current ADA_INCLUDE_PATH, and
include that project in your project file.

-- 
-- Stephe


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

end of thread, other threads:[~2013-08-27 12:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-25  7:02 [GNAT] compiler options ignored for sources from ADA_INCLUDE_PATH gautier_niouzes
2013-08-26  1:22 ` Stephen Leake
2013-08-26  6:42   ` gautier_niouzes
2013-08-26  7:37     ` Simon Wright
2013-08-26 11:21       ` gautier_niouzes
2013-08-26 19:21         ` briot.emmanuel
2013-08-27 12:42     ` Stephen Leake

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