diff options
author | Emmanuel Briot <briot@adacore.com> | 2010-10-05 09:26:00 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-10-05 11:26:00 +0200 |
commit | a0a786e30d405d181e936f76317e3f1c896d4bfa (patch) | |
tree | d6903f3f2b63fe455d17e373f993509b5a0bf01c /gcc/ada/prj-ext.adb | |
parent | 9d9f5f49ae6d54cac2a967ffdfab8b7b4a113cb9 (diff) | |
download | gcc-a0a786e30d405d181e936f76317e3f1c896d4bfa.zip gcc-a0a786e30d405d181e936f76317e3f1c896d4bfa.tar.gz gcc-a0a786e30d405d181e936f76317e3f1c896d4bfa.tar.bz2 |
gnatcmd.adb, [...] (Project_Search_Path): New type.
2010-10-05 Emmanuel Briot <briot@adacore.com>
* gnatcmd.adb, prj-proc.adb, prj-part.adb, prj-ext.adb, prj-ext.ads,
switch-m.adb, clean.adb, prj-nmsc.adb, prj-nmsc.ads, prj-env.adb,
prj-env.ads, prj-tree.adb, prj-tree.ads (Project_Search_Path): New type.
From-SVN: r164969
Diffstat (limited to 'gcc/ada/prj-ext.adb')
-rw-r--r-- | gcc/ada/prj-ext.adb | 237 |
1 files changed, 0 insertions, 237 deletions
diff --git a/gcc/ada/prj-ext.adb b/gcc/ada/prj-ext.adb index 40816cf..cb2cca2 100644 --- a/gcc/ada/prj-ext.adb +++ b/gcc/ada/prj-ext.adb @@ -23,26 +23,11 @@ -- -- ------------------------------------------------------------------------------ -with Hostparm; -with Makeutl; use Makeutl; -with Opt; with Osint; use Osint; with Prj.Tree; use Prj.Tree; -with Sdefault; package body Prj.Ext is - No_Project_Default_Dir : constant String := "-"; - -- Indicator in the project path to indicate that the default search - -- directories should not be added to the path - - Uninitialized_Prefix : constant String := '#' & Path_Separator; - -- Prefix to indicate that the project path has not been initilized yet. - -- Must be two characters long - - procedure Initialize_Project_Path (Tree : Prj.Tree.Project_Node_Tree_Ref); - -- Initialize Current_Project_Path - --------- -- Add -- --------- @@ -65,25 +50,6 @@ package body Prj.Ext is Name_To_Name_HTable.Set (Tree.External_References, The_Key, The_Value); end Add; - ---------------------------------- - -- Add_Search_Project_Directory -- - ---------------------------------- - - procedure Add_Search_Project_Directory - (Tree : Prj.Tree.Project_Node_Tree_Ref; - Path : String) - is - Tmp : String_Access; - begin - if Tree.Project_Path = null then - Tree.Project_Path := new String'(Uninitialized_Prefix & Path); - else - Tmp := Tree.Project_Path; - Tree.Project_Path := new String'(Tmp.all & Path_Separator & Path); - Free (Tmp); - end if; - end Add_Search_Project_Directory; - ----------- -- Check -- ----------- @@ -109,197 +75,6 @@ package body Prj.Ext is return False; end Check; - ----------------------------- - -- Initialize_Project_Path -- - ----------------------------- - - procedure Initialize_Project_Path (Tree : Prj.Tree.Project_Node_Tree_Ref) is - Add_Default_Dir : Boolean := True; - First : Positive; - Last : Positive; - New_Len : Positive; - New_Last : Positive; - - Ada_Project_Path : constant String := "ADA_PROJECT_PATH"; - Gpr_Project_Path : constant String := "GPR_PROJECT_PATH"; - -- Name of alternate env. variable that contain path name(s) of - -- directories where project files may reside. GPR_PROJECT_PATH has - -- precedence over ADA_PROJECT_PATH. - - Gpr_Prj_Path : String_Access := Getenv (Gpr_Project_Path); - Ada_Prj_Path : String_Access := Getenv (Ada_Project_Path); - -- The path name(s) of directories where project files may reside. - -- May be empty. - - begin - -- The current directory is always first in the search path. Since the - -- Project_Path currently starts with '#:' as a sign that it isn't - -- initialized, we simply replace '#' with '.' - - if Tree.Project_Path = null then - Tree.Project_Path := new String'('.' & Path_Separator); - else - Tree.Project_Path (Tree.Project_Path'First) := '.'; - end if; - - -- Then the reset of the project path (if any) currently contains the - -- directories added through Add_Search_Project_Directory - - -- If environment variables are defined and not empty, add their content - - if Gpr_Prj_Path.all /= "" then - Add_Search_Project_Directory (Tree, Gpr_Prj_Path.all); - end if; - - Free (Gpr_Prj_Path); - - if Ada_Prj_Path.all /= "" then - Add_Search_Project_Directory (Tree, Ada_Prj_Path.all); - end if; - - Free (Ada_Prj_Path); - - -- Copy to Name_Buffer, since we will need to manipulate the path - - Name_Len := Tree.Project_Path'Length; - Name_Buffer (1 .. Name_Len) := Tree.Project_Path.all; - - -- Scan the directory path to see if "-" is one of the directories. - -- Remove each occurrence of "-" and set Add_Default_Dir to False. - -- Also resolve relative paths and symbolic links. - - First := 3; - loop - while First <= Name_Len - and then (Name_Buffer (First) = Path_Separator) - 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; - - -- 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; - - -- After removing the '-', go back one character to get the next - -- directory correctly. - - Last := Last - 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), - Resolve_Links => Opt.Follow_Links_For_Dirs); - - 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; - - Free (Tree.Project_Path); - - -- Set the initial value of Current_Project_Path - - if Add_Default_Dir then - declare - Prefix : String_Ptr := Sdefault.Search_Dir_Prefix; - - begin - if Prefix = null then - Prefix := new String'(Executable_Prefix_Path); - - if Prefix.all /= "" then - if Tree.Target_Name /= null - and then Tree.Target_Name.all /= "" - then - Add_Str_To_Name_Buffer - (Path_Separator & Prefix.all & - "lib" & Directory_Separator & "gpr" & - Directory_Separator & Tree.Target_Name.all); - end if; - - Add_Str_To_Name_Buffer - (Path_Separator & Prefix.all & - "share" & Directory_Separator & "gpr"); - Add_Str_To_Name_Buffer - (Path_Separator & Prefix.all & - "lib" & Directory_Separator & "gnat"); - end if; - - else - Tree.Project_Path := - new String'(Name_Buffer (1 .. Name_Len) & Path_Separator & - Prefix.all & - ".." & Directory_Separator & - ".." & Directory_Separator & - ".." & Directory_Separator & "gnat"); - end if; - - Free (Prefix); - end; - end if; - - if Tree.Project_Path = null then - Tree.Project_Path := new String'(Name_Buffer (1 .. Name_Len)); - end if; - end Initialize_Project_Path; - - ------------------ - -- Project_Path -- - ------------------ - - function Project_Path (Tree : Project_Node_Tree_Ref) return String is - begin - if Tree.Project_Path = null - or else Tree.Project_Path (Tree.Project_Path'First) = '#' - then - Initialize_Project_Path (Tree); - end if; - - return Tree.Project_Path.all; - end Project_Path; - ----------- -- Reset -- ----------- @@ -309,18 +84,6 @@ package body Prj.Ext is Name_To_Name_HTable.Reset (Tree.External_References); end Reset; - ---------------------- - -- Set_Project_Path -- - ---------------------- - - procedure Set_Project_Path - (Tree : Project_Node_Tree_Ref; - New_Path : String) is - begin - Free (Tree.Project_Path); - Tree.Project_Path := new String'(New_Path); - end Set_Project_Path; - -------------- -- Value_Of -- -------------- |