adagnat

Gpr file, do not include all directory in source


There is my project.gpr file :

project Test is
    Project_Source_Dirs := ("Dir1")
      & ("src")
      & ("../../lib_all");
    for Object_Dir is "lib";
    for Main use ("Main_file.adb");
    for Languages use ("Ada");

    for Source_Dirs use Project_Source_Dirs & project'Object_Dir;
    -- [...]
end Test;

There is my "../../lib_all" folder :

lib_all
|- file1.adb
|- file1.ads
|- file2.adb
|- file2.ads
|- file3.adb
|- file3.ads
|- file4.adb
|- file4.ads

I only want to use file3, how can I modify my .gpr file to not compile all other files each time ?


Solution

  • You can use Source_Files or Excluded_Source_Files settings, as described here: https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html#source-files-and-directories

    But I think, the easier way could be simply moving unneeded files to separated directory and adding that directory with its content on demand (based on variables, etc.).