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>
* 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,
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,
......
......@@ -909,6 +909,7 @@ package body Prj.Conf is
Compiler_Driver_Mandatory : Boolean := True;
Allow_Duplicate_Basenames : Boolean := False;
Reset_Tree : Boolean := True;
Require_Sources_Other_Lang : Boolean := True;
When_No_Sources : Error_Warning := Warning)
is
Main_Config_Project : Project_Id;
......@@ -954,17 +955,17 @@ package body Prj.Conf is
-- Finish processing the user's project
Prj.Proc.Process_Project_Tree_Phase_2
(In_Tree => Project_Tree,
Project => Main_Project,
Success => Success,
From_Project_Node => User_Project_Node,
From_Project_Node_Tree => Project_Node_Tree,
Report_Error => Report_Error,
Current_Dir => Current_Directory,
When_No_Sources => When_No_Sources,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames,
Is_Config_File => False);
(In_Tree => Project_Tree,
Project => Main_Project,
Success => Success,
From_Project_Node => User_Project_Node,
From_Project_Node_Tree => Project_Node_Tree,
Report_Error => Report_Error,
Current_Dir => Current_Directory,
When_No_Sources => When_No_Sources,
Require_Sources_Other_Lang => Require_Sources_Other_Lang,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames);
if not Success then
Main_Project := No_Project;
......
......@@ -101,6 +101,7 @@ package Prj.Conf is
Compiler_Driver_Mandatory : Boolean := True;
Allow_Duplicate_Basenames : Boolean := False;
Reset_Tree : Boolean := True;
Require_Sources_Other_Lang : Boolean := True;
When_No_Sources : Error_Warning := Warning);
-- Same as above, except the project must already have been parsed through
-- Prj.Part.Parse, and only the processing of the project and the
......@@ -108,6 +109,10 @@ package Prj.Conf is
-- 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
-- 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;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -25,31 +25,48 @@
-- Perform various checks on a project and find all its source files
with GNAT.Dynamic_HTables;
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
-- to be kept in memory once a project has been fully loaded, but is
-- necessary while performing consistency checks (duplicate sources,...)
-- This data must be initialized before processing any project, and the
-- same data is used for processing all projects in the tree.
procedure Initialize (Proc_Data : in out Processing_Data);
-- Initialize Proc_Data
procedure Initialize
(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);
-- Free the memory occupied by Proc_Data
procedure Free (Data : in out Tree_Processing_Data);
-- Free the memory occupied by Data
procedure Check
(Project : Project_Id;
In_Tree : Project_Tree_Ref;
Report_Error : Put_Line_Access;
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);
(Project : Project_Id;
Current_Dir : String;
Data : in out Tree_Processing_Data);
-- Perform consistency and semantic checks on a project, starting from the
-- project tree parsed from the .gpr file. This procedure interprets the
-- various case statements in the project based on the current environment
......@@ -61,28 +78,32 @@ private package Prj.Nmsc is
-- is Ada_Only, this procedure will only search Ada sources, but in multi-
-- 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
-- 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
type Processing_Data is record
Units : Files_Htable.Instance;
-- Mapping from file base name to the Source_Id of the file
package Files_Htable is new GNAT.Dynamic_HTables.Simple_HTable
(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 Prj.Nmsc;
......@@ -94,6 +94,7 @@ package body Prj.Pars is
Normalized_Hostname => "",
Compiler_Driver_Mandatory => False,
Allow_Duplicate_Basenames => False,
Require_Sources_Other_Lang => False,
On_Load_Config =>
Add_Default_GNAT_Naming_Scheme'Access,
Reset_Tree => Reset_Tree,
......
......@@ -79,17 +79,16 @@ package body Prj.Proc is
-- the package or project with declarations Decl.
procedure Check
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Current_Dir : String;
When_No_Sources : Error_Warning;
Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean);
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Current_Dir : String;
When_No_Sources : Error_Warning;
Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean);
-- Set all projects to not checked, then call Recursive_Check for the
-- main project Project. Project is set to No_Project if errors occurred.
-- 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
-- authorized within a project for source-based languages (never for unit
-- based languages)
......@@ -152,13 +151,8 @@ package body Prj.Proc is
-- project.
type Recursive_Check_Data is record
In_Tree : Project_Tree_Ref;
Current_Dir : String_Access;
When_No_Sources : Error_Warning;
Proc_Data : Processing_Data;
Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean;
Proc_Data : Tree_Processing_Data;
end record;
-- Data passed to Recursive_Check
-- Current_Dir is for optimization purposes, avoiding extra system calls.
......@@ -285,13 +279,13 @@ package body Prj.Proc is
-----------
procedure Check
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Current_Dir : String;
When_No_Sources : Error_Warning;
Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Current_Dir : String;
When_No_Sources : Error_Warning;
Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
is
Dir : aliased String := Current_Dir;
......@@ -301,14 +295,16 @@ package body Prj.Proc is
Data : Recursive_Check_Data;
begin
Data.In_Tree := In_Tree;
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);
......@@ -1244,8 +1240,7 @@ package body Prj.Proc is
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error;
Reset_Tree : Boolean := True;
Current_Dir : String := "";
Is_Config_File : Boolean)
Current_Dir : String := "")
is
begin
Process_Project_Tree_Phase_1
......@@ -1257,19 +1252,21 @@ package body Prj.Proc is
Report_Error => Report_Error,
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
(In_Tree => In_Tree,
Project => Project,
Success => Success,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Report_Error => Report_Error,
When_No_Sources => When_No_Sources,
Current_Dir => Current_Dir,
Compiler_Driver_Mandatory => True,
Allow_Duplicate_Basenames => False,
Is_Config_File => Is_Config_File);
(In_Tree => In_Tree,
Project => Project,
Success => Success,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Report_Error => Report_Error,
When_No_Sources => When_No_Sources,
Current_Dir => Current_Dir,
Require_Sources_Other_Lang => False,
Compiler_Driver_Mandatory => True,
Allow_Duplicate_Basenames => False);
end if;
end Process;
......@@ -2315,17 +2312,17 @@ package body Prj.Proc is
----------------------------------
procedure Process_Project_Tree_Phase_2
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Success : out Boolean;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error;
Current_Dir : String;
Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Success : out Boolean;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error;
Current_Dir : String;
Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean)
is
Obj_Dir : Path_Name_Type;
Extending : Project_Id;
......@@ -2341,9 +2338,9 @@ package body Prj.Proc is
if Project /= No_Project then
Check (In_Tree, Project, Current_Dir, When_No_Sources,
Is_Config_File => Is_Config_File,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames);
Require_Sources_Other_Lang => Require_Sources_Other_Lang,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames);
end if;
-- If main project is an extending all project, set the object
......@@ -2464,12 +2461,7 @@ package body Prj.Proc is
Write_Line ("""");
end if;
Prj.Nmsc.Check
(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);
Prj.Nmsc.Check (Project, Data.Current_Dir.all, Data.Proc_Data);
end Recursive_Check;
-----------------------
......
......@@ -58,17 +58,17 @@ package Prj.Proc is
-- project table before processing.
procedure Process_Project_Tree_Phase_2
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Success : out Boolean;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error;
Current_Dir : String;
Is_Config_File : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean);
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Success : out Boolean;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error;
Current_Dir : String;
Require_Sources_Other_Lang : Boolean;
Compiler_Driver_Mandatory : Boolean;
Allow_Duplicate_Basenames : Boolean);
-- Perform the second phase of the processing, filling the rest of the
-- project with the information extracted from the project tree. This phase
-- requires that the configuration file has already been parsed (in fact
......@@ -78,8 +78,6 @@ package Prj.Proc is
--
-- 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
-- authorized within a project for source-based languages (never for unit
-- based languages)
......@@ -93,8 +91,7 @@ package Prj.Proc is
Report_Error : Put_Line_Access;
When_No_Sources : Error_Warning := Error;
Reset_Tree : Boolean := True;
Current_Dir : String := "";
Is_Config_File : Boolean);
Current_Dir : String := "");
-- Performs the two phases of the processing
end Prj.Proc;
......@@ -1268,15 +1268,6 @@ package Prj is
Equal => "=");
-- 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 --
---------------------
......
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