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.
......
...@@ -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