diff options
Diffstat (limited to 'gcc/ada/gnatls.adb')
-rw-r--r-- | gcc/ada/gnatls.adb | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/gcc/ada/gnatls.adb b/gcc/ada/gnatls.adb index a2dd0a1ac49..f8fec48d0e4 100644 --- a/gcc/ada/gnatls.adb +++ b/gcc/ada/gnatls.adb @@ -38,6 +38,7 @@ with Osint; use Osint; with Osint.L; use Osint.L; with Output; use Output; with Rident; use Rident; +with Sdefault; with Snames; with Targparm; use Targparm; with Types; use Types; @@ -47,6 +48,18 @@ with GNAT.Case_Util; use GNAT.Case_Util; procedure Gnatls is pragma Ident (Gnat_Static_Version_String); + Ada_Project_Path : constant String := "ADA_PROJECT_PATH"; + -- Name of the env. variable that contains path name(s) of directories + -- where project files may reside. + + Project_Search_Path : constant String := "Project Search Path:"; + -- Label displayed in verbose mode before the directories in the project + -- search path. + -- NOTE: This string may be used by other tools, such as GPS; so, it + -- should not be modified inconsiderately. + + No_Project_Default_Dir : constant String := "-"; + Max_Column : constant := 80; No_Obj : aliased String := "<no_obj>"; @@ -1523,6 +1536,105 @@ begin end loop; Write_Eol; + Write_Eol; + Write_Str (Project_Search_Path); + Write_Eol; + Write_Str (" <Current_Directory>"); + Write_Eol; + + declare + Project_Path : constant String_Access := Getenv (Ada_Project_Path); + + Lib : constant String := + Directory_Separator & "lib" & Directory_Separator; + + First : Natural; + Last : Natural; + + Add_Default_Dir : Boolean := True; + + begin + -- If there is a project path, display each directory in the path + + if Project_Path.all /= "" then + First := Project_Path'First; + + loop + while First <= Project_Path'Last + and then (Project_Path (First) = Path_Separator) + loop + First := First + 1; + end loop; + + exit when First > Project_Path'Last; + + Last := First; + + while Last < Project_Path'Last + and then Project_Path (Last + 1) /= Path_Separator + loop + Last := Last + 1; + end loop; + + -- If the directory is No_Default_Project_Dir, set + -- Add_Default_Dir to False + + if Project_Path (First .. Last) = No_Project_Default_Dir then + Add_Default_Dir := False; + + elsif First /= Last or else Project_Path (First) /= '.' then + -- If the directory is ".", skip it as it is the current + -- directory and it is already the first directory in the + -- project path. + + Write_Str (" "); + Write_Str (Project_Path (First .. Last)); + Write_Eol; + end if; + + First := Last + 1; + end loop; + end if; + + -- Add the default dir, except if "-" was one of the "directories" + -- specified in ADA_PROJECT_DIR. + + if Add_Default_Dir then + Name_Len := 0; + Add_Str_To_Name_Buffer (Sdefault.Search_Dir_Prefix.all); + + -- On Windows, make sure that all directory separators are '\' + + if Directory_Separator /= '/' then + for J in 1 .. Name_Len loop + if Name_Buffer (J) = '/' then + Name_Buffer (J) := Directory_Separator; + end if; + end loop; + end if; + + -- Find the sequence "/lib/" + + while Name_Len >= Lib'Length + and then Name_Buffer (Name_Len - 4 .. Name_Len) /= Lib + loop + Name_Len := Name_Len - 1; + end loop; + + -- If the sequence "/lib"/ was found, display the default + -- directory <prefix>/lib/gnat/. + + if Name_Len >= 5 then + Write_Str (" "); + Write_Str (Name_Buffer (1 .. Name_Len)); + Write_Str ("gnat"); + Write_Char (Directory_Separator); + Write_Eol; + end if; + end if; + end; + + Write_Eol; end if; -- Output usage information when requested |