comp.lang.ada
 help / color / mirror / Atom feed
* GPR: project hierarchy and file names
@ 2010-08-19  3:23 Yannick Duchêne (Hibou57)
  2010-08-19  7:03 ` Dmitry A. Kazakov
  2010-08-19  7:07 ` Yannick Duchêne (Hibou57)
  0 siblings, 2 replies; 10+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2010-08-19  3:23 UTC (permalink / raw)


I wanted to attempt to try something seducing to me: using project  
hierarchy matching packages hierarchy, but with tricky part, as much  
seducing to me, which is to use only to inner package name as the file  
name.

Let me explain, and just imagine there are more files than the following  
example shows.

Let

    Application
    Models
    Models.Object1
    Models.Object2
    Views
    Views.Object1
    Views.Object2

be some package. The common way to name these would be (just to give spec  
file names, would be the same for body)

    application.ads
    models.ads
    models-object1.ads
    models-object2.ads
    views.ads
    views-object1.ads
    views-object2.ads

The seducing idea I wanted to attempt is the following.


Have a directory hierarchy like this

    application
       models
       views


each ones holding their packages, just with shorten file names (using only  
the inner name)

    application
       |- application.ads
       |
       +- models
       |    |- object1.ads
       |    |- object2.ads
       |
       +- views
            |- object1.ads
            |- object2.ads



then, for each, a project file

    application
       |- application.gpr
       |- application.ads
       |
       +- models
       |    |- models.gpr
       |    |- object1.ads
       |    |- object2.ads
       |
       +- views
            |- views.gpr
            |- object1.ads
            |- object2.ads


(the real case hierarchy ranges from 1 to 4 levels)

I followed this step:

    * Created the directory hierarchy
    * Dispatched files to directories depending on their
      position in the packages hierarchy
    * Renamed files to remove the package hierarchy path
      prefix and just keep the proper package name for
      file names (obviously, the source style says
      “package Parent.Child is” for an example)
    * Created the GPR project files files with
      a simple “for Source_Dirs use (".");”
    * Added a With clause for the parent project
      in each child project (like “with "../application.gpr";”
      in both models.gpr and views.gpr)
    * Added a Limited With clause for each subproject in
      parent projects (there is only one in the example:
      “limited with "models/models.gpr";” and
      “limited with "views/views.gpr";” in
      application.gpr);


This was looking fine for me except it seems I got clashes. Let go to the  
GNAT documentation a moment.

http://www.adacore.com/wp-content/files/auto_update/gnat-unw-docs/html/gnat_ugn_12.html#SEC132
It says, about the project manager:

  <<
    One very important aspect of a project hierarchy is that a
    given source can only belong to one project (otherwise the
    project manager would not know which settings apply to it and when
    to recompile it). It means that different project files do not usually
    share source directories or when they do, they need to specify
    precisely which project owns which sources using attribute Source_Files
    or equivalent. By contrast, 2 projects can each own a source with the
    same base file name as long as they live in different directories.
  >>


When it says that a given source must only belongs to a single project, if  
does not mention directly or indirectly nor it does mention With vs  
Limited With. At least, when a project A import a project B which imports  
a project C, then files of C can be used in both A and B. So I suppose I  
have to understand “source can only directly belong to one project”. And  
it days two projects can own files with same base name, as long are they  
are not in the same directory (obvious).

So the above should be OK, but it fails.

When I open any project in a similar hierarchy, I got tons of  
red-highlighted message from GPS, which talks about units which can belong  
to only one project. It seems to be related to base file name, as if I (in  
the context of the above example) rename object1.ads so that they both  
have a different name in the Views and Models directories, there is no  
more error message about object1 unit.


Well, this kind of organization is not formally required, this is just I  
feel it nice, and it is ever possible to make it successed (or something  
similar), I would like to use this one (would ease view of sibling  
hierarchies dependencies, as well as handy in GPS and in any GUI file  
system explorer).


Is this layout or similar, feasible with GPR project files or it is a  
totally excluded idea ?

Note: I wanted to try to use gnatname and Naming package (in GPR files),  
but this does allow directories, it works only with base names.



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

end of thread, other threads:[~2010-08-19  8:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-19  3:23 GPR: project hierarchy and file names Yannick Duchêne (Hibou57)
2010-08-19  7:03 ` Dmitry A. Kazakov
2010-08-19  7:20   ` Yannick Duchêne (Hibou57)
2010-08-19  7:31     ` Pascal Obry
2010-08-19  7:42       ` Dmitry A. Kazakov
2010-08-19  8:35         ` Yannick Duchêne (Hibou57)
2010-08-19  7:50     ` Dmitry A. Kazakov
2010-08-19  8:41       ` Yannick Duchêne (Hibou57)
2010-08-19  8:54         ` Dmitry A. Kazakov
2010-08-19  7:07 ` Yannick Duchêne (Hibou57)

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