-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2005 Free Software Foundation, Inc. --
+-- Copyright (C) 2001-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
--- MA 02111-1307, USA. --
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
+-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
with Tempdir;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
-with GNAT.OS_Lib; use GNAT.OS_Lib;
package body Prj.Env is
-- and ADA_OBJECTS_PATH are stored.
Ada_Path_Length : Natural := 0;
- -- Index of the last valid character in Ada_Path_Buffer.
+ -- Index of the last valid character in Ada_Path_Buffer
Ada_Prj_Include_File_Set : Boolean := False;
Ada_Prj_Objects_File_Set : Boolean := False;
-- Call Setenv, after calling To_Host_File_Spec
function Ultimate_Extension_Of
- (Project : in Project_Id; In_Tree : Project_Tree_Ref) return Project_Id;
+ (Project : Project_Id;
+ In_Tree : Project_Tree_Ref) return Project_Id;
-- Return a project that is either Project or an extended ancestor of
-- Project that itself is not extended.
if Data.Library then
if Data.Object_Directory = No_Name
or else
- Contains_ALI_Files (Data.Library_Dir)
+ Contains_ALI_Files (Data.Library_ALI_Dir)
then
- Add_To_Path (Get_Name_String (Data.Library_Dir));
+ Add_To_Path (Get_Name_String (Data.Library_ALI_Dir));
else
Add_To_Path (Get_Name_String (Data.Object_Directory));
end if;
and then
(not Including_Libraries or else not Data.Library))
then
- -- For a library project, add the library directory
- -- if there is no object directory or if the library
- -- directory contains ALI files; otherwise add the
- -- object directory.
+ -- For a library project, add the library ALI
+ -- directory if there is no object directory or
+ -- if the library ALI directory contains ALI files;
+ -- otherwise add the object directory.
if Data.Library then
if Data.Object_Directory = No_Name
- or else Contains_ALI_Files (Data.Library_Dir)
+ or else Contains_ALI_Files (Data.Library_ALI_Dir)
then
- Add_To_Object_Path (Data.Library_Dir, In_Tree);
+ Add_To_Object_Path
+ (Data.Library_ALI_Dir, In_Tree);
else
Add_To_Object_Path
(Data.Object_Directory, In_Tree);
end if;
-- For a non-library project, add the object
- -- directory, if it is not a virtual project.
-
- elsif not Data.Virtual then
+ -- directory, if it is not a virtual project, and
+ -- if there are Ada sources or if the project is an
+ -- extending project. if There Are No Ada sources,
+ -- adding the object directory could disrupt
+ -- the order of the object dirs in the path.
+
+ elsif not Data.Virtual
+ and then (In_Tree.Projects.Table
+ (Project).Ada_Sources_Present
+ or else
+ (Data.Extends /= No_Project
+ and then
+ Data.Object_Directory /= No_Name))
+ then
Add_To_Object_Path
(Data.Object_Directory, In_Tree);
end if;
Add (Project);
end if;
- -- Write and close any file that has been created.
+ -- Write and close any file that has been created
if Source_FD /= Invalid_FD then
for Index in Source_Path_Table.First ..
---------------------------
function Ultimate_Extension_Of
- (Project : Project_Id; In_Tree : Project_Tree_Ref) return Project_Id
+ (Project : Project_Id;
+ In_Tree : Project_Tree_Ref) return Project_Id
is
Result : Project_Id := Project;