diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 10:40:57 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 10:40:57 +0000 |
commit | 5c94c0dc65c17599419076890d5ae243656087bd (patch) | |
tree | ad06a04bf2d5c7b5b962784f36f8f4c897320e98 /gcc/ada/prj-ext.adb | |
parent | d3ac8b3a5c0c76eba7ad2f6c0d00bfabf6cddabd (diff) | |
download | ppe42-gcc-5c94c0dc65c17599419076890d5ae243656087bd.tar.gz ppe42-gcc-5c94c0dc65c17599419076890d5ae243656087bd.zip |
2007-04-20 Vincent Celier <celier@adacore.com>
* prj.adb (Project_Empty): Gives default value for new component
Libgnarl_Needed
* prj-attr.ads: Minor reformatting
* prj-env.ads, prj-env.adb (For_All_Object_Dirs): Register object
directory using the untouched casing.
(For_All_Source_Dirs): Idem.
* prj-ext.ads, prj-ext.adb (Search_Directories): New table to record
directories specified with switches -aP.
(Add_Search_Project_Directory): New procedure
(Initialize_Project_Path): Put the directories in table
Search_Directories in the project search path.
(Initialize_Project_Path): For VMS, transform into canonical form the
project path.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125442 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/prj-ext.adb')
-rw-r--r-- | gcc/ada/prj-ext.adb | 167 |
1 files changed, 102 insertions, 65 deletions
diff --git a/gcc/ada/prj-ext.adb b/gcc/ada/prj-ext.adb index f30c70936dd..4ab0a905322 100644 --- a/gcc/ada/prj-ext.adb +++ b/gcc/ada/prj-ext.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2000-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 2000-2007, 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- -- @@ -26,7 +26,6 @@ with Hostparm; with Makeutl; use Makeutl; -with Namet; use Namet; with Output; use Output; with Osint; use Osint; with Sdefault; @@ -68,6 +67,15 @@ package body Prj.Ext is -- first for external reference in this table, before checking the -- environment. Htable is emptied (reset) by procedure Reset. + package Search_Directories is new Table.Table + (Table_Component_Type => Name_Id, + Table_Index_Type => Natural, + Table_Low_Bound => 1, + Table_Initial => 4, + Table_Increment => 100, + Table_Name => "Prj.Ext.Search_Directories"); + -- The table for the directories specified with -aP switches + --------- -- Add -- --------- @@ -89,6 +97,17 @@ package body Prj.Ext is Htable.Set (The_Key, The_Value); end Add; + ---------------------------------- + -- Add_Search_Project_Directory -- + ---------------------------------- + + procedure Add_Search_Project_Directory (Path : String) is + begin + Name_Len := 0; + Add_Str_To_Name_Buffer (Path); + Search_Directories.Append (Name_Find); + end Add_Search_Project_Directory; + ----------- -- Check -- ----------- @@ -121,10 +140,15 @@ package body Prj.Ext is Last : Positive; New_Len : Positive; New_Last : Positive; - Prj_Path : String_Access := Gpr_Prj_Path; + Prj_Path : String_Access := null; begin if Gpr_Prj_Path.all /= "" then + if Hostparm.OpenVMS then + Prj_Path := To_Canonical_Path_Spec ("GPR_PROJECT_PATH:"); + else + Prj_Path := To_Canonical_Path_Spec (Gpr_Prj_Path.all); + end if; -- Warn if both environment variables are defined @@ -133,8 +157,12 @@ package body Prj.Ext is Write_Line (" when GPR_PROJECT_PATH is defined"); end if; - else - Prj_Path := Ada_Prj_Path; + elsif Ada_Prj_Path.all /= "" then + if Hostparm.OpenVMS then + Prj_Path := To_Canonical_Path_Spec ("ADA_PROJECT_PATH:"); + else + Prj_Path := To_Canonical_Path_Spec (Ada_Prj_Path.all); + end if; end if; -- The current directory is always first @@ -142,80 +170,89 @@ package body Prj.Ext is Name_Len := 1; Name_Buffer (Name_Len) := '.'; - -- If environment variable is defined and not empty, add its content + -- If there are directories in the Search_Directories table, add them + + for J in 1 .. Search_Directories.Last loop + Name_Len := Name_Len + 1; + Name_Buffer (Name_Len) := Path_Separator; + Add_Str_To_Name_Buffer + (Get_Name_String (Search_Directories.Table (J))); + end loop; + + -- If environment variable is defined, add its content - if Prj_Path.all /= "" then + if Prj_Path /= null then Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Path_Separator; Add_Str_To_Name_Buffer (Prj_Path.all); + end if; - -- Scan the directory path to see if "-" is one of the directories. - -- Remove each occurence of "-" and set Add_Default_Dir to False. - -- Also resolve relative paths and symbolic links. + -- Scan the directory path to see if "-" is one of the directories. + -- Remove each occurence of "-" and set Add_Default_Dir to False. + -- Also resolve relative paths and symbolic links. - First := 3; + First := 3; + loop + while First <= Name_Len + and then (Name_Buffer (First) = Path_Separator) loop - while First <= Name_Len - and then (Name_Buffer (First) = Path_Separator) - loop - First := First + 1; - end loop; + First := First + 1; + end loop; + + exit when First > Name_Len; + + Last := First; + + while Last < Name_Len + and then Name_Buffer (Last + 1) /= Path_Separator + loop + Last := Last + 1; + end loop; - exit when First > Name_Len; + -- If the directory is "-", set Add_Default_Dir to False and + -- remove from path. - Last := First; + if Name_Buffer (First .. Last) = No_Project_Default_Dir then + Add_Default_Dir := False; - while Last < Name_Len - and then Name_Buffer (Last + 1) /= Path_Separator - loop - Last := Last + 1; + for J in Last + 1 .. Name_Len loop + Name_Buffer (J - No_Project_Default_Dir'Length - 1) := + Name_Buffer (J); end loop; - -- If the directory is "-", set Add_Default_Dir to False and - -- remove from path. - - if Name_Buffer (First .. Last) = No_Project_Default_Dir then - Add_Default_Dir := False; - - for J in Last + 1 .. Name_Len loop - Name_Buffer (J - No_Project_Default_Dir'Length - 1) := - Name_Buffer (J); - end loop; - - Name_Len := Name_Len - No_Project_Default_Dir'Length - 1; - - elsif not Hostparm.OpenVMS - or else not Is_Absolute_Path (Name_Buffer (First .. Last)) - then - -- On VMS, only expand relative path names, as absolute paths - -- may correspond to multi-valued VMS logical names. - - declare - New_Dir : constant String := - Normalize_Pathname (Name_Buffer (First .. Last)); - - begin - -- If the absolute path was resolved and is different from - -- the original, replace original with the resolved path. - - if New_Dir /= Name_Buffer (First .. Last) - and then New_Dir'Length /= 0 - then - New_Len := Name_Len + New_Dir'Length - (Last - First + 1); - New_Last := First + New_Dir'Length - 1; - Name_Buffer (New_Last + 1 .. New_Len) := - Name_Buffer (Last + 1 .. Name_Len); - Name_Buffer (First .. New_Last) := New_Dir; - Name_Len := New_Len; - Last := New_Last; - end if; - end; - end if; + Name_Len := Name_Len - No_Project_Default_Dir'Length - 1; + + elsif not Hostparm.OpenVMS + or else not Is_Absolute_Path (Name_Buffer (First .. Last)) + then + -- On VMS, only expand relative path names, as absolute paths + -- may correspond to multi-valued VMS logical names. + + declare + New_Dir : constant String := + Normalize_Pathname (Name_Buffer (First .. Last)); + + begin + -- If the absolute path was resolved and is different from + -- the original, replace original with the resolved path. + + if New_Dir /= Name_Buffer (First .. Last) + and then New_Dir'Length /= 0 + then + New_Len := Name_Len + New_Dir'Length - (Last - First + 1); + New_Last := First + New_Dir'Length - 1; + Name_Buffer (New_Last + 1 .. New_Len) := + Name_Buffer (Last + 1 .. Name_Len); + Name_Buffer (First .. New_Last) := New_Dir; + Name_Len := New_Len; + Last := New_Last; + end if; + end; + end if; - First := Last + 1; - end loop; - end if; + First := Last + 1; + end loop; -- Set the initial value of Current_Project_Path |