Commit c9287857 by Emmanuel Briot Committed by Arnaud Charlet

prj-proc.adb, [...] (Allow_Duplicate_Basenames): New parameter to several subprograms.

2009-06-24  Emmanuel Briot  <briot@adacore.com>

	* prj-proc.adb, prj-proc.ads, prj.ads, prj-nmsc.adb, prj-nmsc.ads,
	prj-conf.adb, prj-conf.ads (Allow_Duplicate_Basenames): New parameter
	to several subprograms.
	(Source_Data.Other_Part): Removed, since can be computed from the
	language.
	(Other_Part): New subprogram.

From-SVN: r148904
parent 2b426674
2009-06-24 Emmanuel Briot <briot@adacore.com> 2009-06-24 Emmanuel Briot <briot@adacore.com>
* prj-proc.adb, prj-proc.ads, prj.ads, prj-nmsc.adb, prj-nmsc.ads,
prj-conf.adb, prj-conf.ads (Allow_Duplicate_Basenames): New parameter
to several subprograms.
(Source_Data.Other_Part): Removed, since can be computed from the
language.
(Other_Part): New subprogram.
2009-06-24 Emmanuel Briot <briot@adacore.com>
* gnat_ugn.texi, prj-nmsc.adb (Suffix_Matches): A suffix can also match * gnat_ugn.texi, prj-nmsc.adb (Suffix_Matches): A suffix can also match
the full base name of the file when the suffix doesn't start with a '.'. the full base name of the file when the suffix doesn't start with a '.'.
......
...@@ -907,7 +907,8 @@ package body Prj.Conf is ...@@ -907,7 +907,8 @@ package body Prj.Conf is
Normalized_Hostname : String; Normalized_Hostname : String;
Report_Error : Put_Line_Access := null; Report_Error : Put_Line_Access := null;
On_Load_Config : Config_File_Hook := null; On_Load_Config : Config_File_Hook := null;
Compiler_Driver_Mandatory : Boolean := True) Compiler_Driver_Mandatory : Boolean := True;
Allow_Duplicate_Basenames : Boolean := False)
is is
Main_Config_Project : Project_Id; Main_Config_Project : Project_Id;
Success : Boolean; Success : Boolean;
...@@ -962,6 +963,7 @@ package body Prj.Conf is ...@@ -962,6 +963,7 @@ package body Prj.Conf is
Current_Dir => Current_Directory, Current_Dir => Current_Directory,
When_No_Sources => Warning, When_No_Sources => Warning,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory, Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames,
Is_Config_File => False); Is_Config_File => False);
if not Success then if not Success then
......
...@@ -98,7 +98,8 @@ package Prj.Conf is ...@@ -98,7 +98,8 @@ package Prj.Conf is
Normalized_Hostname : String; Normalized_Hostname : String;
Report_Error : Put_Line_Access := null; Report_Error : Put_Line_Access := null;
On_Load_Config : Config_File_Hook := null; On_Load_Config : Config_File_Hook := null;
Compiler_Driver_Mandatory : Boolean := True); Compiler_Driver_Mandatory : Boolean := True;
Allow_Duplicate_Basenames : Boolean := False);
-- Same as above, except the project must already have been parsed through -- Same as above, except the project must already have been parsed through
-- Prj.Part.Parse, and only the processing of the project and the -- Prj.Part.Parse, and only the processing of the project and the
-- configuration is done at this level. -- configuration is done at this level.
......
...@@ -240,7 +240,6 @@ package body Prj.Nmsc is ...@@ -240,7 +240,6 @@ package body Prj.Nmsc is
Naming_Exception : Boolean := False; Naming_Exception : Boolean := False;
Path : Path_Information := No_Path_Information; Path : Path_Information := No_Path_Information;
Alternate_Languages : Language_List := null; Alternate_Languages : Language_List := null;
Other_Part : Source_Id := No_Source;
Unit : Name_Id := No_Name; Unit : Name_Id := No_Name;
Index : Int := 0; Index : Int := 0;
Source_To_Replace : Source_Id := No_Source); Source_To_Replace : Source_Id := No_Source);
...@@ -378,11 +377,15 @@ package body Prj.Nmsc is ...@@ -378,11 +377,15 @@ package body Prj.Nmsc is
procedure Search_Directories procedure Search_Directories
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
For_All_Sources : Boolean); For_All_Sources : Boolean;
Allow_Duplicate_Basenames : Boolean);
-- Search the source directories to find the sources. -- Search the source directories to find the sources.
-- If For_All_Sources is True, check each regular file name against the -- If For_All_Sources is True, check each regular file name against the
-- naming schemes of the different languages. Otherwise consider only the -- naming schemes of the different languages. Otherwise consider only the
-- file names in the hash table Source_Names. -- 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)
procedure Check_File procedure Check_File
(Project : Project_Id; (Project : Project_Id;
...@@ -390,7 +393,8 @@ package body Prj.Nmsc is ...@@ -390,7 +393,8 @@ package body Prj.Nmsc is
Path : Path_Name_Type; Path : Path_Name_Type;
File_Name : File_Name_Type; File_Name : File_Name_Type;
Display_File_Name : File_Name_Type; Display_File_Name : File_Name_Type;
For_All_Sources : Boolean); For_All_Sources : Boolean;
Allow_Duplicate_Basenames : Boolean);
-- Check if file File_Name is a valid source of the project. This is used -- Check if file File_Name is a valid source of the project. This is used
-- in multi-language mode only. -- in multi-language mode only.
-- When the file matches one of the naming schemes, it is added to -- When the file matches one of the naming schemes, it is added to
...@@ -409,6 +413,10 @@ package body Prj.Nmsc is ...@@ -409,6 +413,10 @@ package body Prj.Nmsc is
-- --
-- If For_All_Sources is True, then all possible file names are analyzed -- 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 htable.
--
-- 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)
procedure Check_File_Naming_Schemes procedure Check_File_Naming_Schemes
(In_Tree : Project_Tree_Ref; (In_Tree : Project_Tree_Ref;
...@@ -459,11 +467,15 @@ package body Prj.Nmsc is ...@@ -459,11 +467,15 @@ package body Prj.Nmsc is
procedure Find_Sources procedure Find_Sources
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
Proc_Data : in out Processing_Data); Proc_Data : in out Processing_Data;
Allow_Duplicate_Basenames : Boolean);
-- Process the Source_Files and Source_List_File attributes, and store -- Process the Source_Files and Source_List_File attributes, and store
-- the list of source files into the Source_Names htable. -- the list of source files into the Source_Names htable.
-- When these attributes are not defined, find all files matching the -- When these attributes are not defined, find all files matching the
-- naming schemes in the source directories. -- naming schemes in the source directories.
-- 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)
procedure Compute_Unit_Name procedure Compute_Unit_Name
(File_Name : File_Name_Type; (File_Name : File_Name_Type;
...@@ -525,11 +537,15 @@ package body Prj.Nmsc is ...@@ -525,11 +537,15 @@ package body Prj.Nmsc is
procedure Look_For_Sources procedure Look_For_Sources
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
Proc_Data : in out Processing_Data); Proc_Data : in out Processing_Data;
Allow_Duplicate_Basenames : Boolean);
-- Find all the sources of project Project in project tree In_Tree and -- Find all the sources of project Project in project tree In_Tree and
-- update its Data accordingly. This assumes that Data.First_Source has -- update its Data accordingly. This assumes that Data.First_Source has
-- been initialized with the list of excluded sources and special naming -- been initialized with the list of excluded sources and special naming
-- exceptions. -- exceptions.
-- 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)
function Path_Name_Of function Path_Name_Of
(File_Name : File_Name_Type; (File_Name : File_Name_Type;
...@@ -683,7 +699,6 @@ package body Prj.Nmsc is ...@@ -683,7 +699,6 @@ package body Prj.Nmsc is
Naming_Exception : Boolean := False; Naming_Exception : Boolean := False;
Path : Path_Information := No_Path_Information; Path : Path_Information := No_Path_Information;
Alternate_Languages : Language_List := null; Alternate_Languages : Language_List := null;
Other_Part : Source_Id := No_Source;
Unit : Name_Id := No_Name; Unit : Name_Id := No_Name;
Index : Int := 0; Index : Int := 0;
Source_To_Replace : Source_Id := No_Source) Source_To_Replace : Source_Id := No_Source)
...@@ -716,11 +731,6 @@ package body Prj.Nmsc is ...@@ -716,11 +731,6 @@ package body Prj.Nmsc is
Id.Language := Lang_Id; Id.Language := Lang_Id;
Id.Kind := Kind; Id.Kind := Kind;
Id.Alternate_Languages := Alternate_Languages; Id.Alternate_Languages := Alternate_Languages;
Id.Other_Part := Other_Part;
if Other_Part /= No_Source then
Other_Part.Other_Part := Id;
end if;
-- Add the source id to the Unit_Sources_HT hash table, if the unit name -- Add the source id to the Unit_Sources_HT hash table, if the unit name
-- is not null. -- is not null.
...@@ -820,7 +830,8 @@ package body Prj.Nmsc is ...@@ -820,7 +830,8 @@ package body Prj.Nmsc is
Current_Dir : String; Current_Dir : String;
Proc_Data : in out Processing_Data; Proc_Data : in out Processing_Data;
Is_Config_File : Boolean; Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean) Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
is is
Extending : Boolean := False; Extending : Boolean := False;
...@@ -911,7 +922,8 @@ package body Prj.Nmsc is ...@@ -911,7 +922,8 @@ package body Prj.Nmsc is
-- Find the sources -- Find the sources
if Project.Source_Dirs /= Nil_String then if Project.Source_Dirs /= Nil_String then
Look_For_Sources (Project, In_Tree, Proc_Data); Look_For_Sources
(Project, In_Tree, Proc_Data, Allow_Duplicate_Basenames);
if Get_Mode = Ada_Only then if Get_Mode = Ada_Only then
...@@ -2533,6 +2545,7 @@ package body Prj.Nmsc is ...@@ -2533,6 +2545,7 @@ package body Prj.Nmsc is
Iter : Source_Iterator; Iter : Source_Iterator;
Source : Source_Id; Source : Source_Id;
Project_2 : Project_Id; Project_2 : Project_Id;
Other : Source_Id;
begin begin
if not Interfaces.Default then if not Interfaces.Default then
...@@ -2573,9 +2586,11 @@ package body Prj.Nmsc is ...@@ -2573,9 +2586,11 @@ package body Prj.Nmsc is
Source.In_Interfaces := True; Source.In_Interfaces := True;
Source.Declared_In_Interfaces := True; Source.Declared_In_Interfaces := True;
if Source.Other_Part /= No_Source then Other := Other_Part (Source);
Source.Other_Part.In_Interfaces := True;
Source.Other_Part.Declared_In_Interfaces := True; if Other /= No_Source then
Other.In_Interfaces := True;
Other.Declared_In_Interfaces := True;
end if; end if;
if Current_Verbosity = High then if Current_Verbosity = High then
...@@ -2971,7 +2986,6 @@ package body Prj.Nmsc is ...@@ -2971,7 +2986,6 @@ package body Prj.Nmsc is
Source : Source_Id; Source : Source_Id;
Source_To_Replace : Source_Id := No_Source; Source_To_Replace : Source_Id := No_Source;
Other_Project : Project_Id; Other_Project : Project_Id;
Other_Part : Source_Id := No_Source;
Iter : Source_Iterator; Iter : Source_Iterator;
begin begin
...@@ -3049,8 +3063,6 @@ package body Prj.Nmsc is ...@@ -3049,8 +3063,6 @@ package body Prj.Nmsc is
if Source /= No_Source then if Source /= No_Source then
if Source.Kind /= Kind then if Source.Kind /= Kind then
Other_Part := Source;
loop loop
Next (Iter); Next (Iter);
Source := Prj.Element (Iter); Source := Prj.Element (Iter);
...@@ -3066,10 +3078,6 @@ package body Prj.Nmsc is ...@@ -3066,10 +3078,6 @@ package body Prj.Nmsc is
Other_Project := Source.Project; Other_Project := Source.Project;
if Is_Extending (Project, Other_Project) then if Is_Extending (Project, Other_Project) then
Other_Part := Source.Other_Part;
-- Record the source to be removed
Source_To_Replace := Source; Source_To_Replace := Source;
Source := No_Source; Source := No_Source;
...@@ -3094,7 +3102,6 @@ package body Prj.Nmsc is ...@@ -3094,7 +3102,6 @@ package body Prj.Nmsc is
Kind => Kind, Kind => Kind,
File_Name => File_Name, File_Name => File_Name,
Display_File => File_Name_Type (Element.Value.Value), Display_File => File_Name_Type (Element.Value.Value),
Other_Part => Other_Part,
Unit => Unit, Unit => Unit,
Index => Index, Index => Index,
Naming_Exception => True, Naming_Exception => True,
...@@ -4661,9 +4668,9 @@ package body Prj.Nmsc is ...@@ -4661,9 +4668,9 @@ package body Prj.Nmsc is
if Source.Kind = Sep then if Source.Kind = Sep then
Source := No_Source; Source := No_Source;
elsif Source.Kind = Spec elsif Source.Kind = Spec
and then Source.Other_Part /= No_Source and then Other_Part (Source) /= No_Source
then then
Source := Source.Other_Part; Source := Other_Part (Source);
end if; end if;
end if; end if;
...@@ -4683,10 +4690,10 @@ package body Prj.Nmsc is ...@@ -4683,10 +4690,10 @@ package body Prj.Nmsc is
(Interfaces).Location); (Interfaces).Location);
else else
if Source.Kind = Spec and then if Source.Kind = Spec
Source.Other_Part /= No_Source and then Other_Part (Source) /= No_Source
then then
Source := Source.Other_Part; Source := Other_Part (Source);
end if; end if;
String_Element_Table.Increment_Last String_Element_Table.Increment_Last
...@@ -6760,7 +6767,8 @@ package body Prj.Nmsc is ...@@ -6760,7 +6767,8 @@ package body Prj.Nmsc is
procedure Find_Sources procedure Find_Sources
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
Proc_Data : in out Processing_Data) Proc_Data : in out Processing_Data;
Allow_Duplicate_Basenames : Boolean)
is is
Sources : constant Variable_Value := Sources : constant Variable_Value :=
Util.Value_Of Util.Value_Of
...@@ -6926,7 +6934,8 @@ package body Prj.Nmsc is ...@@ -6926,7 +6934,8 @@ package body Prj.Nmsc is
Search_Directories Search_Directories
(Project, In_Tree, (Project, In_Tree,
For_All_Sources => For_All_Sources =>
Sources.Default and then Source_List_File.Default); Sources.Default and then Source_List_File.Default,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames);
end if; end if;
-- Check if all exceptions have been found. For Ada, it is an error if -- Check if all exceptions have been found. For Ada, it is an error if
...@@ -7342,7 +7351,8 @@ package body Prj.Nmsc is ...@@ -7342,7 +7351,8 @@ package body Prj.Nmsc is
Path : Path_Name_Type; Path : Path_Name_Type;
File_Name : File_Name_Type; File_Name : File_Name_Type;
Display_File_Name : File_Name_Type; Display_File_Name : File_Name_Type;
For_All_Sources : Boolean) For_All_Sources : Boolean;
Allow_Duplicate_Basenames : Boolean)
is is
Canonical_Path : constant Path_Name_Type := Canonical_Path : constant Path_Name_Type :=
Path_Name_Type Path_Name_Type
...@@ -7353,7 +7363,6 @@ package body Prj.Nmsc is ...@@ -7353,7 +7363,6 @@ package body Prj.Nmsc is
Alternate_Languages : Language_List; Alternate_Languages : Language_List;
Language : Language_Ptr; Language : Language_Ptr;
Source : Source_Id; Source : Source_Id;
Other_Part : Source_Id;
Add_Src : Boolean; Add_Src : Boolean;
Src_Ind : Source_File_Index; Src_Ind : Source_File_Index;
Unit : Name_Id; Unit : Name_Id;
...@@ -7414,8 +7423,6 @@ package body Prj.Nmsc is ...@@ -7414,8 +7423,6 @@ package body Prj.Nmsc is
end if; end if;
if Check_Name then if Check_Name then
Other_Part := No_Source;
Check_File_Naming_Schemes Check_File_Naming_Schemes
(In_Tree => In_Tree, (In_Tree => In_Tree,
Project => Project, Project => Project,
...@@ -7457,7 +7464,7 @@ package body Prj.Nmsc is ...@@ -7457,7 +7464,7 @@ package body Prj.Nmsc is
or else or else
(Source.Kind = Impl and then Kind = Spec)) (Source.Kind = Impl and then Kind = Spec))
then then
Other_Part := Source; null; -- We found the "other_part (source)"
elsif (Unit /= No_Name elsif (Unit /= No_Name
and then Source.Unit /= No_Unit_Index and then Source.Unit /= No_Unit_Index
...@@ -7475,22 +7482,29 @@ package body Prj.Nmsc is ...@@ -7475,22 +7482,29 @@ package body Prj.Nmsc is
-- allowed if order of source directories is known. -- allowed if order of source directories is known.
if Project = Source.Project then if Project = Source.Project then
if Project.Known_Order_Of_Source_Dirs then if Unit = No_Name then
Add_Src := False; if Allow_Duplicate_Basenames then
Add_Src := True;
elsif Unit /= No_Name then elsif Project.Known_Order_Of_Source_Dirs then
Error_Msg_Name_1 := Unit; Add_Src := False;
Error_Msg else
(Project, In_Tree, "duplicate unit %%", Error_Msg_File_1 := File_Name;
No_Location); Error_Msg
Add_Src := False; (Project, In_Tree, "duplicate source file name {",
No_Location);
Add_Src := False;
end if;
else else
Error_Msg_File_1 := File_Name; if Project.Known_Order_Of_Source_Dirs then
Error_Msg Add_Src := False;
(Project, In_Tree, "duplicate source file name {", else
No_Location); Error_Msg_Name_1 := Unit;
Add_Src := False; Error_Msg
(Project, In_Tree, "duplicate unit %%",
No_Location);
Add_Src := False;
end if;
end if; end if;
-- Do not allow the same unit name in different projects, -- Do not allow the same unit name in different projects,
...@@ -7539,7 +7553,6 @@ package body Prj.Nmsc is ...@@ -7539,7 +7553,6 @@ package body Prj.Nmsc is
Alternate_Languages => Alternate_Languages, Alternate_Languages => Alternate_Languages,
File_Name => File_Name, File_Name => File_Name,
Display_File => Display_File_Name, Display_File => Display_File_Name,
Other_Part => Other_Part,
Unit => Unit, Unit => Unit,
Path => (Canonical_Path, Path), Path => (Canonical_Path, Path),
Source_To_Replace => Source_To_Replace); Source_To_Replace => Source_To_Replace);
...@@ -7555,7 +7568,8 @@ package body Prj.Nmsc is ...@@ -7555,7 +7568,8 @@ package body Prj.Nmsc is
procedure Search_Directories procedure Search_Directories
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
For_All_Sources : Boolean) For_All_Sources : Boolean;
Allow_Duplicate_Basenames : Boolean)
is is
Source_Dir : String_List_Id; Source_Dir : String_List_Id;
Element : String_Element; Element : String_Element;
...@@ -7663,7 +7677,9 @@ package body Prj.Nmsc is ...@@ -7663,7 +7677,9 @@ package body Prj.Nmsc is
Path => Path, Path => Path,
File_Name => File_Name, File_Name => File_Name,
Display_File_Name => Display_File_Name, Display_File_Name => Display_File_Name,
For_All_Sources => For_All_Sources); For_All_Sources => For_All_Sources,
Allow_Duplicate_Basenames =>
Allow_Duplicate_Basenames);
end if; end if;
end; end;
end if; end if;
...@@ -7761,7 +7777,8 @@ package body Prj.Nmsc is ...@@ -7761,7 +7777,8 @@ package body Prj.Nmsc is
procedure Look_For_Sources procedure Look_For_Sources
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
Proc_Data : in out Processing_Data) Proc_Data : in out Processing_Data;
Allow_Duplicate_Basenames : Boolean)
is is
Iter : Source_Iterator; Iter : Source_Iterator;
...@@ -7914,7 +7931,7 @@ package body Prj.Nmsc is ...@@ -7914,7 +7931,7 @@ package body Prj.Nmsc is
else else
case Src_Id.Kind is case Src_Id.Kind is
when Spec => when Spec =>
if Src_Id.Other_Part = No_Source then if Other_Part (Src_Id) = No_Source then
Check_Object (Src_Id); Check_Object (Src_Id);
end if; end if;
...@@ -7922,7 +7939,7 @@ package body Prj.Nmsc is ...@@ -7922,7 +7939,7 @@ package body Prj.Nmsc is
null; null;
when Impl => when Impl =>
if Src_Id.Other_Part /= No_Source then if Other_Part (Src_Id) /= No_Source then
Check_Object (Src_Id); Check_Object (Src_Id);
else else
...@@ -7966,7 +7983,7 @@ package body Prj.Nmsc is ...@@ -7966,7 +7983,7 @@ package body Prj.Nmsc is
Load_Naming_Exceptions (Project, In_Tree); Load_Naming_Exceptions (Project, In_Tree);
end if; end if;
Find_Sources (Project, In_Tree, Proc_Data); Find_Sources (Project, In_Tree, Proc_Data, Allow_Duplicate_Basenames);
Mark_Excluded_Sources; Mark_Excluded_Sources;
if Get_Mode = Multi_Language then if Get_Mode = Multi_Language then
...@@ -8198,8 +8215,7 @@ package body Prj.Nmsc is ...@@ -8198,8 +8215,7 @@ package body Prj.Nmsc is
Path => (Canonical_Path, Path_Name), Path => (Canonical_Path, Path_Name),
Naming_Exception => Needs_Pragma, Naming_Exception => Needs_Pragma,
Kind => Unit_Kind, Kind => Unit_Kind,
Index => Unit_Ind, Index => Unit_Ind);
Other_Part => No_Source); -- ??? Can we find file ?
Source_Recorded := True; Source_Recorded := True;
end if; end if;
end Record_Unit; end Record_Unit;
......
...@@ -48,7 +48,8 @@ private package Prj.Nmsc is ...@@ -48,7 +48,8 @@ private package Prj.Nmsc is
Current_Dir : String; Current_Dir : String;
Proc_Data : in out Processing_Data; Proc_Data : in out Processing_Data;
Is_Config_File : Boolean; Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean); Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean);
-- Perform consistency and semantic checks on a project, starting from the -- Perform consistency and semantic checks on a project, starting from the
-- project tree parsed from the .gpr file. This procedure interprets the -- project tree parsed from the .gpr file. This procedure interprets the
-- various case statements in the project based on the current environment -- various case statements in the project based on the current environment
...@@ -74,6 +75,9 @@ private package Prj.Nmsc is ...@@ -74,6 +75,9 @@ private package Prj.Nmsc is
-- If Compiler_Driver_Mandatory is true, then a Compiler.Driver attribute -- If Compiler_Driver_Mandatory is true, then a Compiler.Driver attribute
-- for each language must be defined, or we will not look for its source -- for each language must be defined, or we will not look for its source
-- files. -- files.
-- 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)
private private
type Processing_Data is record type Processing_Data is record
......
...@@ -84,11 +84,15 @@ package body Prj.Proc is ...@@ -84,11 +84,15 @@ package body Prj.Proc is
Current_Dir : String; Current_Dir : String;
When_No_Sources : Error_Warning; When_No_Sources : Error_Warning;
Is_Config_File : Boolean; Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean); Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean);
-- Set all projects to not checked, then call Recursive_Check for the -- Set all projects to not checked, then call Recursive_Check for the
-- main project Project. Project is set to No_Project if errors occurred. -- main project Project. Project is set to No_Project if errors occurred.
-- Current_Dir is for optimization purposes, avoiding extra system calls. -- Current_Dir is for optimization purposes, avoiding extra system calls.
-- Is_Config_File should be True if Project is a config file (.cgpr). -- Is_Config_File should be True if Project is a config file (.cgpr).
-- 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)
procedure Copy_Package_Declarations procedure Copy_Package_Declarations
(From : Declarations; (From : Declarations;
...@@ -154,6 +158,7 @@ package body Prj.Proc is ...@@ -154,6 +158,7 @@ package body Prj.Proc is
Proc_Data : Processing_Data; Proc_Data : Processing_Data;
Is_Config_File : Boolean; Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean; Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean;
end record; end record;
-- Data passed to Recursive_Check -- Data passed to Recursive_Check
-- Current_Dir is for optimization purposes, avoiding extra system calls. -- Current_Dir is for optimization purposes, avoiding extra system calls.
...@@ -285,7 +290,8 @@ package body Prj.Proc is ...@@ -285,7 +290,8 @@ package body Prj.Proc is
Current_Dir : String; Current_Dir : String;
When_No_Sources : Error_Warning; When_No_Sources : Error_Warning;
Is_Config_File : Boolean; Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean) Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
is is
Dir : aliased String := Current_Dir; Dir : aliased String := Current_Dir;
...@@ -300,6 +306,7 @@ package body Prj.Proc is ...@@ -300,6 +306,7 @@ package body Prj.Proc is
Data.When_No_Sources := When_No_Sources; Data.When_No_Sources := When_No_Sources;
Data.Is_Config_File := Is_Config_File; Data.Is_Config_File := Is_Config_File;
Data.Compiler_Driver_Mandatory := Compiler_Driver_Mandatory; Data.Compiler_Driver_Mandatory := Compiler_Driver_Mandatory;
Data.Allow_Duplicate_Basenames := Allow_Duplicate_Basenames;
Initialize (Data.Proc_Data); Initialize (Data.Proc_Data);
...@@ -330,8 +337,6 @@ package body Prj.Proc is ...@@ -330,8 +337,6 @@ package body Prj.Proc is
else else
Unit_Htable.Remove (Name); Unit_Htable.Remove (Name);
Source1.Other_Part := Source2;
Source2.Other_Part := Source1;
end if; end if;
end if; end if;
...@@ -1263,6 +1268,7 @@ package body Prj.Proc is ...@@ -1263,6 +1268,7 @@ package body Prj.Proc is
When_No_Sources => When_No_Sources, When_No_Sources => When_No_Sources,
Current_Dir => Current_Dir, Current_Dir => Current_Dir,
Compiler_Driver_Mandatory => True, Compiler_Driver_Mandatory => True,
Allow_Duplicate_Basenames => False,
Is_Config_File => Is_Config_File); Is_Config_File => Is_Config_File);
end if; end if;
end Process; end Process;
...@@ -2318,7 +2324,8 @@ package body Prj.Proc is ...@@ -2318,7 +2324,8 @@ package body Prj.Proc is
When_No_Sources : Error_Warning := Error; When_No_Sources : Error_Warning := Error;
Current_Dir : String; Current_Dir : String;
Is_Config_File : Boolean; Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean) Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
is is
Obj_Dir : Path_Name_Type; Obj_Dir : Path_Name_Type;
Extending : Project_Id; Extending : Project_Id;
...@@ -2334,7 +2341,8 @@ package body Prj.Proc is ...@@ -2334,7 +2341,8 @@ package body Prj.Proc is
if Project /= No_Project then if Project /= No_Project then
Check (In_Tree, Project, Current_Dir, When_No_Sources, Check (In_Tree, Project, Current_Dir, When_No_Sources,
Is_Config_File => Is_Config_File, Is_Config_File => Is_Config_File,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory); Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames);
end if; end if;
-- If main project is an extending all project, set the object -- If main project is an extending all project, set the object
...@@ -2459,7 +2467,8 @@ package body Prj.Proc is ...@@ -2459,7 +2467,8 @@ package body Prj.Proc is
(Project, Data.In_Tree, Error_Report, Data.When_No_Sources, (Project, Data.In_Tree, Error_Report, Data.When_No_Sources,
Data.Current_Dir.all, Data.Proc_Data, Data.Current_Dir.all, Data.Proc_Data,
Compiler_Driver_Mandatory => Data.Compiler_Driver_Mandatory, Compiler_Driver_Mandatory => Data.Compiler_Driver_Mandatory,
Is_Config_File => Data.Is_Config_File); Is_Config_File => Data.Is_Config_File,
Allow_Duplicate_Basenames => Data.Allow_Duplicate_Basenames);
end Recursive_Check; end Recursive_Check;
----------------------- -----------------------
......
...@@ -67,7 +67,8 @@ package Prj.Proc is ...@@ -67,7 +67,8 @@ package Prj.Proc is
When_No_Sources : Error_Warning := Error; When_No_Sources : Error_Warning := Error;
Current_Dir : String; Current_Dir : String;
Is_Config_File : Boolean; Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean); Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean);
-- Perform the second phase of the processing, filling the rest of the -- Perform the second phase of the processing, filling the rest of the
-- project with the information extracted from the project tree. This phase -- project with the information extracted from the project tree. This phase
-- requires that the configuration file has already been parsed (in fact -- requires that the configuration file has already been parsed (in fact
...@@ -78,6 +79,10 @@ package Prj.Proc is ...@@ -78,6 +79,10 @@ package Prj.Proc is
-- Current_Dir is for optimization purposes, avoiding extra system calls. -- Current_Dir is for optimization purposes, avoiding extra system calls.
-- --
-- Is_Config_File should be true if Project is a config file (.cgpr) -- Is_Config_File should be true if Project is a config file (.cgpr)
--
-- 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)
procedure Process procedure Process
(In_Tree : Project_Tree_Ref; (In_Tree : Project_Tree_Ref;
......
...@@ -308,7 +308,8 @@ package Prj is ...@@ -308,7 +308,8 @@ package Prj is
-- Constant indicating that there is no language data -- Constant indicating that there is no language data
function Get_Language_From_Name function Get_Language_From_Name
(Project : Project_Id; Name : String) return Language_Ptr; (Project : Project_Id;
Name : String) return Language_Ptr;
-- Get a language from a project. This might return null if no such -- Get a language from a project. This might return null if no such
-- language exists in the project -- language exists in the project
...@@ -399,8 +400,13 @@ package Prj is ...@@ -399,8 +400,13 @@ package Prj is
function Is_Compilable (Source : Source_Id) return Boolean; function Is_Compilable (Source : Source_Id) return Boolean;
pragma Inline (Is_Compilable); pragma Inline (Is_Compilable);
-- Return True if we know how to compile Source (ie if a compiler is -- Return True if we know how to compile Source (i.e. if a compiler is
-- defined). This doesn't indicate whether the source should be compiled -- defined). This doesn't indicate whether the source should be compiled.
function Other_Part (Source : Source_Id) return Source_Id;
pragma Inline (Other_Part);
-- Source ID for the other part, if any: for a spec, indicates its body;
-- for a body, indicates its spec.
No_Source : constant Source_Id := null; No_Source : constant Source_Id := null;
...@@ -638,103 +644,102 @@ package Prj is ...@@ -638,103 +644,102 @@ package Prj is
-- GNAT Project File(s). -- GNAT Project File(s).
type Source_Data is record type Source_Data is record
Project : Project_Id := No_Project; Project : Project_Id := No_Project;
-- Project of the source -- Project of the source
Language : Language_Ptr := No_Language_Index; Language : Language_Ptr := No_Language_Index;
-- Index of the language. This is an index into -- Index of the language. This is an index into
-- Project_Tree.Languages_Data. -- Project_Tree.Languages_Data.
In_Interfaces : Boolean := True; In_Interfaces : Boolean := True;
-- False when the source is not included in interfaces, when attribute -- False when the source is not included in interfaces, when attribute
-- Interfaces is declared. -- Interfaces is declared.
Declared_In_Interfaces : Boolean := False; Declared_In_Interfaces : Boolean := False;
-- True when source is declared in attribute Interfaces -- True when source is declared in attribute Interfaces
Alternate_Languages : Language_List; Alternate_Languages : Language_List;
-- List of languages a header file may also be, in addition of language -- List of languages a header file may also be, in addition of language
-- Language_Name. -- Language_Name.
Kind : Source_Kind := Spec; Kind : Source_Kind := Spec;
-- Kind of the source: spec, body or subunit -- Kind of the source: spec, body or subunit
Other_Part : Source_Id := No_Source; Unit : Unit_Index := No_Unit_Index;
-- Source ID for the other part, if any: for a spec, indicates its body;
-- for a body, indicates its spec.
Unit : Unit_Index := No_Unit_Index;
-- Name of the unit, if language is unit based -- Name of the unit, if language is unit based
Index : Int := 0; Index : Int := 0;
-- Index of the source in a multi unit source file -- Index of the source in a multi unit source file (the same Source_Data
-- is duplicated several times when there are several units in the same
-- file). Index is 0 if there is either no unit or a single one, and
-- starts at 1 when there are multiple units
Locally_Removed : Boolean := False; Locally_Removed : Boolean := False;
-- True if the source has been "excluded" -- True if the source has been "excluded"
Get_Object : Boolean := False; Get_Object : Boolean := False;
-- Indicates that the object of the source should be put in the global -- Indicates that the object of the source should be put in the global
-- archive. This is for Ada, when only the closure of a main needs to -- archive. This is for Ada, when only the closure of a main needs to
-- be compiled/recompiled. -- be compiled/recompiled.
Replaced_By : Source_Id := No_Source; Replaced_By : Source_Id := No_Source;
File : File_Name_Type := No_File; File : File_Name_Type := No_File;
-- Canonical file name of the source -- Canonical file name of the source
Display_File : File_Name_Type := No_File; Display_File : File_Name_Type := No_File;
-- File name of the source, for display purposes -- File name of the source, for display purposes
Path : Path_Information := No_Path_Information; Path : Path_Information := No_Path_Information;
-- Path name of the source -- Path name of the source
-- Path.Name is set to Slash for an excluded file that does not belong -- Path.Name is set to Slash for an excluded file that does not belong
-- in the project in fact -- in the project in fact
Source_TS : Time_Stamp_Type := Empty_Time_Stamp; Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- Time stamp of the source file -- Time stamp of the source file
Object_Project : Project_Id := No_Project; Object_Project : Project_Id := No_Project;
-- Project where the object file is. This might be different from -- Project where the object file is. This might be different from
-- Project when using extending project files. -- Project when using extending project files.
Object : File_Name_Type := No_File; Object : File_Name_Type := No_File;
-- File name of the object file -- File name of the object file
Current_Object_Path : Path_Name_Type := No_Path; Current_Object_Path : Path_Name_Type := No_Path;
-- Object path of an existing object file -- Object path of an existing object file
Object_Path : Path_Name_Type := No_Path; Object_Path : Path_Name_Type := No_Path;
-- Object path of the real object file -- Object path of the real object file
Object_TS : Time_Stamp_Type := Empty_Time_Stamp; Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- Object file time stamp -- Object file time stamp
Dep_Name : File_Name_Type := No_File; Dep_Name : File_Name_Type := No_File;
-- Dependency file simple name -- Dependency file simple name
Current_Dep_Path : Path_Name_Type := No_Path; Current_Dep_Path : Path_Name_Type := No_Path;
-- Path name of an existing dependency file -- Path name of an existing dependency file
Dep_Path : Path_Name_Type := No_Path; Dep_Path : Path_Name_Type := No_Path;
-- Path name of the real dependency file -- Path name of the real dependency file
Dep_TS : Time_Stamp_Type := Empty_Time_Stamp; Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- Dependency file time stamp -- Dependency file time stamp
Switches : File_Name_Type := No_File; Switches : File_Name_Type := No_File;
-- File name of the switches file. For all languages, this is a file -- File name of the switches file. For all languages, this is a file
-- that ends with the .cswi extension. -- that ends with the .cswi extension.
Switches_Path : Path_Name_Type := No_Path; Switches_Path : Path_Name_Type := No_Path;
-- Path name of the switches file -- Path name of the switches file
Switches_TS : Time_Stamp_Type := Empty_Time_Stamp; Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- Switches file time stamp -- Switches file time stamp
Naming_Exception : Boolean := False; Naming_Exception : Boolean := False;
-- True if the source has an exceptional name -- True if the source has an exceptional name
Next_In_Lang : Source_Id := No_Source; Next_In_Lang : Source_Id := No_Source;
-- Link to another source of the same language in the same project -- Link to another source of the same language in the same project
end record; end record;
...@@ -745,7 +750,6 @@ package Prj is ...@@ -745,7 +750,6 @@ package Prj is
Declared_In_Interfaces => False, Declared_In_Interfaces => False,
Alternate_Languages => null, Alternate_Languages => null,
Kind => Spec, Kind => Spec,
Other_Part => No_Source,
Unit => No_Unit_Index, Unit => No_Unit_Index,
Index => 0, Index => 0,
Locally_Removed => False, Locally_Removed => False,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment