with GNAT.Dynamic_HTables;
with Err_Vars; use Err_Vars;
-with MLib.Tgt;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
-with Prj.Env; use Prj.Env;
-with Prj.Err;
+with Prj.Err; use Prj.Err;
with Prj.Util; use Prj.Util;
with Sinput.P;
with Snames; use Snames;
-- Used in Check_Library for continuation error messages at the same
-- location.
- ALI_Suffix : constant String := ".ali";
- -- File suffix for ali files
-
type Name_Location is record
Name : File_Name_Type; -- ??? duplicates the key
Location : Source_Ptr;
Key => File_Name_Type,
Hash => Hash,
Equal => "=");
- -- A hash table to store the base names of excluded files, if any.
+ -- A hash table to store the base names of excluded files, if any
package Object_File_Names_Htable is new GNAT.Dynamic_HTables.Simple_HTable
(Header_Num => Header_Num,
Hash => Hash,
Equal => "=");
-- Mapping from base file names to Source_Id (containing full info about
- -- the source)
+ -- the source).
type Tree_Processing_Data is record
Tree : Project_Tree_Ref;
procedure Check
(Project : Project_Id;
Data : in out Tree_Processing_Data);
- -- Process the naming scheme for a single project.
+ -- Process the naming scheme for a single project
procedure Initialize
(Data : in out Project_Processing_Data;
(Id : out Source_Id;
Data : in out Tree_Processing_Data;
Project : Project_Id;
+ Source_Dir_Rank : Natural;
Lang_Id : Language_Ptr;
Kind : Source_Kind;
File_Name : File_Name_Type;
Display_File : File_Name_Type;
- Naming_Exception : Boolean := False;
+ Naming_Exception : Boolean := False;
Path : Path_Information := No_Path_Information;
- Alternate_Languages : Language_List := null;
- Unit : Name_Id := No_Name;
- Index : Int := 0;
- Location : Source_Ptr := No_Location);
+ Alternate_Languages : Language_List := null;
+ Unit : Name_Id := No_Name;
+ Index : Int := 0;
+ Locally_Removed : Boolean := False;
+ Location : Source_Ptr := No_Location);
-- Add a new source to the different lists: list of all sources in the
-- project tree, list of source of a project and list of sources of a
-- language.
-- Copy Str into Name_Buffer, replacing Pattern with Replacement. Str is
-- converted to lower-case at the same time.
- function ALI_File_Name (Source : String) return String;
- -- Return the ALI file name corresponding to a source
-
procedure Check_Ada_Name (Name : String; Unit : out Name_Id);
-- Check that a name is a valid Ada unit name
procedure Check_Package_Naming
- (Project : Project_Id;
- Data : in out Tree_Processing_Data;
- Bodies : out Array_Element_Id;
- Specs : out Array_Element_Id);
+ (Project : Project_Id;
+ Data : in out Tree_Processing_Data;
+ Bodies : out Array_Element_Id;
+ Specs : out Array_Element_Id);
-- Check the naming scheme part of Data, and initialize the naming scheme
-- data in the config of the various languages. This also returns the
-- naming scheme exceptions for unit-based languages (Bodies and Specs are
-- tree Data.Tree and set the components of Data for all the programming
-- languages indicated in attribute Languages, if any.
- function Check_Project
- (P : Project_Id;
- Root_Project : Project_Id;
- Extending : Boolean) return Boolean;
- -- Returns True if P is Root_Project or, if Extending is True, a project
- -- extended by Root_Project.
-
procedure Check_Stand_Alone_Library
- (Project : Project_Id;
- Extending : Boolean;
- Data : in out Tree_Processing_Data);
+ (Project : Project_Id;
+ Data : in out Tree_Processing_Data);
-- Check if project Project in project tree Data.Tree is a Stand-Alone
-- Library project, and modify its data Data accordingly if it is one.
-- Return the index of the last significant character in Dir. This is used
-- to avoid duplicate '/' (slash) characters at the end of directory names.
- procedure Error_Msg
- (Project : Project_Id;
- Msg : String;
- Flag_Location : Source_Ptr;
- Data : Tree_Processing_Data);
- -- Output an error message. If Data.Error_Report is null, simply call
- -- Prj.Err.Error_Msg. Otherwise, disregard Flag_Location and use
- -- Error_Report.
-
procedure Search_Directories
(Project : in out Project_Processing_Data;
Data : in out Tree_Processing_Data;
For_All_Sources : Boolean);
-- Search the source directories to find the sources. If For_All_Sources is
-- True, check each regular file name against the naming schemes of the
- -- different languages. Otherwise consider only the file names in the hash
- -- table Source_Names. If Allow_Duplicate_Basenames, then files with the
- -- same base names are authorized within a project for source-based
- -- languages (never for unit based languages)
+ -- various languages. Otherwise consider only the file names in hash table
+ -- Source_Names. If Allow_Duplicate_Basenames then files with identical
+ -- base names are permitted within a project for source-based languages
+ -- (never for unit based languages).
procedure Check_File
(Project : in out Project_Processing_Data;
Data : in out Tree_Processing_Data;
+ Source_Dir_Rank : Natural;
Path : Path_Name_Type;
File_Name : File_Name_Type;
Display_File_Name : File_Name_Type;
-- File_Name is the same as Name, but has been normalized.
-- Display_File_Name, however, has not been normalized.
--
- -- Source_Directory is the directory in which the file
- -- was found. It hasn't been normalized (nor has had links resolved).
- -- It should not end with a directory separator, to avoid duplicates
- -- later on.
+ -- Source_Directory is the directory in which the file was found. It is
+ -- neither normalized nor has had links resolved, and must not end with a
+ -- a directory separator, to avoid duplicates later on.
--
-- If For_All_Sources is True, then all possible file names are analyzed
- -- otherwise only those currently set in the Source_Names htable.
+ -- otherwise only those currently set in the Source_Names hash table.
procedure Check_File_Naming_Schemes
(In_Tree : Project_Tree_Ref;
end if;
declare
- Suf : constant String := Get_Name_String (Suffix);
+ Suf : String := Get_Name_String (Suffix);
begin
+ -- On non case-sensitive systems, use proper suffix casing
+
+ Canonical_Case_File_Name (Suf);
+
-- The file name must end with the suffix (which is not an extension)
-- For instance a suffix "configure.in" must match a file with the
-- same name. To avoid dummy cases, though, a suffix starting with
(Id : out Source_Id;
Data : in out Tree_Processing_Data;
Project : Project_Id;
+ Source_Dir_Rank : Natural;
Lang_Id : Language_Ptr;
Kind : Source_Kind;
File_Name : File_Name_Type;
Display_File : File_Name_Type;
- Naming_Exception : Boolean := False;
+ Naming_Exception : Boolean := False;
Path : Path_Information := No_Path_Information;
- Alternate_Languages : Language_List := null;
- Unit : Name_Id := No_Name;
- Index : Int := 0;
- Location : Source_Ptr := No_Location)
+ Alternate_Languages : Language_List := null;
+ Unit : Name_Id := No_Name;
+ Index : Int := 0;
+ Locally_Removed : Boolean := False;
+ Location : Source_Ptr := No_Location)
is
Config : constant Language_Config := Lang_Id.Config;
UData : Unit_Index;
Add_Src : Boolean;
Source : Source_Id;
Prev_Unit : Unit_Index := No_Unit_Index;
+
Source_To_Replace : Source_Id := No_Source;
begin
end if;
if Prev_Unit /= No_Unit_Index
- and then (Kind = Impl or Kind = Spec)
+ and then (Kind = Impl or else Kind = Spec)
and then Prev_Unit.File_Names (Kind) /= null
then
-- Suspicious, we need to check later whether this is authorized
if Data.Flags.Allow_Duplicate_Basenames then
Add_Src := True;
- elsif Project.Known_Order_Of_Source_Dirs then
+ elsif Source_Dir_Rank /= Source.Source_Dir_Rank then
Add_Src := False;
else
Error_Msg_File_1 := File_Name;
Error_Msg
- (Project, "duplicate source file name {",
- Location, Data);
+ (Data.Flags, "duplicate source file name {",
+ Location, Project);
Add_Src := False;
end if;
else
- if Project.Known_Order_Of_Source_Dirs then
+ if Source_Dir_Rank /= Source.Source_Dir_Rank then
Add_Src := False;
-- We might be seeing the same file through a different path
elsif Source.Path.Name /= Path.Name then
Error_Msg_Name_1 := Unit;
Error_Msg
- (Project, "duplicate unit %%", Location, Data);
+ (Data.Flags, "duplicate unit %%", Location, Project);
Add_Src := False;
end if;
end if;
- -- Do not allow the same unit name in different projects,
- -- except if one is extending the other.
+ -- Do not allow the same unit name in different projects, except
+ -- if one is extending the other.
- -- For a file based language, the same file name replaces
- -- a file in a project being extended, but it is allowed
- -- to have the same file name in unrelated projects.
+ -- For a file based language, the same file name replaces a file
+ -- in a project being extended, but it is allowed to have the same
+ -- file name in unrelated projects.
elsif Is_Extending (Project, Source.Project) then
- Source_To_Replace := Source;
+ if not Locally_Removed then
+ Source_To_Replace := Source;
+ end if;
elsif Prev_Unit /= No_Unit_Index
and then not Source.Locally_Removed
if Path /= No_Path_Information then
Error_Msg_Name_1 := Unit;
Error_Msg
- (Project,
+ (Data.Flags,
"unit %% cannot belong to several projects",
- Location, Data);
+ Location, Project);
Error_Msg_Name_1 := Project.Name;
- Error_Msg_Name_2 := Name_Id (Path.Name);
+ Error_Msg_Name_2 := Name_Id (Path.Display_Name);
Error_Msg
- (Project, "\ project %%, %%", Location, Data);
+ (Data.Flags, "\ project %%, %%", Location, Project);
Error_Msg_Name_1 := Source.Project.Name;
Error_Msg_Name_2 := Name_Id (Source.Path.Display_Name);
Error_Msg
- (Project, "\ project %%, %%", Location, Data);
+ (Data.Flags, "\ project %%, %%", Location, Project);
else
Error_Msg_Name_1 := Unit;
Error_Msg_Name_2 := Source.Project.Name;
Error_Msg
- (Project, "unit %% already belongs to project %%",
- Location, Data);
+ (Data.Flags, "unit %% already belongs to project %%",
+ Location, Project);
end if;
Add_Src := False;
Error_Msg_File_1 := File_Name;
Error_Msg_File_2 := File_Name_Type (Source.Project.Name);
Error_Msg
- (Project,
- "{ is already a source of project {", Location, Data);
+ (Data.Flags,
+ "{ is already a source of project {", Location, Project);
-- Add the file anyway, to avoid further warnings like "language
-- unknown".
end if;
Id.Project := Project;
+ Id.Source_Dir_Rank := Source_Dir_Rank;
Id.Language := Lang_Id;
Id.Kind := Kind;
Id.Alternate_Languages := Alternate_Languages;
+ Id.Locally_Removed := Locally_Removed;
+ Id.Index := Index;
+ Id.File := File_Name;
+ Id.Display_File := Display_File;
+ Id.Dep_Name := Dependency_Name
+ (File_Name, Lang_Id.Config.Dependency_Kind);
+ Id.Naming_Exception := Naming_Exception;
-- Add the source id to the Unit_Sources_HT hash table, if the unit name
-- is not null.
if Unit /= No_Name then
- Unit_Sources_Htable.Set (Data.Tree.Unit_Sources_HT, Unit, Id);
- -- ??? Record_Unit has already fetched that earlier, so this isn't
- -- the most efficient way. But we can't really pass a parameter since
- -- Process_Exceptions_Unit_Based and Check_File haven't looked it up.
+ -- Note: we might be creating a dummy unit here, when we in fact have
+ -- a separate. For instance, file file-bar.adb will initially be
+ -- assumed to be the IMPL of unit "file.bar". Only later on (in
+ -- Check_Object_Files) will we parse those units that only have an
+ -- impl and no spec to make sure whether we have a Separate in fact
+ -- (that significantly reduces the number of times we need to parse
+ -- the files, since we are then only interested in those with no
+ -- spec). We still need those dummy units in the table, since that's
+ -- the name we find in the ALI file
UData := Units_Htable.Get (Data.Tree.Units_HT, Unit);
Override_Kind (Id, Kind);
end if;
- Id.Index := Index;
- Id.File := File_Name;
- Id.Display_File := Display_File;
- Id.Dep_Name := Dependency_Name
- (File_Name, Lang_Id.Config.Dependency_Kind);
- Id.Naming_Exception := Naming_Exception;
-
if Is_Compilable (Id) and then Config.Object_Generated then
Id.Object := Object_Name (File_Name, Config.Object_File_Suffix);
Id.Switches := Switches_Name (File_Name);
Source_Paths_Htable.Set (Data.Tree.Source_Paths_HT, Path.Name, Id);
end if;
+ if Index /= 0 then
+ Project.Has_Multi_Unit_Sources := True;
+ end if;
+
-- Add the source to the language list
Id.Next_In_Lang := Lang_Id.First_Source;
Files_Htable.Set (Data.File_To_Source, File_Name, Id);
end Add_Source;
- -------------------
- -- ALI_File_Name --
- -------------------
-
- function ALI_File_Name (Source : String) return String is
- begin
- -- If the source name has extension, replace it with the ALI suffix
-
- for Index in reverse Source'First + 1 .. Source'Last loop
- if Source (Index) = '.' then
- return Source (Source'First .. Index - 1) & ALI_Suffix;
- end if;
- end loop;
-
- -- If no dot, or if it is the first character, just add the ALI suffix
-
- return Source & ALI_Suffix;
- end ALI_File_Name;
-
------------------------------
-- Canonical_Case_File_Name --
------------------------------
else
Error_Msg
- (Project,
+ (Data.Flags,
"at least one of Source_Files, Source_Dirs or Languages "
& "must be declared empty for an abstract project",
- Project.Location, Data);
+ Project.Location, Project);
end if;
end;
end if;
- -- Check configuration in multi language mode
+ -- Check configuration. This must be done even for gnatmake (even though
+ -- no user configuration file was provided) since the default config we
+ -- generate indicates whether libraries are supported for instance.
- if Must_Check_Configuration then
- Check_Configuration (Project, Data);
- end if;
+ Check_Configuration (Project, Data);
-- Library attributes
-- are sources for which this is an alternate language.
if Language.First_Source = No_Source
- and then
- (Data.Flags.Require_Sources_Other_Lang
- or else Language.Name = Name_Ada)
+ and then (Data.Flags.Require_Sources_Other_Lang
+ or else Language.Name = Name_Ada)
then
Iter := For_Each_Source (In_Tree => Data.Tree,
Project => Project);
-- If it is a library project file, check if it is a standalone library
if Project.Library then
- Check_Stand_Alone_Library (Project, Extending, Data);
+ Check_Stand_Alone_Library (Project, Data);
end if;
-- Put the list of Mains, if any, in the project data
if List = Nil_String then
Error_Msg
- (Project, "include option cannot be null",
- Element.Value.Location, Data);
+ (Data.Flags, "include option cannot be null",
+ Element.Value.Location, Project);
end if;
Put (Into_List => Lang_Index.Config.Include_Option,
From_List => Element.Value.Values,
In_Tree => Data.Tree);
+ when Name_Multi_Unit_Switches =>
+ Put (Into_List =>
+ Lang_Index.Config.Multi_Unit_Switches,
+ From_List => Element.Value.Values,
+ In_Tree => Data.Tree);
+
+ when Name_Multi_Unit_Object_Separator =>
+ Get_Name_String (Element.Value.Value);
+
+ if Name_Len /= 1 then
+ Error_Msg
+ (Data.Flags,
+ "multi-unit object separator must have " &
+ "a single character",
+ Element.Value.Location, Project);
+
+ elsif Name_Buffer (1) = ' ' then
+ Error_Msg
+ (Data.Flags,
+ "multi-unit object separator cannot be " &
+ "a space",
+ Element.Value.Location, Project);
+
+ else
+ Lang_Index.Config.Multi_Unit_Object_Separator :=
+ Name_Buffer (1);
+ end if;
+
when Name_Path_Syntax =>
begin
Lang_Index.Config.Path_Syntax :=
exception
when Constraint_Error =>
Error_Msg
- (Project, "invalid value for Path_Syntax",
- Element.Value.Location, Data);
+ (Data.Flags,
+ "invalid value for Path_Syntax",
+ Element.Value.Location, Project);
end;
when Name_Object_File_Suffix =>
if Get_Name_String (Element.Value.Value) = "" then
Error_Msg
- (Project, "object file suffix cannot be empty",
- Element.Value.Location, Data);
+ (Data.Flags,
+ "object file suffix cannot be empty",
+ Element.Value.Location, Project);
else
Lang_Index.Config.Object_File_Suffix :=
if List = Nil_String then
Error_Msg
- (Project, "compiler PIC option cannot be null",
- Element.Value.Location, Data);
+ (Data.Flags,
+ "compiler PIC option cannot be null",
+ Element.Value.Location, Project);
end if;
Put (Into_List =>
if List = Nil_String then
Error_Msg
- (Project,
+ (Data.Flags,
"mapping file switches cannot be null",
- Element.Value.Location, Data);
+ Element.Value.Location, Project);
end if;
Put (Into_List =>
if List = Nil_String then
Error_Msg
- (Project,
+ (Data.Flags,
"config file switches cannot be null",
- Element.Value.Location, Data);
+ Element.Value.Location, Project);
end if;
Put (Into_List =>
Lang_Index.Config.Config_Body :=
Element.Value.Value;
+ when Name_Config_Body_File_Name_Index =>
+
+ -- Attribute Config_Body_File_Name_Index
+ -- ( < Language > )
+
+ Lang_Index.Config.Config_Body_Index :=
+ Element.Value.Value;
+
when Name_Config_Body_File_Name_Pattern =>
-- Attribute Config_Body_File_Name_Pattern
- -- (<language>)
+ -- (<language>)
Lang_Index.Config.Config_Body_Pattern :=
Element.Value.Value;
Lang_Index.Config.Config_Spec :=
Element.Value.Value;
+ when Name_Config_Spec_File_Name_Index =>
+
+ -- Attribute Config_Spec_File_Name_Index
+ -- ( < Language > )
+
+ Lang_Index.Config.Config_Spec_Index :=
+ Element.Value.Value;
+
when Name_Config_Spec_File_Name_Pattern =>
-- Attribute Config_Spec_File_Name_Pattern
- -- (<language>)
+ -- (<language>)
Lang_Index.Config.Config_Spec_Pattern :=
Element.Value.Value;
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"illegal value for Config_File_Unique",
- Element.Value.Location, Data);
+ Element.Value.Location, Project);
end;
when others =>
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value for Casing",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end;
elsif Attribute.Name = Name_Dot_Replacement then
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"value must be positive or equal to 0",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end;
elsif Attribute.Name = Name_Response_File_Format then
else
Error_Msg
- (Project,
+ (Data.Flags,
"illegal response file format",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end if;
end;
if List = Nil_String then
Error_Msg
- (Project,
+ (Data.Flags,
"archive builder cannot be null",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end if;
Put (Into_List => Project.Config.Archive_Builder,
if List = Nil_String then
Error_Msg
- (Project,
+ (Data.Flags,
"archive indexer cannot be null",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end if;
Put (Into_List => Project.Config.Archive_Indexer,
if List = Nil_String then
Error_Msg
- (Project,
+ (Data.Flags,
"partial linker cannot be null",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end if;
Put (Into_List => Project.Config.Lib_Partial_Linker,
Project.Config.Shared_Lib_Driver :=
File_Name_Type (Attribute.Value.Value);
Error_Msg
- (Project,
+ (Data.Flags,
"?Library_'G'C'C is an obsolescent attribute, " &
"use Linker''Driver instead",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
elsif Attribute.Name = Name_Archive_Suffix then
Project.Config.Archive_Suffix :=
if List = Nil_String then
Error_Msg
- (Project,
+ (Data.Flags,
"linker executable option cannot be null",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end if;
Put (Into_List => Project.Config.Linker_Executable_Option,
if Name_Len = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"linker library directory option cannot be empty",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end if;
Project.Config.Linker_Lib_Dir_Option :=
if Name_Len = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"linker library name option cannot be empty",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end if;
Project.Config.Linker_Lib_Name_Option :=
In_Tree => Data.Tree);
end if;
+ elsif Attribute.Name = Name_Run_Path_Origin then
+ Get_Name_String (Attribute.Value.Value);
+
+ if Name_Len = 0 then
+ Error_Msg
+ (Data.Flags,
+ "run path origin cannot be empty",
+ Attribute.Value.Location, Project);
+ end if;
+
+ Project.Config.Run_Path_Origin := Attribute.Value.Value;
+
+ elsif Attribute.Name = Name_Library_Install_Name_Option then
+ Project.Config.Library_Install_Name_Option :=
+ Attribute.Value.Value;
+
elsif Attribute.Name = Name_Separate_Run_Path_Options then
declare
pragma Unsuppress (All_Checks);
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value """ &
Get_Name_String (Attribute.Value.Value) &
""" for Separate_Run_Path_Options",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end;
elsif Attribute.Name = Name_Library_Support then
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value """ &
Get_Name_String (Attribute.Value.Value) &
""" for Library_Support",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end;
elsif Attribute.Name = Name_Shared_Library_Prefix then
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value """
& Get_Name_String (Attribute.Value.Value)
& """ for Symbolic_Link_Supported",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end;
elsif
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value """ &
Get_Name_String (Attribute.Value.Value) &
""" for Library_Major_Minor_Id_Supported",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end;
elsif Attribute.Name = Name_Library_Auto_Init_Supported then
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value """
& Get_Name_String (Attribute.Value.Value)
& """ for Library_Auto_Init_Supported",
- Attribute.Value.Location, Data);
+ Attribute.Value.Location, Project);
end;
elsif Attribute.Name = Name_Shared_Library_Minimum_Switches then
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value """
& Get_Name_String (Element.Value.Value)
& """ for Object_Generated",
- Element.Value.Location, Data);
+ Element.Value.Location, Project);
end;
when Name_Objects_Linked =>
exception
when Constraint_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value """
& Get_Name_String (Element.Value.Value)
& """ for Objects_Linked",
- Element.Value.Location, Data);
+ Element.Value.Location, Project);
end;
when others =>
null;
then
Error_Msg_Name_1 := Lang_Index.Display_Name;
Error_Msg
- (Project,
+ (Data.Flags,
"?no compiler specified for language %%" &
", ignoring all its sources",
- No_Location, Data);
+ No_Location, Project);
if Lang_Index = Project.Languages then
Project.Languages := Lang_Index.Next;
if Lang_Index.Config.Naming_Data.Dot_Replacement = No_File then
Error_Msg
- (Project,
+ (Data.Flags,
"Dot_Replacement not specified for Ada",
- No_Location, Data);
+ No_Location, Project);
end if;
if Lang_Index.Config.Naming_Data.Spec_Suffix = No_File then
Error_Msg
- (Project,
+ (Data.Flags,
"Spec_Suffix not specified for Ada",
- No_Location, Data);
+ No_Location, Project);
end if;
if Lang_Index.Config.Naming_Data.Body_Suffix = No_File then
Error_Msg
- (Project,
+ (Data.Flags,
"Body_Suffix not specified for Ada",
- No_Location, Data);
+ No_Location, Project);
end if;
else
-- For file based languages, either Spec_Suffix or Body_Suffix
-- need to be specified.
- if Lang_Index.Config.Naming_Data.Spec_Suffix = No_File and then
- Lang_Index.Config.Naming_Data.Body_Suffix = No_File
+ if Data.Flags.Require_Sources_Other_Lang
+ and then Lang_Index.Config.Naming_Data.Spec_Suffix = No_File
+ and then Lang_Index.Config.Naming_Data.Body_Suffix = No_File
then
Error_Msg_Name_1 := Lang_Index.Display_Name;
Error_Msg
- (Project,
+ (Data.Flags,
"no suffixes specified for %%",
- No_Location, Data);
+ No_Location, Project);
end if;
end if;
Project.Externally_Built := True;
elsif Name_Buffer (1 .. Name_Len) /= "false" then
- Error_Msg (Project,
+ Error_Msg (Data.Flags,
"Externally_Built may only be true or false",
- Externally_Built.Location, Data);
+ Externally_Built.Location, Project);
end if;
end if;
Project.Decl.Attributes,
Data.Tree);
+ Library_Interface : constant Prj.Variable_Value :=
+ Prj.Util.Value_Of
+ (Snames.Name_Library_Interface,
+ Project.Decl.Attributes,
+ Data.Tree);
+
List : String_List_Id;
Element : String_Element;
Name : File_Name_Type;
Error_Msg_Name_1 := Project.Name;
Error_Msg
- (Project,
+ (Data.Flags,
"{ cannot be an interface of project %% "
& "as it is not one of its sources",
- Element.Location, Data);
+ Element.Location, Project);
end if;
List := Element.Next;
Project.Interfaces_Defined := True;
- elsif Project.Extends /= No_Project then
- Project.Interfaces_Defined := Project.Extends.Interfaces_Defined;
+ elsif Project.Library and then not Library_Interface.Default then
+
+ -- Set In_Interfaces to False for all sources. It will be set to True
+ -- later for the sources in the Library_Interface list.
- if Project.Interfaces_Defined then
- Iter := For_Each_Source (Data.Tree, Project);
+ Project_2 := Project;
+ while Project_2 /= No_Project loop
+ Iter := For_Each_Source (Data.Tree, Project_2);
loop
Source := Prj.Element (Iter);
exit when Source = No_Source;
-
- if not Source.Declared_In_Interfaces then
- Source.In_Interfaces := False;
- end if;
-
+ Source.In_Interfaces := False;
Next (Iter);
end loop;
- end if;
+
+ Project_2 := Project_2.Extends;
+ end loop;
+
+ List := Library_Interface.Values;
+ while List /= Nil_String loop
+ Element := Data.Tree.String_Elements.Table (List);
+ Get_Name_String (Element.Value);
+ To_Lower (Name_Buffer (1 .. Name_Len));
+ Name := Name_Find;
+
+ Project_2 := Project;
+ Big_Loop_2 :
+ while Project_2 /= No_Project loop
+ Iter := For_Each_Source (Data.Tree, Project_2);
+
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
+
+ if Source.Unit /= No_Unit_Index and then
+ Source.Unit.Name = Name_Id (Name)
+ then
+ if not Source.Locally_Removed then
+ Source.In_Interfaces := True;
+ Source.Declared_In_Interfaces := True;
+
+ Other := Other_Part (Source);
+
+ if Other /= No_Source then
+ Other.In_Interfaces := True;
+ Other.Declared_In_Interfaces := True;
+ end if;
+
+ if Current_Verbosity = High then
+ Write_Str (" interface: ");
+ Write_Line (Get_Name_String (Source.Path.Name));
+ end if;
+ end if;
+
+ exit Big_Loop_2;
+ end if;
+
+ Next (Iter);
+ end loop;
+
+ Project_2 := Project_2.Extends;
+ end loop Big_Loop_2;
+
+ List := Element.Next;
+ end loop;
+
+ Project.Interfaces_Defined := True;
+
+ elsif Project.Extends /= No_Project
+ and then Project.Extends.Interfaces_Defined
+ then
+ Project.Interfaces_Defined := True;
+
+ Iter := For_Each_Source (Data.Tree, Project);
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
+
+ if not Source.Declared_In_Interfaces then
+ Source.In_Interfaces := False;
+ end if;
+
+ Next (Iter);
+ end loop;
end if;
end Check_Interfaces;
--------------------------
procedure Check_Package_Naming
- (Project : Project_Id;
- Data : in out Tree_Processing_Data;
- Bodies : out Array_Element_Id;
- Specs : out Array_Element_Id)
+ (Project : Project_Id;
+ Data : in out Tree_Processing_Data;
+ Bodies : out Array_Element_Id;
+ Specs : out Array_Element_Id)
is
Naming_Id : constant Package_Id :=
Util.Value_Of
if Length_Of_Name (Dot_Repl.Value) = 0 then
Error_Msg
- (Project, "Dot_Replacement cannot be empty",
- Dot_Repl.Location, Data);
+ (Data.Flags, "Dot_Replacement cannot be empty",
+ Dot_Repl.Location, Project);
end if;
Dot_Replacement := Canonical_Case_File_Name (Dot_Repl.Value);
Index (Source => Repl, Pattern => ".") /= 0)
then
Error_Msg
- (Project,
+ (Data.Flags,
'"' & Repl &
""" is illegal for Dot_Replacement.",
- Dot_Repl_Loc, Data);
+ Dot_Repl_Loc, Project);
end if;
end;
end if;
begin
if Casing_Image'Length = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"Casing cannot be an empty string",
- Casing_String.Location, Data);
+ Casing_String.Location, Project);
end if;
Casing := Value (Casing_Image);
Name_Buffer (1 .. Name_Len) := Casing_Image;
Err_Vars.Error_Msg_Name_1 := Name_Find;
Error_Msg
- (Project,
+ (Data.Flags,
"%% is not a correct Casing",
- Casing_String.Location, Data);
+ Casing_String.Location, Project);
end;
end if;
if not Sep_Suffix.Default then
if Length_Of_Name (Sep_Suffix.Value) = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"Separate_Suffix cannot be empty",
- Sep_Suffix.Location, Data);
+ Sep_Suffix.Location, Project);
else
Separate_Suffix := Canonical_Case_File_Name (Sep_Suffix.Value);
(Id => Source,
Data => Data,
Project => Project,
+ Source_Dir_Rank => 0,
Lang_Id => Lang_Id,
Kind => Kind,
File_Name => File_Name,
if Source.Language /= Lang_Id then
Error_Msg
- (Project,
+ (Data.Flags,
"the same file cannot be a source of two languages",
- Element.Location, Data);
+ Element.Location, Project);
elsif Source.Kind /= Kind then
Error_Msg
- (Project,
+ (Data.Flags,
"the same file cannot be a source and a template",
- Element.Location, Data);
+ Element.Location, Project);
end if;
-- If the file is already recorded for the same
if Unit = No_Name then
Err_Vars.Error_Msg_Name_1 := Element.Index;
Error_Msg
- (Project,
+ (Data.Flags,
"%% is not a valid unit name.",
- Element.Value.Location, Data);
+ Element.Value.Location, Project);
end if;
end if;
if Unit /= No_Name then
Add_Source
- (Id => Source,
- Data => Data,
- Project => Project,
- Lang_Id => Lang_Id,
- Kind => Kind,
- File_Name => File_Name,
- Display_File => File_Name_Type (Element.Value.Value),
- Unit => Unit,
- Index => Index,
- Location => Element.Value.Location,
+ (Id => Source,
+ Data => Data,
+ Project => Project,
+ Source_Dir_Rank => 0,
+ Lang_Id => Lang_Id,
+ Kind => Kind,
+ File_Name => File_Name,
+ Display_File => File_Name_Type (Element.Value.Value),
+ Unit => Unit,
+ Index => Index,
+ Location => Element.Value.Location,
Naming_Exception => True);
end if;
Lang_Id.Config.Naming_Data.Body_Suffix
then
Error_Msg
- (Project,
+ (Data.Flags,
"Body_Suffix ("""
& Get_Name_String (Lang_Id.Config.Naming_Data.Body_Suffix)
& """) cannot be the same as Spec_Suffix.",
- Ada_Body_Suffix_Loc, Data);
+ Ada_Body_Suffix_Loc, Project);
end if;
if Lang_Id.Config.Naming_Data.Body_Suffix /=
Lang_Id.Config.Naming_Data.Separate_Suffix
then
Error_Msg
- (Project,
+ (Data.Flags,
"Separate_Suffix ("""
& Get_Name_String
(Lang_Id.Config.Naming_Data.Separate_Suffix)
& """) cannot be the same as Spec_Suffix.",
- Sep_Suffix_Loc, Data);
+ Sep_Suffix_Loc, Project);
end if;
Lang_Id := Lang_Id.Next;
-- No Naming package or parsing a configuration file? nothing to do
if Naming_Id /= No_Package
- and Project.Qualifier /= Configuration
+ and then Project.Qualifier /= Configuration
then
Naming := Data.Tree.Packages.Table (Naming_Id);
if Extends then
if Project.Library_Kind /= Static then
Error_Msg
- (Project,
+ (Data.Flags,
Continuation.all &
"shared library project %% cannot extend " &
"project %% that is not a library project",
- Project.Location, Data);
+ Project.Location, Project);
Continuation := Continuation_String'Access;
end if;
and then Project.Library_Kind /= Static
then
Error_Msg
- (Project,
+ (Data.Flags,
Continuation.all &
"shared library project %% cannot import project %% " &
"that is not a shared library project",
- Project.Location, Data);
+ Project.Location, Project);
Continuation := Continuation_String'Access;
end if;
end if;
if Extends then
Error_Msg
- (Project,
+ (Data.Flags,
Continuation.all &
"shared library project %% cannot extend static " &
"library project %%",
- Project.Location, Data);
+ Project.Location, Project);
Continuation := Continuation_String'Access;
elsif not Unchecked_Shared_Lib_Imports then
Error_Msg
- (Project,
+ (Data.Flags,
Continuation.all &
"shared library project %% cannot import static " &
"library project %%",
- Project.Location, Data);
+ Project.Location, Project);
Continuation := Continuation_String'Access;
end if;
if Project.Extends.Library then
if Project.Qualifier = Standard then
Error_Msg
- (Project,
+ (Data.Flags,
"a standard project cannot extend a library project",
- Project.Location, Data);
+ Project.Location, Project);
else
if Lib_Name.Default then
if Lib_Dir.Default then
if not Project.Virtual then
Error_Msg
- (Project,
+ (Data.Flags,
"a project extending a library project must " &
"specify an attribute Library_Dir",
- Project.Location, Data);
+ Project.Location, Project);
else
-- For a virtual project extending a library project,
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Project.Library_Dir.Display_Name);
Error_Msg
- (Project,
+ (Data.Flags,
"library directory { does not exist",
- Lib_Dir.Location, Data);
+ Lib_Dir.Location, Project);
-- The library directory cannot be the same as the Object
-- directory.
elsif Project.Library_Dir.Name = Project.Object_Directory.Name then
Error_Msg
- (Project,
+ (Data.Flags,
"library directory cannot be the same " &
"as object directory",
- Lib_Dir.Location, Data);
+ Lib_Dir.Location, Project);
Project.Library_Dir := No_Path_Information;
else
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Dir_Elem.Value);
Error_Msg
- (Project,
+ (Data.Flags,
"library directory cannot be the same " &
"as source directory {",
- Lib_Dir.Location, Data);
+ Lib_Dir.Location, Project);
OK := False;
exit;
end if;
Err_Vars.Error_Msg_Name_1 := Pid.Project.Name;
Error_Msg
- (Project,
+ (Data.Flags,
"library directory cannot be the same " &
"as source directory { of project %%",
- Lib_Dir.Location, Data);
+ Lib_Dir.Location, Project);
OK := False;
exit Project_Loop;
end if;
when Standard =>
if Project.Library then
Error_Msg
- (Project,
+ (Data.Flags,
"a standard project cannot be a library project",
- Lib_Name.Location, Data);
+ Lib_Name.Location, Project);
end if;
when Library =>
if not Project.Library then
if Project.Library_Dir = No_Path_Information then
Error_Msg
- (Project,
+ (Data.Flags,
"\attribute Library_Dir not declared",
- Project.Location, Data);
+ Project.Location, Project);
end if;
if Project.Library_Name = No_Name then
Error_Msg
- (Project,
+ (Data.Flags,
"\attribute Library_Name not declared",
- Project.Location, Data);
+ Project.Location, Project);
end if;
end if;
end if;
if Project.Library then
- if Get_Mode = Multi_Language then
- Support_For_Libraries := Project.Config.Lib_Support;
-
- else
- Support_For_Libraries := MLib.Tgt.Support_For_Libraries;
- end if;
+ Support_For_Libraries := Project.Config.Lib_Support;
if Support_For_Libraries = Prj.None then
Error_Msg
- (Project,
+ (Data.Flags,
"?libraries are not supported on this platform",
- Lib_Name.Location, Data);
+ Lib_Name.Location, Project);
Project.Library := False;
else
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Project.Library_ALI_Dir.Display_Name);
Error_Msg
- (Project,
+ (Data.Flags,
"library 'A'L'I directory { does not exist",
- Lib_ALI_Dir.Location, Data);
+ Lib_ALI_Dir.Location, Project);
end if;
if Project.Library_ALI_Dir /= Project.Library_Dir then
if Project.Library_ALI_Dir = Project.Object_Directory then
Error_Msg
- (Project,
+ (Data.Flags,
"library 'A'L'I directory cannot be the same " &
"as object directory",
- Lib_ALI_Dir.Location, Data);
+ Lib_ALI_Dir.Location, Project);
Project.Library_ALI_Dir := No_Path_Information;
else
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Dir_Elem.Value);
Error_Msg
- (Project,
+ (Data.Flags,
"library 'A'L'I directory cannot be " &
"the same as source directory {",
- Lib_ALI_Dir.Location, Data);
+ Lib_ALI_Dir.Location, Project);
OK := False;
exit;
end if;
Pid.Project.Name;
Error_Msg
- (Project,
+ (Data.Flags,
"library 'A'L'I directory cannot " &
"be the same as source directory " &
"{ of project %%",
- Lib_ALI_Dir.Location, Data);
+ Lib_ALI_Dir.Location, Project);
OK := False;
exit ALI_Project_Loop;
end if;
else
Error_Msg
- (Project,
+ (Data.Flags,
"illegal value for Library_Kind",
- The_Lib_Kind.Location, Data);
+ The_Lib_Kind.Location, Project);
OK := False;
end if;
if Project.Library_Kind /= Static then
if Support_For_Libraries = Prj.Static_Only then
Error_Msg
- (Project,
+ (Data.Flags,
"only static libraries are supported " &
"on this platform",
- The_Lib_Kind.Location, Data);
+ The_Lib_Kind.Location, Project);
Project.Library := False;
else
if Lib_GCC.Value /= Empty_String then
Error_Msg
- (Project,
+ (Data.Flags,
"?Library_'G'C'C is an obsolescent attribute, " &
"use Linker''Driver instead",
- Lib_GCC.Location, Data);
+ Lib_GCC.Location, Project);
Project.Config.Shared_Lib_Driver :=
File_Name_Type (Lib_GCC.Value);
if Switches /= No_Array_Element then
Error_Msg
- (Project,
+ (Data.Flags,
"?Linker switches not taken into account in library " &
"projects",
- No_Location, Data);
+ No_Location, Project);
end if;
end if;
end;
Lang.Display_Name := Display_Name;
if Name = Name_Ada then
- Lang.Config.Kind := Unit_Based;
+ Lang.Config.Kind := Unit_Based;
Lang.Config.Dependency_Kind := ALI_File;
-
- if Get_Mode = Ada_Only then
-
- -- Create a default config for Ada (since there is no
- -- configuration file to create it for us).
-
- -- ??? We should do as GPS does and create a dummy config file
-
- Lang.Config.Naming_Data :=
- (Dot_Replacement =>
- File_Name_Type
- (First_Name_Id + Character'Pos ('-')),
- Casing => All_Lower_Case,
- Separate_Suffix => Default_Ada_Body_Suffix,
- Spec_Suffix => Default_Ada_Spec_Suffix,
- Body_Suffix => Default_Ada_Body_Suffix);
- end if;
-
else
Lang.Config.Kind := File_Based;
end if;
Prj.Util.Value_Of
(Name_Default_Language, Project.Decl.Attributes, Data.Tree);
- -- Shouldn't these be set to False by default, and only set to True when
- -- we actually find some source file???
-
if Project.Source_Dirs /= Nil_String then
-- Check if languages are specified in this project
if Languages.Default then
- -- In Ada_Only mode, the default language is Ada
+ -- Fail if there is no default language defined
- if Get_Mode = Ada_Only then
- Def_Lang_Id := Name_Ada;
+ if Def_Lang.Default then
+ Error_Msg
+ (Data.Flags,
+ "no languages defined for this project",
+ Project.Location, Project);
+ Def_Lang_Id := No_Name;
else
- -- Fail if there is no default language defined
-
- if Def_Lang.Default then
- if not Default_Language_Is_Ada then
- Error_Msg
- (Project,
- "no languages defined for this project",
- Project.Location, Data);
- Def_Lang_Id := No_Name;
-
- else
- Def_Lang_Id := Name_Ada;
- end if;
-
- else
- Get_Name_String (Def_Lang.Value);
- To_Lower (Name_Buffer (1 .. Name_Len));
- Def_Lang_Id := Name_Find;
- end if;
+ Get_Name_String (Def_Lang.Value);
+ To_Lower (Name_Buffer (1 .. Name_Len));
+ Def_Lang_Id := Name_Find;
end if;
if Def_Lang_Id /= No_Name then
if Project.Qualifier = Standard then
Error_Msg
- (Project,
+ (Data.Flags,
"a standard project must have at least one language",
- Languages.Location, Data);
+ Languages.Location, Project);
end if;
else
end if;
end Check_Programming_Languages;
- -------------------
- -- Check_Project --
- -------------------
-
- function Check_Project
- (P : Project_Id;
- Root_Project : Project_Id;
- Extending : Boolean) return Boolean
- is
- Prj : Project_Id;
-
- begin
- if P = Root_Project then
- return True;
-
- elsif Extending then
- Prj := Root_Project;
- while Prj.Extends /= No_Project loop
- if P = Prj.Extends then
- return True;
- end if;
-
- Prj := Prj.Extends;
- end loop;
- end if;
-
- return False;
- end Check_Project;
-
-------------------------------
-- Check_Stand_Alone_Library --
-------------------------------
procedure Check_Stand_Alone_Library
- (Project : Project_Id;
- Extending : Boolean;
- Data : in out Tree_Processing_Data)
+ (Project : Project_Id;
+ Data : in out Tree_Processing_Data)
is
Lib_Interfaces : constant Prj.Variable_Value :=
Prj.Util.Value_Of
Iter : Source_Iterator;
begin
- if Get_Mode = Multi_Language then
- Auto_Init_Supported := Project.Config.Auto_Init_Supported;
- else
- Auto_Init_Supported :=
- MLib.Tgt.Standalone_Library_Auto_Init_Is_Supported;
- end if;
+ Auto_Init_Supported := Project.Config.Auto_Init_Supported;
pragma Assert (Lib_Interfaces.Kind = List);
-- Library_Interface is defined.
if not Lib_Interfaces.Default then
- SAL_Library : declare
+ declare
Interfaces : String_List_Id := Lib_Interfaces.Values;
Interface_ALIs : String_List_Id := Nil_String;
Unit : Name_Id;
- UData : Unit_Index;
-
- procedure Add_ALI_For (Source : File_Name_Type);
- -- Add an ALI file name to the list of Interface ALIs
-
- -----------------
- -- Add_ALI_For --
- -----------------
-
- procedure Add_ALI_For (Source : File_Name_Type) is
- begin
- Get_Name_String (Source);
-
- declare
- ALI : constant String :=
- ALI_File_Name (Name_Buffer (1 .. Name_Len));
- ALI_Name_Id : Name_Id;
-
- begin
- Name_Len := ALI'Length;
- Name_Buffer (1 .. Name_Len) := ALI;
- ALI_Name_Id := Name_Find;
-
- String_Element_Table.Increment_Last
- (Data.Tree.String_Elements);
-
- Data.Tree.String_Elements.Table
- (String_Element_Table.Last
- (Data.Tree.String_Elements)) :=
- (Value => ALI_Name_Id,
- Index => 0,
- Display_Value => ALI_Name_Id,
- Location =>
- Data.Tree.String_Elements.Table
- (Interfaces).Location,
- Flag => False,
- Next => Interface_ALIs);
-
- Interface_ALIs :=
- String_Element_Table.Last
- (Data.Tree.String_Elements);
- end;
- end Add_ALI_For;
-
- -- Start of processing for SAL_Library
begin
Project.Standalone_Library := True;
if Interfaces = Nil_String then
Error_Msg
- (Project,
+ (Data.Flags,
"Library_Interface cannot be an empty list",
- Lib_Interfaces.Location, Data);
+ Lib_Interfaces.Location, Project);
end if;
-- Process each unit name specified in the attribute
if Name_Len = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"an interface cannot be an empty string",
Data.Tree.String_Elements.Table (Interfaces).Location,
- Data);
+ Project);
else
Unit := Name_Find;
Error_Msg_Name_1 := Unit;
- if Get_Mode = Ada_Only then
- UData := Units_Htable.Get (Data.Tree.Units_HT, Unit);
-
- -- Check that the unit is part of the project
-
- if UData /= null
- and then UData.File_Names (Impl) /= null
- and then not UData.File_Names (Impl).Locally_Removed
- then
- if Check_Project
- (UData.File_Names (Impl).Project,
- Project, Extending)
- then
- -- There is a body for this unit. If there is
- -- no spec, we need to check that it is not a
- -- subunit.
-
- if UData.File_Names (Spec) = null then
- declare
- Src_Ind : Source_File_Index;
-
- begin
- Src_Ind :=
- Sinput.P.Load_Project_File
- (Get_Name_String (UData.File_Names
- (Impl).Path.Name));
-
- if Sinput.P.Source_File_Is_Subunit
- (Src_Ind)
- then
- Error_Msg
- (Project,
- "%% is a subunit; " &
- "it cannot be an interface",
- Data.Tree.
- String_Elements.Table
- (Interfaces).Location,
- Data);
- end if;
- end;
- end if;
-
- -- The unit is not a subunit, so we add the
- -- ALI file for its body to the Interface ALIs.
-
- Add_ALI_For
- (UData.File_Names (Impl).File);
-
- else
- Error_Msg
- (Project,
- "%% is not an unit of this project",
- Data.Tree.String_Elements.Table
- (Interfaces).Location, Data);
- end if;
-
- elsif UData /= null
- and then UData.File_Names (Spec) /= null
- and then not UData.File_Names (Spec).Locally_Removed
- and then Check_Project
- (UData.File_Names (Spec).Project,
- Project, Extending)
-
- then
- -- The unit is part of the project, it has a spec,
- -- but no body. We add the ALI for its spec to the
- -- Interface ALIs.
-
- Add_ALI_For
- (UData.File_Names (Spec).File);
-
- else
- Error_Msg
- (Project,
- "%% is not an unit of this project",
- Data.Tree.String_Elements.Table
- (Interfaces).Location, Data);
- end if;
-
- else
- Next_Proj := Project.Extends;
- Iter := For_Each_Source (Data.Tree, Project);
+ Next_Proj := Project.Extends;
+ Iter := For_Each_Source (Data.Tree, Project);
+ loop
+ while Prj.Element (Iter) /= No_Source
+ and then
+ (Prj.Element (Iter).Unit = null
+ or else Prj.Element (Iter).Unit.Name /= Unit)
loop
- while Prj.Element (Iter) /= No_Source
- and then
- (Prj.Element (Iter).Unit = null
- or else Prj.Element (Iter).Unit.Name /= Unit)
- loop
- Next (Iter);
- end loop;
+ Next (Iter);
+ end loop;
- Source := Prj.Element (Iter);
- exit when Source /= No_Source
- or else Next_Proj = No_Project;
+ Source := Prj.Element (Iter);
+ exit when Source /= No_Source
+ or else Next_Proj = No_Project;
- Iter := For_Each_Source (Data.Tree, Next_Proj);
- Next_Proj := Next_Proj.Extends;
- end loop;
+ Iter := For_Each_Source (Data.Tree, Next_Proj);
+ Next_Proj := Next_Proj.Extends;
+ end loop;
- if Source /= No_Source then
- if Source.Kind = Sep then
- Source := No_Source;
+ if Source /= No_Source then
+ if Source.Kind = Sep then
+ Source := No_Source;
- elsif Source.Kind = Spec
- and then Other_Part (Source) /= No_Source
- then
- Source := Other_Part (Source);
- end if;
+ elsif Source.Kind = Spec
+ and then Other_Part (Source) /= No_Source
+ then
+ Source := Other_Part (Source);
end if;
+ end if;
- if Source /= No_Source then
- if Source.Project /= Project
- and then not Is_Extending (Project, Source.Project)
- then
- Source := No_Source;
- end if;
+ if Source /= No_Source then
+ if Source.Project /= Project
+ and then not Is_Extending (Project, Source.Project)
+ then
+ Source := No_Source;
end if;
+ end if;
- if Source = No_Source then
- Error_Msg
- (Project,
- "%% is not an unit of this project",
- Data.Tree.String_Elements.Table
- (Interfaces).Location, Data);
-
- else
- if Source.Kind = Spec
- and then Other_Part (Source) /= No_Source
- then
- Source := Other_Part (Source);
- end if;
-
- String_Element_Table.Increment_Last
- (Data.Tree.String_Elements);
-
+ if Source = No_Source then
+ Error_Msg
+ (Data.Flags,
+ "%% is not a unit of this project",
Data.Tree.String_Elements.Table
- (String_Element_Table.Last
- (Data.Tree.String_Elements)) :=
- (Value => Name_Id (Source.Dep_Name),
- Index => 0,
- Display_Value => Name_Id (Source.Dep_Name),
- Location =>
- Data.Tree.String_Elements.Table
- (Interfaces).Location,
- Flag => False,
- Next => Interface_ALIs);
-
- Interface_ALIs :=
- String_Element_Table.Last
- (Data.Tree.String_Elements);
+ (Interfaces).Location, Project);
+
+ else
+ if Source.Kind = Spec
+ and then Other_Part (Source) /= No_Source
+ then
+ Source := Other_Part (Source);
end if;
+ String_Element_Table.Increment_Last
+ (Data.Tree.String_Elements);
+
+ Data.Tree.String_Elements.Table
+ (String_Element_Table.Last
+ (Data.Tree.String_Elements)) :=
+ (Value => Name_Id (Source.Dep_Name),
+ Index => 0,
+ Display_Value => Name_Id (Source.Dep_Name),
+ Location =>
+ Data.Tree.String_Elements.Table
+ (Interfaces).Location,
+ Flag => False,
+ Next => Interface_ALIs);
+
+ Interface_ALIs :=
+ String_Element_Table.Last
+ (Data.Tree.String_Elements);
end if;
-
end if;
- Interfaces :=
- Data.Tree.String_Elements.Table (Interfaces).Next;
+ Interfaces := Data.Tree.String_Elements.Table (Interfaces).Next;
end loop;
-- Put the list of Interface ALIs in the project data
-- supported.
Error_Msg
- (Project,
+ (Data.Flags,
"library auto init not supported " &
"on this platform",
- Lib_Auto_Init.Location, Data);
+ Lib_Auto_Init.Location, Project);
end if;
else
Error_Msg
- (Project,
+ (Data.Flags,
"invalid value for attribute Library_Auto_Init",
- Lib_Auto_Init.Location, Data);
+ Lib_Auto_Init.Location, Project);
end if;
end if;
- end SAL_Library;
+ end;
-- If attribute Library_Src_Dir is defined and not the empty string,
-- check if the directory exist and is not the object directory or
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Project.Library_Src_Dir.Display_Name);
Error_Msg
- (Project,
+ (Data.Flags,
"Directory { does not exist",
- Lib_Src_Dir.Location, Data);
+ Lib_Src_Dir.Location, Project);
-- Report error if it is the same as the object directory
elsif Project.Library_Src_Dir = Project.Object_Directory then
Error_Msg
- (Project,
+ (Data.Flags,
"directory to copy interfaces cannot be " &
"the object directory",
- Lib_Src_Dir.Location, Data);
+ Lib_Src_Dir.Location, Project);
Project.Library_Src_Dir := No_Path_Information;
else
-- Report error if it is one of the source directories
if Project.Library_Src_Dir.Name =
- Path_Name_Type (Src_Dir.Value)
+ Path_Name_Type (Src_Dir.Value)
then
Error_Msg
- (Project,
+ (Data.Flags,
"directory to copy interfaces cannot " &
"be one of the source directories",
- Lib_Src_Dir.Location, Data);
+ Lib_Src_Dir.Location, Project);
Project.Library_Src_Dir := No_Path_Information;
exit;
end if;
Data.Tree.String_Elements.Table (Src_Dirs);
-- Report error if it is one of the source
- -- directories
+ -- directories.
if Project.Library_Src_Dir.Name =
Path_Name_Type (Src_Dir.Value)
File_Name_Type (Src_Dir.Value);
Error_Msg_Name_1 := Pid.Project.Name;
Error_Msg
- (Project,
+ (Data.Flags,
"directory to copy interfaces cannot " &
"be the same as source directory { of " &
"project %%",
- Lib_Src_Dir.Location, Data);
+ Lib_Src_Dir.Location, Project);
Project.Library_Src_Dir :=
No_Path_Information;
exit Project_Loop;
else
Error_Msg
- (Project,
+ (Data.Flags,
"illegal value for Library_Symbol_Policy",
- Lib_Symbol_Policy.Location, Data);
+ Lib_Symbol_Policy.Location, Project);
end if;
end;
end if;
if Lib_Symbol_File.Default then
if Project.Symbol_Data.Symbol_Policy = Restricted then
Error_Msg
- (Project,
+ (Data.Flags,
"Library_Symbol_File needs to be defined when " &
"symbol policy is Restricted",
- Lib_Symbol_Policy.Location, Data);
+ Lib_Symbol_Policy.Location, Project);
end if;
else
if Name_Len = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"symbol file name cannot be an empty string",
- Lib_Symbol_File.Location, Data);
+ Lib_Symbol_File.Location, Project);
else
OK := not Is_Absolute_Path (Name_Buffer (1 .. Name_Len));
if not OK then
Error_Msg_File_1 := File_Name_Type (Lib_Symbol_File.Value);
Error_Msg
- (Project,
+ (Data.Flags,
"symbol file name { is illegal. " &
"Name cannot include directory info.",
- Lib_Symbol_File.Location, Data);
+ Lib_Symbol_File.Location, Project);
end if;
end if;
end if;
or else Project.Symbol_Data.Symbol_Policy = Controlled
then
Error_Msg
- (Project,
+ (Data.Flags,
"a reference symbol file needs to be defined",
- Lib_Symbol_Policy.Location, Data);
+ Lib_Symbol_Policy.Location, Project);
end if;
else
if Name_Len = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"reference symbol file name cannot be an empty string",
- Lib_Symbol_File.Location, Data);
+ Lib_Symbol_File.Location, Project);
else
if not Is_Absolute_Path (Name_Buffer (1 .. Name_Len)) then
and then Project.Symbol_Data.Symbol_Policy /= Direct;
Error_Msg
- (Project,
+ (Data.Flags,
"<library reference symbol file { does not exist",
- Lib_Ref_Symbol_File.Location, Data);
+ Lib_Ref_Symbol_File.Location, Project);
-- In addition in the non-controlled case, if symbol policy
-- is Compliant, it is changed to Autonomous, because there
begin
if Symb_Path = Ref_Path then
Error_Msg
- (Project,
+ (Data.Flags,
"library reference symbol file and library" &
" symbol file cannot be the same file",
- Lib_Ref_Symbol_File.Location, Data);
+ Lib_Ref_Symbol_File.Location, Project);
end if;
end;
end if;
begin
if Dir'Length > 1
and then (Dir (Dir'Last - 1) = Directory_Separator
- or else Dir (Dir'Last - 1) = '/')
+ or else
+ Dir (Dir'Last - 1) = '/')
then
return Dir'Last - 1;
else
end if;
end Compute_Directory_Last;
- ---------------
- -- Error_Msg --
- ---------------
-
- procedure Error_Msg
- (Project : Project_Id;
- Msg : String;
- Flag_Location : Source_Ptr;
- Data : Tree_Processing_Data)
- is
- Real_Location : Source_Ptr := Flag_Location;
- Error_Buffer : String (1 .. 5_000);
- Error_Last : Natural := 0;
- Name_Number : Natural := 0;
- File_Number : Natural := 0;
- First : Positive := Msg'First;
- Index : Positive;
-
- procedure Add (C : Character);
- -- Add a character to the buffer
-
- procedure Add (S : String);
- -- Add a string to the buffer
-
- procedure Add_Name;
- -- Add a name to the buffer
-
- procedure Add_File;
- -- Add a file name to the buffer
-
- ---------
- -- Add --
- ---------
-
- procedure Add (C : Character) is
- begin
- Error_Last := Error_Last + 1;
- Error_Buffer (Error_Last) := C;
- end Add;
-
- procedure Add (S : String) is
- begin
- Error_Buffer (Error_Last + 1 .. Error_Last + S'Length) := S;
- Error_Last := Error_Last + S'Length;
- end Add;
-
- --------------
- -- Add_File --
- --------------
-
- procedure Add_File is
- File : File_Name_Type;
-
- begin
- Add ('"');
- File_Number := File_Number + 1;
-
- case File_Number is
- when 1 =>
- File := Err_Vars.Error_Msg_File_1;
- when 2 =>
- File := Err_Vars.Error_Msg_File_2;
- when 3 =>
- File := Err_Vars.Error_Msg_File_3;
- when others =>
- null;
- end case;
-
- Get_Name_String (File);
- Add (Name_Buffer (1 .. Name_Len));
- Add ('"');
- end Add_File;
-
- --------------
- -- Add_Name --
- --------------
-
- procedure Add_Name is
- Name : Name_Id;
-
- begin
- Add ('"');
- Name_Number := Name_Number + 1;
-
- case Name_Number is
- when 1 =>
- Name := Err_Vars.Error_Msg_Name_1;
- when 2 =>
- Name := Err_Vars.Error_Msg_Name_2;
- when 3 =>
- Name := Err_Vars.Error_Msg_Name_3;
- when others =>
- null;
- end case;
-
- Get_Name_String (Name);
- Add (Name_Buffer (1 .. Name_Len));
- Add ('"');
- end Add_Name;
-
- -- Start of processing for Error_Msg
-
- begin
- -- Display the error message in the traces so that it appears in the
- -- correct location in the traces (otherwise error messages are only
- -- displayed at the end and it is difficult to see when they were
- -- triggered)
-
- if Current_Verbosity = High then
- Write_Line ("ERROR: " & Msg);
- end if;
-
- -- If location of error is unknown, use the location of the project
-
- if Real_Location = No_Location then
- Real_Location := Project.Location;
- end if;
-
- if Data.Flags.Report_Error = null then
- Prj.Err.Error_Msg (Msg, Real_Location);
- return;
- end if;
-
- -- Ignore continuation character
-
- if Msg (First) = '\' then
- First := First + 1;
- end if;
-
- -- Warning character is always the first one in this package
- -- this is an undocumented kludge???
-
- if Msg (First) = '?' then
- First := First + 1;
- Add ("Warning: ");
-
- elsif Msg (First) = '<' then
- First := First + 1;
-
- if Err_Vars.Error_Msg_Warn then
- Add ("Warning: ");
- end if;
- end if;
-
- Index := First;
- while Index <= Msg'Last loop
- if Msg (Index) = '{' then
- Add_File;
-
- elsif Msg (Index) = '%' then
- if Index < Msg'Last and then Msg (Index + 1) = '%' then
- Index := Index + 1;
- end if;
-
- Add_Name;
-
- else
- Add (Msg (Index));
- end if;
-
- Index := Index + 1;
-
- end loop;
-
- Data.Flags.Report_Error
- (Error_Buffer (1 .. Error_Last), Project, Data.Tree);
- end Error_Msg;
-
---------------------
-- Get_Directories --
---------------------
(Name_Source_Files,
Project.Decl.Attributes, Data.Tree);
- Last_Source_Dir : String_List_Id := Nil_String;
+ Last_Source_Dir : String_List_Id := Nil_String;
+ Last_Src_Dir_Rank : Number_List_Index := No_Number_List;
Languages : constant Variable_Value :=
Prj.Util.Value_Of
procedure Find_Source_Dirs
(From : File_Name_Type;
Location : Source_Ptr;
+ Rank : Natural;
Removed : Boolean := False);
-- Find one or several source directories, and add (or remove, if
-- Removed is True) them to list of source directories of the project.
procedure Find_Source_Dirs
(From : File_Name_Type;
Location : Source_Ptr;
+ Rank : Natural;
Removed : Boolean := False)
is
Directory : constant String := Get_Name_String (From);
- Element : String_Element;
+
+ procedure Add_To_Or_Remove_From_List
+ (Path_Id : Name_Id;
+ Display_Path_Id : Name_Id);
+ -- When Removed = False, the directory Path_Id to the list of
+ -- source_dirs if not already in the list. When Removed = True,
+ -- removed directory Path_Id if in the list.
procedure Recursive_Find_Dirs (Path : Name_Id);
-- Find all the subdirectories (recursively) of Path and add them
-- to the list of source directories of the project.
- -------------------------
- -- Recursive_Find_Dirs --
- -------------------------
-
- procedure Recursive_Find_Dirs (Path : Name_Id) is
- Dir : Dir_Type;
- Name : String (1 .. 250);
- Last : Natural;
- List : String_List_Id;
- Prev : String_List_Id;
- Element : String_Element;
- Found : Boolean := False;
-
- Non_Canonical_Path : Name_Id := No_Name;
- Canonical_Path : Name_Id := No_Name;
-
- The_Path : constant String :=
- Normalize_Pathname
- (Get_Name_String (Path),
- Directory => Get_Name_String
- (Project.Directory.Display_Name),
- Resolve_Links => Opt.Follow_Links_For_Dirs) &
- Directory_Separator;
-
- The_Path_Last : constant Natural :=
- Compute_Directory_Last (The_Path);
+ --------------------------------
+ -- Add_To_Or_Remove_From_List --
+ --------------------------------
+
+ procedure Add_To_Or_Remove_From_List
+ (Path_Id : Name_Id;
+ Display_Path_Id : Name_Id)
+ is
+ List : String_List_Id;
+ Prev : String_List_Id;
+ Rank_List : Number_List_Index;
+ Prev_Rank : Number_List_Index;
+ Element : String_Element;
begin
- Name_Len := The_Path_Last - The_Path'First + 1;
- Name_Buffer (1 .. Name_Len) :=
- The_Path (The_Path'First .. The_Path_Last);
- Non_Canonical_Path := Name_Find;
- Canonical_Path :=
- Name_Id (Canonical_Case_File_Name (Non_Canonical_Path));
-
- -- To avoid processing the same directory several times, check
- -- if the directory is already in Recursive_Dirs. If it is, then
- -- there is nothing to do, just return. If it is not, put it there
- -- and continue recursive processing.
-
- if not Removed then
- if Recursive_Dirs.Get (Visited, Canonical_Path) then
- return;
- else
- Recursive_Dirs.Set (Visited, Canonical_Path, True);
- end if;
- end if;
-
- -- Check if directory is already in list
-
- List := Project.Source_Dirs;
- Prev := Nil_String;
+ Prev := Nil_String;
+ Prev_Rank := No_Number_List;
+ List := Project.Source_Dirs;
+ Rank_List := Project.Source_Dir_Ranks;
while List /= Nil_String loop
Element := Data.Tree.String_Elements.Table (List);
-
- if Element.Value /= No_Name then
- Found := Element.Value = Canonical_Path;
- exit when Found;
- end if;
-
+ exit when Element.Value = Path_Id;
Prev := List;
List := Element.Next;
+ Prev_Rank := Rank_List;
+ Rank_List := Data.Tree.Number_Lists.Table (Prev_Rank).Next;
end loop;
- -- If directory is not already in list, put it there
+ -- The directory is in the list if List is not Nil_String
- if (not Removed) and (not Found) then
+ if not Removed and then List = Nil_String then
if Current_Verbosity = High then
- Write_Str (" ");
- Write_Line (The_Path (The_Path'First .. The_Path_Last));
+ Write_Str (" Adding Source Dir=");
+ Write_Line (Get_Name_String (Path_Id));
end if;
String_Element_Table.Increment_Last (Data.Tree.String_Elements);
Element :=
- (Value => Canonical_Path,
- Display_Value => Non_Canonical_Path,
+ (Value => Path_Id,
+ Index => 0,
+ Display_Value => Display_Path_Id,
Location => No_Location,
Flag => False,
- Next => Nil_String,
- Index => 0);
+ Next => Nil_String);
- -- Case of first source directory
+ Number_List_Table.Increment_Last (Data.Tree.Number_Lists);
if Last_Source_Dir = Nil_String then
+
+ -- This is the first source directory
+
Project.Source_Dirs :=
String_Element_Table.Last (Data.Tree.String_Elements);
-
- -- Here we already have source directories
+ Project.Source_Dir_Ranks :=
+ Number_List_Table.Last (Data.Tree.Number_Lists);
else
- -- Link the previous last to the new one
+ -- We already have source directories, link the previous
+ -- last to the new one.
- Data.Tree.String_Elements.Table
- (Last_Source_Dir).Next :=
- String_Element_Table.Last (Data.Tree.String_Elements);
+ Data.Tree.String_Elements.Table (Last_Source_Dir).Next :=
+ String_Element_Table.Last (Data.Tree.String_Elements);
+ Data.Tree.Number_Lists.Table (Last_Src_Dir_Rank).Next :=
+ Number_List_Table.Last (Data.Tree.Number_Lists);
end if;
-- And register this source directory as the new last
Last_Source_Dir :=
String_Element_Table.Last (Data.Tree.String_Elements);
Data.Tree.String_Elements.Table (Last_Source_Dir) := Element;
+ Last_Src_Dir_Rank :=
+ Number_List_Table.Last (Data.Tree.Number_Lists);
+ Data.Tree.Number_Lists.Table (Last_Src_Dir_Rank) :=
+ (Number => Rank, Next => No_Number_List);
+
+ elsif Removed and then List /= Nil_String then
+
+ -- Remove source dir, if present
- elsif Removed and Found then
if Prev = Nil_String then
Project.Source_Dirs :=
Data.Tree.String_Elements.Table (List).Next;
+ Project.Source_Dir_Ranks :=
+ Data.Tree.Number_Lists.Table (Rank_List).Next;
+
else
Data.Tree.String_Elements.Table (Prev).Next :=
Data.Tree.String_Elements.Table (List).Next;
+ Data.Tree.Number_Lists.Table (Prev_Rank).Next :=
+ Data.Tree.Number_Lists.Table (Rank_List).Next;
+ end if;
+ end if;
+ end Add_To_Or_Remove_From_List;
+
+ -------------------------
+ -- Recursive_Find_Dirs --
+ -------------------------
+
+ procedure Recursive_Find_Dirs (Path : Name_Id) is
+ Dir : Dir_Type;
+ Name : String (1 .. 250);
+ Last : Natural;
+
+ Non_Canonical_Path : Name_Id := No_Name;
+ Canonical_Path : Name_Id := No_Name;
+
+ The_Path : constant String :=
+ Normalize_Pathname
+ (Get_Name_String (Path),
+ Directory =>
+ Get_Name_String (Project.Directory.Display_Name),
+ Resolve_Links => Opt.Follow_Links_For_Dirs) &
+ Directory_Separator;
+
+ The_Path_Last : constant Natural :=
+ Compute_Directory_Last (The_Path);
+
+ begin
+ Name_Len := The_Path_Last - The_Path'First + 1;
+ Name_Buffer (1 .. Name_Len) :=
+ The_Path (The_Path'First .. The_Path_Last);
+ Non_Canonical_Path := Name_Find;
+ Canonical_Path :=
+ Name_Id (Canonical_Case_File_Name (Non_Canonical_Path));
+
+ -- To avoid processing the same directory several times, check
+ -- if the directory is already in Recursive_Dirs. If it is, then
+ -- there is nothing to do, just return. If it is not, put it there
+ -- and continue recursive processing.
+
+ if not Removed then
+ if Recursive_Dirs.Get (Visited, Canonical_Path) then
+ return;
+ else
+ Recursive_Dirs.Set (Visited, Canonical_Path, True);
end if;
end if;
- -- Now look for subdirectories. We do that even when this
- -- directory is already in the list, because some of its
- -- subdirectories may not be in the list yet.
+ Add_To_Or_Remove_From_List
+ (Path_Id => Canonical_Path,
+ Display_Path_Id => Non_Canonical_Path);
+
+ -- Now look for subdirectories. Do that even when this directory
+ -- is already in the list, because some of its subdirectories may
+ -- not be in the list yet.
Open (Dir, The_Path (The_Path'First .. The_Path_Last));
declare
Path_Name : constant String :=
- Normalize_Pathname
- (Name => Name (1 .. Last),
- Directory =>
- The_Path (The_Path'First .. The_Path_Last),
- Resolve_Links => Opt.Follow_Links_For_Dirs,
- Case_Sensitive => True);
+ Normalize_Pathname
+ (Name => Name (1 .. Last),
+ Directory =>
+ The_Path
+ (The_Path'First .. The_Path_Last),
+ Resolve_Links =>
+ Opt.Follow_Links_For_Dirs,
+ Case_Sensitive => True);
begin
if Is_Directory (Path_Name) then
if Current_Verbosity = High and then not Removed then
Write_Str ("Find_Source_Dirs (""");
Write_Str (Directory);
+ Write_Str (",");
+ Write_Str (Rank'Img);
Write_Line (""")");
end if;
or else
Directory (Directory'Last - 2) = Directory_Separator)
then
- if not Removed then
- Project.Known_Order_Of_Source_Dirs := False;
- end if;
-
Name_Len := Directory'Length - 3;
if Name_Len = 0 then
Directory =>
Get_Name_String
(Project.Directory.Display_Name),
- Resolve_Links => False,
+ Resolve_Links =>
+ Opt.Follow_Links_For_Dirs,
Case_Sensitive => True);
begin
if Location = No_Location then
Error_Msg
- (Project,
+ (Data.Flags,
"{ is not a valid directory.",
- Project.Location, Data);
+ Project.Location, Project);
else
Error_Msg
- (Project,
+ (Data.Flags,
"{ is not a valid directory.",
- Location, Data);
+ Location, Project);
end if;
else
else
declare
Path_Name : Path_Information;
- List : String_List_Id;
- Prev : String_List_Id;
Dir_Exists : Boolean;
begin
if Location = No_Location then
Error_Msg
- (Project,
+ (Data.Flags,
"{ is not a valid directory",
- Project.Location, Data);
+ Project.Location, Project);
else
Error_Msg
- (Project,
+ (Data.Flags,
"{ is not a valid directory",
- Location, Data);
+ Location, Project);
end if;
else
declare
- Path : constant String :=
- Get_Name_String (Path_Name.Name);
+ Path : constant String :=
+ Normalize_Pathname
+ (Name =>
+ Get_Name_String (Path_Name.Name),
+ Directory =>
+ Get_Name_String (Project.Directory.Name),
+ Resolve_Links => Opt.Follow_Links_For_Dirs,
+ Case_Sensitive => True) &
+ Directory_Separator;
+
Last_Path : constant Natural :=
Compute_Directory_Last (Path);
Path_Id : Name_Id;
Name_Len := 0;
Add_Str_To_Name_Buffer (Path (Path'First .. Last_Path));
Path_Id := Name_Find;
+
Name_Len := 0;
Add_Str_To_Name_Buffer
(Display_Path
(Display_Path'First .. Last_Display_Path));
Display_Path_Id := Name_Find;
- if not Removed then
-
- -- As it is an existing directory, we add it to the
- -- list of directories.
-
- String_Element_Table.Increment_Last
- (Data.Tree.String_Elements);
- Element :=
- (Value => Path_Id,
- Index => 0,
- Display_Value => Display_Path_Id,
- Location => No_Location,
- Flag => False,
- Next => Nil_String);
-
- if Last_Source_Dir = Nil_String then
-
- -- This is the first source directory
-
- Project.Source_Dirs := String_Element_Table.Last
- (Data.Tree.String_Elements);
-
- else
- -- We already have source directories, link the
- -- previous last to the new one.
-
- Data.Tree.String_Elements.Table
- (Last_Source_Dir).Next :=
- String_Element_Table.Last
- (Data.Tree.String_Elements);
- end if;
-
- -- And register this source directory as the new last
-
- Last_Source_Dir := String_Element_Table.Last
- (Data.Tree.String_Elements);
- Data.Tree.String_Elements.Table
- (Last_Source_Dir) := Element;
-
- else
- -- Remove source dir, if present
-
- Prev := Nil_String;
-
- -- Look for source dir in current list
-
- List := Project.Source_Dirs;
- while List /= Nil_String loop
- Element := Data.Tree.String_Elements.Table (List);
- exit when Element.Value = Path_Id;
- Prev := List;
- List := Element.Next;
- end loop;
-
- if List /= Nil_String then
- -- Source dir was found, remove it from the list
-
- if Prev = Nil_String then
- Project.Source_Dirs :=
- Data.Tree.String_Elements.Table (List).Next;
-
- else
- Data.Tree.String_Elements.Table (Prev).Next :=
- Data.Tree.String_Elements.Table (List).Next;
- end if;
- end if;
- end if;
+ Add_To_Or_Remove_From_List
+ (Path_Id => Path_Id,
+ Display_Path_Id => Display_Path_Id);
end;
end if;
end;
if Name_Len = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"Object_Dir cannot be empty",
- Object_Dir.Location, Data);
+ Object_Dir.Location, Project);
else
-- We check that the specified object directory does exist.
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Object_Dir.Value);
- Error_Msg
- (Project,
- "object directory { not found",
- Project.Location, Data);
+
+ case Data.Flags.Require_Obj_Dirs is
+ when Error =>
+ Error_Msg
+ (Data.Flags,
+ "object directory { not found",
+ Project.Location, Project);
+ when Warning =>
+ Error_Msg
+ (Data.Flags,
+ "?object directory { not found",
+ Project.Location, Project);
+ when Silent =>
+ null;
+ end case;
end if;
end if;
if Name_Len = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"Exec_Dir cannot be empty",
- Exec_Dir.Location, Data);
+ Exec_Dir.Location, Project);
else
-- We check that the specified exec directory does exist
if not Dir_Exists then
Err_Vars.Error_Msg_File_1 := File_Name_Type (Exec_Dir.Value);
Error_Msg
- (Project,
+ (Data.Flags,
"exec directory { not found",
- Project.Location, Data);
+ Project.Location, Project);
end if;
end if;
end if;
if Project.Qualifier = Standard then
Error_Msg
- (Project,
+ (Data.Flags,
"a standard project cannot have no sources",
- Source_Files.Location, Data);
+ Source_Files.Location, Project);
end if;
elsif Source_Dirs.Default then
Project.Source_Dirs :=
String_Element_Table.Last (Data.Tree.String_Elements);
+ Number_List_Table.Append
+ (Data.Tree.Number_Lists,
+ (Number => 1, Next => No_Number_List));
+
+ Project.Source_Dir_Ranks :=
+ Number_List_Table.Last (Data.Tree.Number_Lists);
+
if Current_Verbosity = High then
Write_Attr
("Default source directory",
elsif Source_Dirs.Values = Nil_String then
if Project.Qualifier = Standard then
Error_Msg
- (Project,
+ (Data.Flags,
"a standard project cannot have no source directories",
- Source_Dirs.Location, Data);
+ Source_Dirs.Location, Project);
end if;
Project.Source_Dirs := Nil_String;
declare
Source_Dir : String_List_Id;
Element : String_Element;
-
+ Rank : Natural;
begin
-- Process the source directories for each element of the list
Source_Dir := Source_Dirs.Values;
+ Rank := 0;
while Source_Dir /= Nil_String loop
Element := Data.Tree.String_Elements.Table (Source_Dir);
+ Rank := Rank + 1;
Find_Source_Dirs
- (File_Name_Type (Element.Value), Element.Location);
+ (File_Name_Type (Element.Value), Element.Location, Rank);
Source_Dir := Element.Next;
end loop;
end;
Find_Source_Dirs
(File_Name_Type (Element.Value),
Element.Location,
+ 0,
Removed => True);
Source_Dir := Element.Next;
end loop;
elsif Project.Library then
Error_Msg
- (Project,
+ (Data.Flags,
"a library project file cannot have Main specified",
- Mains.Location, Data);
+ Mains.Location, Project);
else
List := Mains.Values;
if Length_Of_Name (Elem.Value) = 0 then
Error_Msg
- (Project,
+ (Data.Flags,
"?a main cannot have an empty name",
- Elem.Location, Data);
+ Elem.Location, Project);
exit;
end if;
Prj.Util.Open (File, Path);
if not Prj.Util.Is_Valid (File) then
- Error_Msg (Project.Project, "file does not exist", Location, Data);
+ Error_Msg
+ (Data.Flags, "file does not exist", Location, Project.Project);
else
-- Read the lines one by one
if Line (J) = '/' or else Line (J) = Directory_Separator then
Error_Msg_File_1 := Source_Name;
Error_Msg
- (Project.Project,
+ (Data.Flags,
"file name cannot include directory information ({)",
- Location, Data);
+ Location, Project.Project);
exit;
end if;
end loop;
is
Filename : constant String := Get_Name_String (File_Name);
Last : Integer := Filename'Last;
- Sep_Len : constant Integer :=
- Integer (Length_Of_Name (Naming.Separate_Suffix));
- Body_Len : constant Integer :=
- Integer (Length_Of_Name (Naming.Body_Suffix));
- Spec_Len : constant Integer :=
- Integer (Length_Of_Name (Naming.Spec_Suffix));
-
- Standard_GNAT : constant Boolean :=
- Naming.Spec_Suffix = Default_Ada_Spec_Suffix
- and then
- Naming.Body_Suffix = Default_Ada_Body_Suffix;
+ Sep_Len : Integer;
+ Body_Len : Integer;
+ Spec_Len : Integer;
Unit_Except : Unit_Exception;
Masked : Boolean := False;
Unit := No_Name;
Kind := Spec;
+ if Naming.Separate_Suffix = No_File
+ or else Naming.Body_Suffix = No_File
+ or else Naming.Spec_Suffix = No_File
+ then
+ return;
+ end if;
+
if Naming.Dot_Replacement = No_File then
if Current_Verbosity = High then
Write_Line (" No dot_replacement specified");
return;
end if;
+ Sep_Len := Integer (Length_Of_Name (Naming.Separate_Suffix));
+ Spec_Len := Integer (Length_Of_Name (Naming.Spec_Suffix));
+ Body_Len := Integer (Length_Of_Name (Naming.Body_Suffix));
+
-- Choose the longest suffix that matches. If there are several matches,
-- give priority to specs, then bodies, then separates.
-- In the standard GNAT naming scheme, check for special cases: children
-- or separates of A, G, I or S, and run time sources.
- if Standard_GNAT and then Name_Len >= 3 then
+ if Is_Standard_GNAT_Naming (Naming)
+ and then Name_Len >= 3
+ then
declare
S1 : constant Character := Name_Buffer (1);
S2 : constant Character := Name_Buffer (2);
elsif S2 = '.' then
- -- If it is potentially a run time source, disable filling
- -- of the mapping file to avoid warnings.
+ -- If it is potentially a run time source
- Set_Mapping_File_Initial_State_To_Empty (In_Tree);
+ null;
end if;
end if;
end;
elsif Index (Suffix_Str, ".") = 0 then
Err_Vars.Error_Msg_File_1 := Suffix;
Error_Msg
- (Project,
+ (Data.Flags,
"{ is illegal for " & Attribute_Name & ": must have a dot",
- Location, Data);
+ Location, Project);
return;
end if;
if Is_Letter (Suffix_Str (Suffix_Str'First + 1)) then
Err_Vars.Error_Msg_File_1 := Suffix;
Error_Msg
- (Project,
+ (Data.Flags,
"{ is illegal for " & Attribute_Name
& ": ambiguous prefix when Dot_Replacement is a dot",
- Location, Data);
+ Location, Project);
end if;
return;
end if;
exception
when Use_Error =>
Error_Msg
- (Project,
+ (Data.Flags,
"could not create " & Create &
" directory " & Full_Path_Name.all,
- Location, Data);
+ Location, Project);
end;
end if;
end if;
if not Excluded_Source_List_File.Default then
if Locally_Removed then
Error_Msg
- (Project.Project,
+ (Data.Flags,
"?both attributes Locally_Removed_Files and " &
"Excluded_Source_List_File are present",
- Excluded_Source_List_File.Location, Data);
+ Excluded_Source_List_File.Location, Project.Project);
else
Error_Msg
- (Project.Project,
+ (Data.Flags,
"?both attributes Excluded_Source_Files and " &
"Excluded_Source_List_File are present",
- Excluded_Source_List_File.Location, Data);
+ Excluded_Source_List_File.Location, Project.Project);
end if;
end if;
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Excluded_Source_List_File.Value);
Error_Msg
- (Project.Project,
+ (Data.Flags,
"file with excluded sources { does not exist",
- Excluded_Source_List_File.Location, Data);
+ Excluded_Source_List_File.Location, Project.Project);
else
-- Open the file
if not Prj.Util.Is_Valid (File) then
Error_Msg
- (Project.Project, "file does not exist", Location, Data);
+ (Data.Flags, "file does not exist",
+ Location, Project.Project);
else
-- Read the lines one by one
then
Error_Msg_File_1 := Name;
Error_Msg
- (Project.Project,
+ (Data.Flags,
"file name cannot include " &
"directory information ({)",
- Location, Data);
+ Location, Project.Project);
exit;
end if;
end loop;
if not Sources.Default then
if not Source_List_File.Default then
Error_Msg
- (Project.Project,
+ (Data.Flags,
"?both attributes source_files and " &
"source_list_file are present",
- Source_List_File.Location, Data);
+ Source_List_File.Location, Project.Project);
end if;
-- Sources is a list of file names
then
Error_Msg_File_1 := Name;
Error_Msg
- (Project.Project,
+ (Data.Flags,
"file name cannot include directory " &
"information ({)",
- Location, Data);
+ Location, Project.Project);
exit;
end if;
end loop;
Err_Vars.Error_Msg_File_1 :=
File_Name_Type (Source_List_File.Value);
Error_Msg
- (Project.Project,
+ (Data.Flags,
"file with sources { does not exist",
- Source_List_File.Location, Data);
+ Source_List_File.Location, Project.Project);
else
Get_Sources_From_File
Data => Data,
For_All_Sources => Sources.Default and then Source_List_File.Default);
- -- Check if all exceptions have been found.
+ -- Check if all exceptions have been found
declare
Source : Source_Id;
Error_Msg_Name_1 := Name_Id (Source.Display_File);
Error_Msg_Name_2 := Name_Id (Source.Unit.Name);
Error_Msg
- (Project.Project,
+ (Data.Flags,
"source file %% for unit %% not found",
- No_Location,
- Data);
+ No_Location, Project.Project);
else
Source.Path := Files_Htable.Get
if First_Error then
Error_Msg
- (Project.Project,
+ (Data.Flags,
"source file { not found",
- NL.Location, Data);
+ NL.Location, Project.Project);
First_Error := False;
else
Error_Msg
- (Project.Project,
+ (Data.Flags,
"\source file { not found",
- NL.Location, Data);
+ NL.Location, Project.Project);
end if;
end if;
procedure Initialize
(Data : out Tree_Processing_Data;
Tree : Project_Tree_Ref;
- Flags : Prj.Processing_Flags) is
+ Flags : Prj.Processing_Flags)
+ is
begin
Files_Htable.Reset (Data.File_To_Source);
Data.Tree := Tree;
procedure Initialize
(Data : in out Project_Processing_Data;
- Project : Project_Id) is
+ Project : Project_Id)
+ is
begin
Data.Project := Project;
end Initialize;
Source.Kind := Kind;
+ if Current_Verbosity = High
+ and then Source.File /= No_File
+ then
+ Write_Line ("Override kind for "
+ & Get_Name_String (Source.File)
+ & " kind=" & Source.Kind'Img);
+ end if;
+
if Source.Kind in Spec_Or_Body and then Source.Unit /= null then
Source.Unit.File_Names (Source.Kind) := Source;
end if;
procedure Check_File
(Project : in out Project_Processing_Data;
Data : in out Tree_Processing_Data;
+ Source_Dir_Rank : Natural;
Path : Path_Name_Type;
File_Name : File_Name_Type;
Display_File_Name : File_Name_Type;
Kind : Source_Kind := Spec;
begin
+ if Current_Verbosity = High then
+ Write_Line ("Checking file:");
+ Write_Str (" Path = ");
+ Write_Line (Get_Name_String (Path));
+ Write_Str (" Rank =");
+ Write_Line (Source_Dir_Rank'Img);
+ end if;
+
if Name_Loc = No_Name_Location then
Check_Name := For_All_Sources;
-- Check if it is OK to have the same file name in several
-- source directories.
- if not Project.Project.Known_Order_Of_Source_Dirs then
+ if Source_Dir_Rank = Name_Loc.Source.Source_Dir_Rank then
Error_Msg_File_1 := File_Name;
Error_Msg
- (Project.Project,
+ (Data.Flags,
"{ is found in several source directories",
- Name_Loc.Location, Data);
+ Name_Loc.Location, Project.Project);
end if;
else
then
Error_Msg_File_1 := File_Name;
Error_Msg
- (Project.Project,
+ (Data.Flags,
"language unknown for {",
- Name_Loc.Location, Data);
+ Name_Loc.Location, Project.Project);
end if;
else
Add_Source
(Id => Source,
Project => Project.Project,
+ Source_Dir_Rank => Source_Dir_Rank,
Lang_Id => Language,
Kind => Kind,
Data => Data,
File_Name => File_Name,
Display_File => Display_File_Name,
Unit => Unit,
+ Locally_Removed => Locally_Removed,
Path => (Canonical_Path, Path));
- if Source /= No_Source then
- Source.Locally_Removed := Locally_Removed;
+ -- If it is a source specified in a list, update the entry in
+ -- the Source_Names table.
+
+ if Name_Loc.Found and then Name_Loc.Source = No_Source then
+ Name_Loc.Source := Source;
+ Source_Names_Htable.Set
+ (Project.Source_Names, File_Name, Name_Loc);
end if;
end if;
end if;
is
Source_Dir : String_List_Id;
Element : String_Element;
+ Src_Dir_Rank : Number_List_Index;
+ Num_Nod : Number_Node;
Dir : Dir_Type;
Name : String (1 .. 1_000);
Last : Natural;
-- Loop through subdirectories
Source_Dir := Project.Project.Source_Dirs;
+ Src_Dir_Rank := Project.Project.Source_Dir_Ranks;
while Source_Dir /= Nil_String loop
begin
+ Num_Nod := Data.Tree.Number_Lists.Table (Src_Dir_Rank);
Element := Data.Tree.String_Elements.Table (Source_Dir);
+
if Element.Value /= No_Name then
Get_Name_String (Element.Display_Value);
+ if Current_Verbosity = High then
+ Write_Str ("Directory: ");
+ Write_Str (Name_Buffer (1 .. Name_Len));
+ Write_Line (Num_Nod.Number'Img);
+ end if;
+
declare
Source_Directory : constant String :=
Name_Buffer (1 .. Name_Len) &
exit when Last = 0;
- -- ??? Duplicate system call here, we just did a a
- -- similar one. Maybe Ada.Directories would be more
- -- appropriate here.
+ -- In fast project loading mode (without -eL), the user
+ -- guarantees that no directory has a name which is a
+ -- valid source name, so we can avoid doing a system call
+ -- here. This provides a very significant speed up on
+ -- slow file systems (remote files for instance).
- if Is_Regular_File
- (Source_Directory & Name (1 .. Last))
+ if not Opt.Follow_Links_For_Files
+ or else Is_Regular_File
+ (Source_Directory & Name (1 .. Last))
then
if Current_Verbosity = High then
Write_Str (" Checking ");
-- still need to add it to the list: if we
-- don't, the file will not appear in the
-- mapping file and will cause the compiler
- -- to fail
+ -- to fail.
To_Remove := True;
end if;
Check_File
(Project => Project,
+ Source_Dir_Rank => Num_Nod.Number,
Data => Data,
Path => Path,
File_Name => File_Name,
end;
Source_Dir := Element.Next;
+ Src_Dir_Rank := Num_Nod.Next;
end loop;
if Current_Verbosity = High then
then
Error_Msg_File_1 := Source.File;
Error_Msg
- (Project.Project,
+ (Data.Flags,
"{ cannot be both excluded and an exception file name",
- No_Location, Data);
+ No_Location, Project.Project);
end if;
if Current_Verbosity = High then
Error_Msg_File_1 := Src.File;
Error_Msg_File_2 := Source.File;
Error_Msg
- (Project.Project,
+ (Data.Flags,
"{ and { have the same object file name",
- No_Location, Data);
+ No_Location, Project.Project);
else
Object_File_Names_Htable.Set (Object_Files, Src.Object, Src);
if Src = No_Source then
Error_Msg
- (Project.Project,
- "unknown file {", Excluded.Location, Data);
+ (Data.Flags,
+ "unknown file {", Excluded.Location, Project.Project);
else
Error_Msg
- (Project.Project,
+ (Data.Flags,
"cannot remove a source from an imported project: {",
- Excluded.Location, Data);
+ Excluded.Location, Project.Project);
end if;
end if;
else
-- Check if it is a subunit
- Src_Ind := Sinput.P.Load_Project_File
- (Get_Name_String (Src_Id.Path.Name));
+ Src_Ind :=
+ Sinput.P.Load_Project_File
+ (Get_Name_String (Src_Id.Path.Name));
if Sinput.P.Source_File_Is_Subunit (Src_Ind) then
Override_Kind (Src_Id, Sep);
begin
if Current_Verbosity = High then
Write_Str ("Removing source ");
- Write_Line (Get_Name_String (Id.File) & " at" & Id.Index'Img);
+ Write_Str (Get_Name_String (Id.File));
+
+ if Id.Index /= 0 then
+ Write_Str (" at" & Id.Index'Img);
+ end if;
+
+ Write_Eol;
end if;
if Replaced_By /= No_Source then
Error_Msg_Warn := Data.Flags.When_No_Sources = Warning;
if Continuation then
- Error_Msg (Project, "\" & Msg, Location, Data);
+ Error_Msg (Data.Flags, "\" & Msg, Location, Project);
else
- Error_Msg (Project, Msg, Location, Data);
+ Error_Msg (Data.Flags, Msg, Location, Project);
end if;
end;
end case;
procedure Recursive_Check
(Project : Project_Id;
- Data : in out Tree_Processing_Data) is
+ Data : in out Tree_Processing_Data)
+ is
begin
if Verbose_Mode then
Write_Str ("Processing_Naming_Scheme for project """);
For_Every_Project_Imported (Tree_Processing_Data, Recursive_Check);
Data : Tree_Processing_Data;
+
+ -- Start of processing for Process_Naming_Scheme
begin
Initialize (Data, Tree => Tree, Flags => Flags);
Check_All_Projects (Root_Project, Data, Imported_First => True);