Commit fdd7e7bb by Emmanuel Briot Committed by Arnaud Charlet

prj-proc.adb, [...]: Remove all remaining global variables and tables in prj-nmsc.adb.

2009-07-13  Emmanuel Briot  <briot@adacore.com>

	* prj-proc.adb, prj-proc.ads, prj.ads, prj-nmsc.adb, prj-nmsc.ads,
	prj-pars.adb, prj-conf.adb, prj-conf.ads: Remove all remaining global
	variables and tables in prj-nmsc.adb.
	(Tree_Processing_Data): Renames Processing_Data, some new fields added
	(Project_Processing_Data): New record
	Simplify/unify check for missing sources.

From-SVN: r149558
parent fc2c32e2
2009-07-13 Emmanuel Briot <briot@adacore.com> 2009-07-13 Emmanuel Briot <briot@adacore.com>
* prj-proc.adb, prj-proc.ads, prj.ads, prj-nmsc.adb, prj-nmsc.ads,
prj-pars.adb, prj-conf.adb, prj-conf.ads: Remove all remaining global
variables and tables in prj-nmsc.adb.
(Tree_Processing_Data): Renames Processing_Data, some new fields added
(Project_Processing_Data): New record
Simplify/unify check for missing sources.
2009-07-13 Emmanuel Briot <briot@adacore.com>
* gnatcmd.adb, make.adb, mlib-prj.adb, prj-part.adb, mlib.adb, * gnatcmd.adb, make.adb, mlib-prj.adb, prj-part.adb, mlib.adb,
prj.adb, prj.ads, clean.adb, prj-nmsc.adb, prj-nmsc.ads, prj-pars.adb, prj.adb, prj.ads, clean.adb, prj-nmsc.adb, prj-nmsc.ads, prj-pars.adb,
prj-pars.ads, prj-conf.adb, prj-conf.ads, prj-tree.adb, prj-pars.ads, prj-conf.adb, prj-conf.ads, prj-tree.adb,
......
...@@ -909,6 +909,7 @@ package body Prj.Conf is ...@@ -909,6 +909,7 @@ package body Prj.Conf is
Compiler_Driver_Mandatory : Boolean := True; Compiler_Driver_Mandatory : Boolean := True;
Allow_Duplicate_Basenames : Boolean := False; Allow_Duplicate_Basenames : Boolean := False;
Reset_Tree : Boolean := True; Reset_Tree : Boolean := True;
Require_Sources_Other_Lang : Boolean := True;
When_No_Sources : Error_Warning := Warning) When_No_Sources : Error_Warning := Warning)
is is
Main_Config_Project : Project_Id; Main_Config_Project : Project_Id;
...@@ -954,17 +955,17 @@ package body Prj.Conf is ...@@ -954,17 +955,17 @@ package body Prj.Conf is
-- Finish processing the user's project -- Finish processing the user's project
Prj.Proc.Process_Project_Tree_Phase_2 Prj.Proc.Process_Project_Tree_Phase_2
(In_Tree => Project_Tree, (In_Tree => Project_Tree,
Project => Main_Project, Project => Main_Project,
Success => Success, Success => Success,
From_Project_Node => User_Project_Node, From_Project_Node => User_Project_Node,
From_Project_Node_Tree => Project_Node_Tree, From_Project_Node_Tree => Project_Node_Tree,
Report_Error => Report_Error, Report_Error => Report_Error,
Current_Dir => Current_Directory, Current_Dir => Current_Directory,
When_No_Sources => When_No_Sources, When_No_Sources => When_No_Sources,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory, Require_Sources_Other_Lang => Require_Sources_Other_Lang,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames, Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Is_Config_File => False); Allow_Duplicate_Basenames => Allow_Duplicate_Basenames);
if not Success then if not Success then
Main_Project := No_Project; Main_Project := No_Project;
......
...@@ -101,6 +101,7 @@ package Prj.Conf is ...@@ -101,6 +101,7 @@ package Prj.Conf is
Compiler_Driver_Mandatory : Boolean := True; Compiler_Driver_Mandatory : Boolean := True;
Allow_Duplicate_Basenames : Boolean := False; Allow_Duplicate_Basenames : Boolean := False;
Reset_Tree : Boolean := True; Reset_Tree : Boolean := True;
Require_Sources_Other_Lang : Boolean := True;
When_No_Sources : Error_Warning := Warning); When_No_Sources : Error_Warning := Warning);
-- 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
...@@ -108,6 +109,10 @@ package Prj.Conf is ...@@ -108,6 +109,10 @@ package Prj.Conf is
-- If Reset_Tree is true, all projects are first removed from the tree. -- If Reset_Tree is true, all projects are first removed from the tree.
-- When_No_Sources indicates what should be done when no sources are found -- When_No_Sources indicates what should be done when no sources are found
-- for one of the languages of the project. -- for one of the languages of the project.
-- If Require_Sources_Other_Lang is true, then all languages must have at
-- least one source file, or an error is reported via When_No_Sources. If
-- it is false, this is only required for Ada (and only if it is a language
-- of the project).
Invalid_Config : exception; Invalid_Config : exception;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -25,31 +25,48 @@ ...@@ -25,31 +25,48 @@
-- Perform various checks on a project and find all its source files -- Perform various checks on a project and find all its source files
with GNAT.Dynamic_HTables;
private package Prj.Nmsc is private package Prj.Nmsc is
type Processing_Data is private; type Tree_Processing_Data is private;
-- Temporary data which is needed while parsing a project. It does not need -- Temporary data which is needed while parsing a project. It does not need
-- to be kept in memory once a project has been fully loaded, but is -- to be kept in memory once a project has been fully loaded, but is
-- necessary while performing consistency checks (duplicate sources,...) -- necessary while performing consistency checks (duplicate sources,...)
-- This data must be initialized before processing any project, and the -- This data must be initialized before processing any project, and the
-- same data is used for processing all projects in the tree. -- same data is used for processing all projects in the tree.
procedure Initialize (Proc_Data : in out Processing_Data); procedure Initialize
-- Initialize Proc_Data (Data : out Tree_Processing_Data;
Tree : Project_Tree_Ref;
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning;
Require_Sources_Other_Lang : Boolean := True;
Allow_Duplicate_Basenames : Boolean := True;
Compiler_Driver_Mandatory : Boolean := False);
-- Initialize Data
-- 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)
-- 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
-- files.
-- When_No_Sources indicates what should be done when no sources of a
-- language are found in a project where this language is declared.
-- If Require_Sources_Other_Lang is true, then all languages must have at
-- least one source file, or an error is reported via When_No_Sources. If
-- it is false, this is only required for Ada (and only if it is a language
-- of the project).
-- If Report_Error is null, use the standard error reporting mechanism
-- (Errout). Otherwise, report errors using Report_Error.
procedure Free (Proc_Data : in out Processing_Data); procedure Free (Data : in out Tree_Processing_Data);
-- Free the memory occupied by Proc_Data -- Free the memory occupied by Data
procedure Check procedure Check
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; Current_Dir : String;
Report_Error : Put_Line_Access; Data : in out Tree_Processing_Data);
When_No_Sources : Error_Warning;
Current_Dir : String;
Proc_Data : in out Processing_Data;
Is_Config_File : 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
...@@ -61,28 +78,32 @@ private package Prj.Nmsc is ...@@ -61,28 +78,32 @@ private package Prj.Nmsc is
-- is Ada_Only, this procedure will only search Ada sources, but in multi- -- is Ada_Only, this procedure will only search Ada sources, but in multi-
-- language mode it will look for sources for all supported languages. -- language mode it will look for sources for all supported languages.
-- --
-- If Report_Error is null, use the standard error reporting mechanism
-- (Errout). Otherwise, report errors using Report_Error.
--
-- Current_Dir is for optimization purposes only, avoiding system calls to -- Current_Dir is for optimization purposes only, avoiding system calls to
-- query it. -- query it.
--
-- When_No_Sources indicates what should be done when no sources of a
-- language are found in a project where this language is declared.
--
-- Is_Config_File should be True if Project is config file (.cgpr)
--
-- 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
-- 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
Units : Files_Htable.Instance; package Files_Htable is new GNAT.Dynamic_HTables.Simple_HTable
-- Mapping from file base name to the Source_Id of the file (Header_Num => Header_Num,
Element => Source_Id,
No_Element => No_Source,
Key => File_Name_Type,
Hash => Hash,
Equal => "=");
-- Mapping from base file names to Source_Id (containing full info about
-- the source)
type Tree_Processing_Data is record
Tree : Project_Tree_Ref;
-- The data applies when parsing this tree
File_To_Source : Files_Htable.Instance;
Require_Sources_Other_Lang : Boolean;
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning;
Allow_Duplicate_Basenames : Boolean := True;
Compiler_Driver_Mandatory : Boolean := False;
-- See comments for Initialize
end record; end record;
end Prj.Nmsc; end Prj.Nmsc;
...@@ -94,6 +94,7 @@ package body Prj.Pars is ...@@ -94,6 +94,7 @@ package body Prj.Pars is
Normalized_Hostname => "", Normalized_Hostname => "",
Compiler_Driver_Mandatory => False, Compiler_Driver_Mandatory => False,
Allow_Duplicate_Basenames => False, Allow_Duplicate_Basenames => False,
Require_Sources_Other_Lang => False,
On_Load_Config => On_Load_Config =>
Add_Default_GNAT_Naming_Scheme'Access, Add_Default_GNAT_Naming_Scheme'Access,
Reset_Tree => Reset_Tree, Reset_Tree => Reset_Tree,
......
...@@ -79,17 +79,16 @@ package body Prj.Proc is ...@@ -79,17 +79,16 @@ package body Prj.Proc is
-- the package or project with declarations Decl. -- the package or project with declarations Decl.
procedure Check procedure Check
(In_Tree : Project_Tree_Ref; (In_Tree : Project_Tree_Ref;
Project : Project_Id; Project : Project_Id;
Current_Dir : String; Current_Dir : String;
When_No_Sources : Error_Warning; When_No_Sources : Error_Warning;
Is_Config_File : Boolean; Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean; Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : 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).
-- If Allow_Duplicate_Basenames, then files with the same base names are -- If Allow_Duplicate_Basenames, then files with the same base names are
-- authorized within a project for source-based languages (never for unit -- authorized within a project for source-based languages (never for unit
-- based languages) -- based languages)
...@@ -152,13 +151,8 @@ package body Prj.Proc is ...@@ -152,13 +151,8 @@ package body Prj.Proc is
-- project. -- project.
type Recursive_Check_Data is record type Recursive_Check_Data is record
In_Tree : Project_Tree_Ref;
Current_Dir : String_Access; Current_Dir : String_Access;
When_No_Sources : Error_Warning; Proc_Data : Tree_Processing_Data;
Proc_Data : Processing_Data;
Is_Config_File : 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,13 +279,13 @@ package body Prj.Proc is ...@@ -285,13 +279,13 @@ package body Prj.Proc is
----------- -----------
procedure Check procedure Check
(In_Tree : Project_Tree_Ref; (In_Tree : Project_Tree_Ref;
Project : Project_Id; Project : Project_Id;
Current_Dir : String; Current_Dir : String;
When_No_Sources : Error_Warning; When_No_Sources : Error_Warning;
Is_Config_File : Boolean; Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean; Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean) Allow_Duplicate_Basenames : Boolean)
is is
Dir : aliased String := Current_Dir; Dir : aliased String := Current_Dir;
...@@ -301,14 +295,16 @@ package body Prj.Proc is ...@@ -301,14 +295,16 @@ package body Prj.Proc is
Data : Recursive_Check_Data; Data : Recursive_Check_Data;
begin begin
Data.In_Tree := In_Tree;
Data.Current_Dir := Dir'Unchecked_Access; Data.Current_Dir := Dir'Unchecked_Access;
Data.When_No_Sources := When_No_Sources;
Data.Is_Config_File := Is_Config_File;
Data.Compiler_Driver_Mandatory := Compiler_Driver_Mandatory;
Data.Allow_Duplicate_Basenames := Allow_Duplicate_Basenames;
Initialize (Data.Proc_Data); Initialize
(Data.Proc_Data,
Tree => In_Tree,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames,
Require_Sources_Other_Lang => Require_Sources_Other_Lang,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
When_No_Sources => When_No_Sources,
Report_Error => null);
Check_All_Projects (Project, Data, Imported_First => True); Check_All_Projects (Project, Data, Imported_First => True);
...@@ -1244,8 +1240,7 @@ package body Prj.Proc is ...@@ -1244,8 +1240,7 @@ package body Prj.Proc is
Report_Error : Put_Line_Access; Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error; When_No_Sources : Error_Warning := Error;
Reset_Tree : Boolean := True; Reset_Tree : Boolean := True;
Current_Dir : String := ""; Current_Dir : String := "")
Is_Config_File : Boolean)
is is
begin begin
Process_Project_Tree_Phase_1 Process_Project_Tree_Phase_1
...@@ -1257,19 +1252,21 @@ package body Prj.Proc is ...@@ -1257,19 +1252,21 @@ package body Prj.Proc is
Report_Error => Report_Error, Report_Error => Report_Error,
Reset_Tree => Reset_Tree); Reset_Tree => Reset_Tree);
if not Is_Config_File then if Project_Qualifier_Of (From_Project_Node, From_Project_Node_Tree) /=
Configuration
then
Process_Project_Tree_Phase_2 Process_Project_Tree_Phase_2
(In_Tree => In_Tree, (In_Tree => In_Tree,
Project => Project, Project => Project,
Success => Success, Success => Success,
From_Project_Node => From_Project_Node, From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree, From_Project_Node_Tree => From_Project_Node_Tree,
Report_Error => Report_Error, Report_Error => Report_Error,
When_No_Sources => When_No_Sources, When_No_Sources => When_No_Sources,
Current_Dir => Current_Dir, Current_Dir => Current_Dir,
Compiler_Driver_Mandatory => True, Require_Sources_Other_Lang => False,
Allow_Duplicate_Basenames => False, Compiler_Driver_Mandatory => True,
Is_Config_File => Is_Config_File); Allow_Duplicate_Basenames => False);
end if; end if;
end Process; end Process;
...@@ -2315,17 +2312,17 @@ package body Prj.Proc is ...@@ -2315,17 +2312,17 @@ package body Prj.Proc is
---------------------------------- ----------------------------------
procedure Process_Project_Tree_Phase_2 procedure Process_Project_Tree_Phase_2
(In_Tree : Project_Tree_Ref; (In_Tree : Project_Tree_Ref;
Project : Project_Id; Project : Project_Id;
Success : out Boolean; Success : out Boolean;
From_Project_Node : Project_Node_Id; From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref; From_Project_Node_Tree : Project_Node_Tree_Ref;
Report_Error : Put_Line_Access; Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error; When_No_Sources : Error_Warning := Error;
Current_Dir : String; Current_Dir : String;
Is_Config_File : Boolean; Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean; Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean) Allow_Duplicate_Basenames : Boolean)
is is
Obj_Dir : Path_Name_Type; Obj_Dir : Path_Name_Type;
Extending : Project_Id; Extending : Project_Id;
...@@ -2341,9 +2338,9 @@ package body Prj.Proc is ...@@ -2341,9 +2338,9 @@ 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, Require_Sources_Other_Lang => Require_Sources_Other_Lang,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory, Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames); 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
...@@ -2464,12 +2461,7 @@ package body Prj.Proc is ...@@ -2464,12 +2461,7 @@ package body Prj.Proc is
Write_Line (""""); Write_Line ("""");
end if; end if;
Prj.Nmsc.Check Prj.Nmsc.Check (Project, Data.Current_Dir.all, Data.Proc_Data);
(Project, Data.In_Tree, Error_Report, Data.When_No_Sources,
Data.Current_Dir.all, Data.Proc_Data,
Compiler_Driver_Mandatory => Data.Compiler_Driver_Mandatory,
Is_Config_File => Data.Is_Config_File,
Allow_Duplicate_Basenames => Data.Allow_Duplicate_Basenames);
end Recursive_Check; end Recursive_Check;
----------------------- -----------------------
......
...@@ -58,17 +58,17 @@ package Prj.Proc is ...@@ -58,17 +58,17 @@ package Prj.Proc is
-- project table before processing. -- project table before processing.
procedure Process_Project_Tree_Phase_2 procedure Process_Project_Tree_Phase_2
(In_Tree : Project_Tree_Ref; (In_Tree : Project_Tree_Ref;
Project : Project_Id; Project : Project_Id;
Success : out Boolean; Success : out Boolean;
From_Project_Node : Project_Node_Id; From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref; From_Project_Node_Tree : Project_Node_Tree_Ref;
Report_Error : Put_Line_Access; Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error; When_No_Sources : Error_Warning := Error;
Current_Dir : String; Current_Dir : String;
Is_Config_File : Boolean; Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean; Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : 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,8 +78,6 @@ package Prj.Proc is ...@@ -78,8 +78,6 @@ 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)
--
-- If Allow_Duplicate_Basenames, then files with the same base names are -- If Allow_Duplicate_Basenames, then files with the same base names are
-- authorized within a project for source-based languages (never for unit -- authorized within a project for source-based languages (never for unit
-- based languages) -- based languages)
...@@ -93,8 +91,7 @@ package Prj.Proc is ...@@ -93,8 +91,7 @@ package Prj.Proc is
Report_Error : Put_Line_Access; Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error; When_No_Sources : Error_Warning := Error;
Reset_Tree : Boolean := True; Reset_Tree : Boolean := True;
Current_Dir : String := ""; Current_Dir : String := "");
Is_Config_File : Boolean);
-- Performs the two phases of the processing -- Performs the two phases of the processing
end Prj.Proc; end Prj.Proc;
...@@ -1268,15 +1268,6 @@ package Prj is ...@@ -1268,15 +1268,6 @@ package Prj is
Equal => "="); Equal => "=");
-- Mapping of unit names to indexes in the Units table -- Mapping of unit names to indexes in the Units table
package Files_Htable is new Simple_HTable
(Header_Num => Header_Num,
Element => Source_Id,
No_Element => No_Source,
Key => File_Name_Type,
Hash => Hash,
Equal => "=");
-- Mapping of file names to indexes in the Units table
--------------------- ---------------------
-- Source_Iterator -- -- Source_Iterator --
--------------------- ---------------------
......
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