Search code examples
compilationadagprbuild

In Adacore's GPR file, how can I set the compiler to exclude file with full path


I have a project which contains several files which have the same name but in differents folders.

Ex :

 ->sources
    ->src 
      - a.c
      - b.c
    ->stub
      - a.c
      - z.c

In my gprfile I included the source with

for Source_Dirs use ( "sources/**" )

Now, I want to ignore the files in src by using the primitive "Excluded_Source_File".

Unfortunatly, this primitive needs a file name, and not a full path, so when I want to ignore a.c, it ignore the both files in src and stub.

for Excluded_Source_Files use ( "sources/src/a.c" ); -- KO by gprbuild
for Excluded_Source_Files use ( "a.c" ); -- OK but ignore both

Does anyone know how can I do this, without alterate the current folder architecture and without rename files ?


Solution

  • Sounds like what you want is a project extension, ie. create a second project file, which extends the first. In this seconds project file, you can override a.c

    project Stubbed extends "my_project.gpr" is
       for Source_Dirs use ("stub");
    end Stubbed;
    

    You can read more about project extentions in the GPRBuild User Guide