===================================================================
@@ -1105,6 +1105,7 @@
Free (Project.Ada_Include_Path);
Free (Project.Objects_Path);
Free (Project.Ada_Objects_Path);
+ Free (Project.Ada_Objects_Path_No_Libs);
Free_List (Project.Imported_Projects, Free_Project => False);
Free_List (Project.All_Imported_Projects, Free_Project => False);
Free_List (Project.Languages);
@@ -1485,7 +1486,10 @@
if Project.Library then
if Project.Object_Directory = No_Path_Information
- or else Contains_ALI_Files (Project.Library_ALI_Dir.Display_Name)
+ or else
+ (Including_Libraries
+ and then
+ Contains_ALI_Files (Project.Library_ALI_Dir.Display_Name))
then
return Project.Library_ALI_Dir.Display_Name;
else
===================================================================
@@ -973,11 +973,12 @@
Only_If_Ada : Boolean := False) return Path_Name_Type;
-- Return the object directory to use for the project. This depends on
-- whether we have a library project or a standard project. This function
- -- might return No_Name when no directory applies.
- -- If we have a library project file and Including_Libraries is True then
- -- the library dir is returned instead of the object dir.
- -- If Only_If_Ada is True, then No_Name will be returned when the project
- -- doesn't Ada sources.
+ -- might return No_Name when no directory applies. If the project is a
+ -- library project file and Including_Libraries is True then the library
+ -- ALI dir is returned instead of the object dir, except when there is no
+ -- ALI files in the Library ALI dir and the object directory exists. If
+ -- Only_If_Ada is True, then No_Name is returned when the project doesn't
+ -- include any Ada source.
procedure Compute_All_Imported_Projects
(Root_Project : Project_Id;
@@ -1400,10 +1401,15 @@
-------------------
Ada_Objects_Path : String_Access := null;
- -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
- -- use this field directly outside of the compiler, use
- -- Prj.Env.Ada_Objects_Path instead.
+ -- The cached value of ADA_OBJECTS_PATH for this project file, with
+ -- library ALI directories for library projects instead of object
+ -- directories. Do not use this field directly outside of the
+ -- compiler, use Prj.Env.Ada_Objects_Path instead.
+ Ada_Objects_Path_No_Libs : String_Access := null;
+ -- The cached value of ADA_OBJECTS_PATH for this project file with all
+ -- object directories (no library ALI dir for library projects).
+
Libgnarl_Needed : Yes_No_Unknown := Unknown;
-- Set to True when libgnarl is needed to link
===================================================================
@@ -219,21 +219,37 @@
Dummy : Boolean := False;
+ Result : String_Access;
+
-- Start of processing for Ada_Objects_Path
begin
-- If it is the first time we call this function for
-- this project, compute the objects path
- if Project.Ada_Objects_Path = null then
+ if Including_Libraries and then Project.Ada_Objects_Path /= null then
+ return Project.Ada_Objects_Path;
+
+ elsif not Including_Libraries
+ and then Project.Ada_Objects_Path_No_Libs /= null
+ then
+ return Project.Ada_Objects_Path_No_Libs;
+
+ else
Buffer := new String (1 .. 4096);
For_All_Projects (Project, In_Tree, Dummy);
+ Result := new String'(Buffer (1 .. Buffer_Last));
+ Free (Buffer);
- Project.Ada_Objects_Path := new String'(Buffer (1 .. Buffer_Last));
- Free (Buffer);
+ if Including_Libraries then
+ Project.Ada_Objects_Path := Result;
+
+ else
+ Project.Ada_Objects_Path_No_Libs := Result;
+ end if;
+
+ return Result;
end if;
-
- return Project.Ada_Objects_Path;
end Ada_Objects_Path;
-------------------
===================================================================
@@ -90,9 +90,12 @@
(Project : Project_Id;
In_Tree : Project_Tree_Ref;
Including_Libraries : Boolean := True) return String_Access;
- -- Get the ADA_OBJECTS_PATH of a Project file. For the first call, compute
- -- it and cache it. When Including_Libraries is False, do not include the
- -- object directories of the library projects, and do not cache the result.
+ -- Get the ADA_OBJECTS_PATH of a Project file. For the first call with the
+ -- exact same parameters, compute it and cache it. When Including_Libraries
+ -- is False, the object directory of a library project is replaced with the
+ -- library ALI directory of this project (usually the library directory of
+ -- the project, except when attribute Library_ALI_Dir is declared) except
+ -- when the library ALI directory does not contain any ALI file.
procedure Set_Ada_Paths
(Project : Project_Id;