Commit daa72421 by Arnaud Charlet

[multiple changes]

2009-09-17  Bob Duff  <duff@adacore.com>

	* gnat_rm.texi, s-oscons-tmplt.c: Minor typo

2009-09-17  Emmanuel Briot  <briot@adacore.com>

	* gnatcmd.adb, prj-proc.adb, make.adb, prj-ext.adb, prj-ext.ads,
	makeutl.adb, makeutl.ads, clean.adb, prj-pars.adb, prj-pars.ads,
	prj-conf.adb, prj-conf.ads, prj-tree.adb, prj-tree.ads, prj-proc.ads,
	prj-nmsc.ads (Add, Value_Of, Reset): new parameter Tree.
	Scenario variables are now specific to each project tree loaded in
	memory.
	Code clean ups.

2009-09-17  Javier Miranda  <miranda@adacore.com>

	* exp_disp.adb (Make_DT): Remove wrong line of code that was
	undocumented and probably added by mistake.

From-SVN: r151792
parent 15ac3c72
2009-09-17 Bob Duff <duff@adacore.com>
* gnat_rm.texi, s-oscons-tmplt.c: Minor typo
2009-09-17 Emmanuel Briot <briot@adacore.com>
* gnatcmd.adb, prj-proc.adb, make.adb, prj-ext.adb, prj-ext.ads,
makeutl.adb, makeutl.ads, clean.adb, prj-pars.adb, prj-pars.ads,
prj-conf.adb, prj-conf.ads, prj-tree.adb, prj-tree.ads, prj-proc.ads,
prj-nmsc.ads (Add, Value_Of, Reset): new parameter Tree.
Scenario variables are now specific to each project tree loaded in
memory.
Code clean ups.
2009-09-17 Javier Miranda <miranda@adacore.com>
* exp_disp.adb (Make_DT): Remove wrong line of code that was
undocumented and probably added by mistake.
2009-09-16 Eric Botcazou <ebotcazou@adacore.com> 2009-09-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Size>: Strip * gcc-interface/trans.c (Attribute_to_gnu) <Attr_Size>: Strip
......
...@@ -35,6 +35,7 @@ with Prj; use Prj; ...@@ -35,6 +35,7 @@ with Prj; use Prj;
with Prj.Env; with Prj.Env;
with Prj.Ext; with Prj.Ext;
with Prj.Pars; with Prj.Pars;
with Prj.Tree; use Prj.Tree;
with Prj.Util; use Prj.Util; with Prj.Util; use Prj.Util;
with Snames; with Snames;
with Switch; use Switch; with Switch; use Switch;
...@@ -90,7 +91,7 @@ package body Clean is ...@@ -90,7 +91,7 @@ package body Clean is
Project_File_Name : String_Access := null; Project_File_Name : String_Access := null;
Project_Tree : constant Prj.Project_Tree_Ref := new Prj.Project_Tree_Data; Project_Node_Tree : Project_Node_Tree_Ref;
Main_Project : Prj.Project_Id := Prj.No_Project; Main_Project : Prj.Project_Id := Prj.No_Project;
...@@ -1402,6 +1403,7 @@ package body Clean is ...@@ -1402,6 +1403,7 @@ package body Clean is
Prj.Pars.Parse Prj.Pars.Parse
(Project => Main_Project, (Project => Main_Project,
In_Tree => Project_Tree, In_Tree => Project_Tree,
In_Node_Tree => Project_Node_Tree,
Project_File_Name => Project_File_Name.all, Project_File_Name => Project_File_Name.all,
Flags => Gnatmake_Flags, Flags => Gnatmake_Flags,
Packages_To_Check => Packages_To_Check_By_Gnatmake); Packages_To_Check => Packages_To_Check_By_Gnatmake);
...@@ -1556,6 +1558,10 @@ package body Clean is ...@@ -1556,6 +1558,10 @@ package body Clean is
Csets.Initialize; Csets.Initialize;
Namet.Initialize; Namet.Initialize;
Snames.Initialize; Snames.Initialize;
Project_Node_Tree := new Project_Node_Tree_Data;
Prj.Tree.Initialize (Project_Node_Tree);
Prj.Initialize (Project_Tree); Prj.Initialize (Project_Tree);
-- Check if the platform is VMS and, if it is, change some variables -- Check if the platform is VMS and, if it is, change some variables
...@@ -1873,7 +1879,8 @@ package body Clean is ...@@ -1873,7 +1879,8 @@ package body Clean is
if OK then if OK then
Prj.Ext.Add Prj.Ext.Add
(External_Name => (Project_Node_Tree,
External_Name =>
Ext_Asgn (Start .. Equal_Pos - 1), Ext_Asgn (Start .. Equal_Pos - 1),
Value => Value =>
Ext_Asgn (Equal_Pos + 1 .. Stop)); Ext_Asgn (Equal_Pos + 1 .. Stop));
......
...@@ -5140,9 +5140,8 @@ package body Exp_Disp is ...@@ -5140,9 +5140,8 @@ package body Exp_Disp is
exit when Parent_Typ = Current_Typ; exit when Parent_Typ = Current_Typ;
if Is_CPP_Class (Parent_Typ) if Is_CPP_Class (Parent_Typ) then
or else Is_Interface (Typ)
then
-- The tags defined in the C++ side will be inherited when -- The tags defined in the C++ side will be inherited when
-- the object is constructed (Exp_Ch3.Build_Init_Procedure) -- the object is constructed (Exp_Ch3.Build_Init_Procedure)
......
...@@ -7733,11 +7733,11 @@ Followed. ...@@ -7733,11 +7733,11 @@ Followed.
In addition to the implementation dependent pragmas and attributes, and In addition to the implementation dependent pragmas and attributes, and
the implementation advice, there are a number of other Ada features the implementation advice, there are a number of other Ada features
that are potentially implementation dependent. These are mentioned that are potentially implementation dependent. These are mentioned
throughout the Ada Reference Manual, and are summarized in annex M@. throughout the Ada Reference Manual, and are summarized in Annex M@.
A requirement for conforming Ada compilers is that they provide A requirement for conforming Ada compilers is that they provide
documentation describing how the implementation deals with each of these documentation describing how the implementation deals with each of these
issues. In this chapter, you will find each point in annex M listed issues. In this chapter, you will find each point in Annex M listed
followed by a description in italic font of how GNAT followed by a description in italic font of how GNAT
@c SGI info: @c SGI info:
@ignore @ignore
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with Csets; with Csets;
with Makeutl; with Makeutl; use Makeutl;
with MLib.Tgt; use MLib.Tgt; with MLib.Tgt; use MLib.Tgt;
with MLib.Utl; with MLib.Utl;
with MLib.Fil; with MLib.Fil;
...@@ -38,6 +38,7 @@ with Prj; use Prj; ...@@ -38,6 +38,7 @@ with Prj; use Prj;
with Prj.Env; with Prj.Env;
with Prj.Ext; use Prj.Ext; with Prj.Ext; use Prj.Ext;
with Prj.Pars; with Prj.Pars;
with Prj.Tree; use Prj.Tree;
with Prj.Util; use Prj.Util; with Prj.Util; use Prj.Util;
with Sinput.P; with Sinput.P;
with Snames; use Snames; with Snames; use Snames;
...@@ -57,7 +58,7 @@ with GNAT.OS_Lib; use GNAT.OS_Lib; ...@@ -57,7 +58,7 @@ with GNAT.OS_Lib; use GNAT.OS_Lib;
with VMS_Conv; use VMS_Conv; with VMS_Conv; use VMS_Conv;
procedure GNATCmd is procedure GNATCmd is
Project_Tree : constant Project_Tree_Ref := new Project_Tree_Data; Project_Node_Tree : Project_Node_Tree_Ref;
Project_File : String_Access; Project_File : String_Access;
Project : Prj.Project_Id; Project : Prj.Project_Id;
Current_Verbosity : Prj.Verbosity := Prj.Default; Current_Verbosity : Prj.Verbosity := Prj.Default;
...@@ -1268,6 +1269,9 @@ begin ...@@ -1268,6 +1269,9 @@ begin
Snames.Initialize; Snames.Initialize;
Project_Node_Tree := new Project_Node_Tree_Data;
Prj.Tree.Initialize (Project_Node_Tree);
Prj.Initialize (Project_Tree); Prj.Initialize (Project_Tree);
Last_Switches.Init; Last_Switches.Init;
...@@ -1694,7 +1698,8 @@ begin ...@@ -1694,7 +1698,8 @@ begin
begin begin
if Equal_Pos >= Argv'First + 3 and then if Equal_Pos >= Argv'First + 3 and then
Equal_Pos /= Argv'Last then Equal_Pos /= Argv'Last then
Add (External_Name => Add (Project_Node_Tree,
External_Name =>
Argv (Argv'First + 2 .. Equal_Pos - 1), Argv (Argv'First + 2 .. Equal_Pos - 1),
Value => Argv (Equal_Pos + 1 .. Argv'Last)); Value => Argv (Equal_Pos + 1 .. Argv'Last));
else else
...@@ -1753,6 +1758,7 @@ begin ...@@ -1753,6 +1758,7 @@ begin
Prj.Pars.Parse Prj.Pars.Parse
(Project => Project, (Project => Project,
In_Tree => Project_Tree, In_Tree => Project_Tree,
In_Node_Tree => Project_Node_Tree,
Project_File_Name => Project_File.all, Project_File_Name => Project_File.all,
Flags => Gnatmake_Flags, Flags => Gnatmake_Flags,
Packages_To_Check => Packages_To_Check); Packages_To_Check => Packages_To_Check);
...@@ -2114,7 +2120,7 @@ begin ...@@ -2114,7 +2120,7 @@ begin
-- arguments. -- arguments.
for J in 1 .. Last_Switches.Last loop for J in 1 .. Last_Switches.Last loop
Test_If_Relative_Path GNATCmd.Test_If_Relative_Path
(Last_Switches.Table (J), Current_Work_Dir); (Last_Switches.Table (J), Current_Work_Dir);
end loop; end loop;
...@@ -2124,7 +2130,7 @@ begin ...@@ -2124,7 +2130,7 @@ begin
Project_Dir : constant String := Name_Buffer (1 .. Name_Len); Project_Dir : constant String := Name_Buffer (1 .. Name_Len);
begin begin
for J in 1 .. First_Switches.Last loop for J in 1 .. First_Switches.Last loop
Test_If_Relative_Path GNATCmd.Test_If_Relative_Path
(First_Switches.Table (J), Project_Dir); (First_Switches.Table (J), Project_Dir);
end loop; end loop;
end; end;
......
...@@ -49,10 +49,16 @@ with Prj; use Prj; ...@@ -49,10 +49,16 @@ with Prj; use Prj;
with Prj.Com; with Prj.Com;
with Prj.Env; with Prj.Env;
with Prj.Pars; with Prj.Pars;
with Prj.Tree; use Prj.Tree;
with Prj.Util; with Prj.Util;
with SFN_Scan; with SFN_Scan;
with Sinput.P; with Sinput.P;
with Snames; use Snames; with Snames; use Snames;
pragma Warnings (Off);
with System.HTable;
pragma Warnings (On);
with Switch; use Switch; with Switch; use Switch;
with Switch.M; use Switch.M; with Switch.M; use Switch.M;
with Targparm; use Targparm; with Targparm; use Targparm;
...@@ -68,8 +74,6 @@ with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables; ...@@ -68,8 +74,6 @@ with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Case_Util; use GNAT.Case_Util;
with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.OS_Lib; use GNAT.OS_Lib;
with System.HTable;
package body Make is package body Make is
use ASCII; use ASCII;
...@@ -640,7 +644,7 @@ package body Make is ...@@ -640,7 +644,7 @@ package body Make is
-- directory of the ultimate extending project. If it is not, we ignore -- directory of the ultimate extending project. If it is not, we ignore
-- the fact that this ALI file is read-only. -- the fact that this ALI file is read-only.
procedure Process_Multilib; procedure Process_Multilib (Project_Node_Tree : Project_Node_Tree_Ref);
-- Add appropriate --RTS argument to handle multilib -- Add appropriate --RTS argument to handle multilib
---------------------------------------------------- ----------------------------------------------------
...@@ -710,7 +714,8 @@ package body Make is ...@@ -710,7 +714,8 @@ package body Make is
File_Name : String; File_Name : String;
Index : Int; Index : Int;
Program : Make_Program_Type; Program : Make_Program_Type;
Unknown_Switches_To_The_Compiler : Boolean := True); Unknown_Switches_To_The_Compiler : Boolean := True;
Project_Node_Tree : Project_Node_Tree_Ref);
procedure Add_Switch procedure Add_Switch
(S : String_Access; (S : String_Access;
Program : Make_Program_Type; Program : Make_Program_Type;
...@@ -998,7 +1003,7 @@ package body Make is ...@@ -998,7 +1003,7 @@ package body Make is
-- during a compilation are also transitively included in the W section -- during a compilation are also transitively included in the W section
-- of the originally compiled file. -- of the originally compiled file.
procedure Initialize; procedure Initialize (Project_Node_Tree : out Project_Node_Tree_Ref);
-- Performs default and package initialization. Therefore, -- Performs default and package initialization. Therefore,
-- Compile_Sources can be called by an external unit. -- Compile_Sources can be called by an external unit.
...@@ -1010,8 +1015,13 @@ package body Make is ...@@ -1010,8 +1015,13 @@ package body Make is
-- Args must have a lower bound of 1. Success indicates if the link -- Args must have a lower bound of 1. Success indicates if the link
-- succeeded or not. -- succeeded or not.
procedure Scan_Make_Arg (Argv : String; And_Save : Boolean); procedure Scan_Make_Arg
-- Scan make arguments. Argv is a single argument to be processed (Project_Node_Tree : Project_Node_Tree_Ref;
Argv : String;
And_Save : Boolean);
-- Scan make arguments. Argv is a single argument to be processed.
-- Project_Node_Tree will be used to initialize external references. It
-- must have been initialized.
------------------- -------------------
-- Add_Arguments -- -- Add_Arguments --
...@@ -1233,7 +1243,8 @@ package body Make is ...@@ -1233,7 +1243,8 @@ package body Make is
File_Name : String; File_Name : String;
Index : Int; Index : Int;
Program : Make_Program_Type; Program : Make_Program_Type;
Unknown_Switches_To_The_Compiler : Boolean := True) Unknown_Switches_To_The_Compiler : Boolean := True;
Project_Node_Tree : Project_Node_Tree_Ref)
is is
Switches : Variable_Value; Switches : Variable_Value;
Switch_List : String_List_Id; Switch_List : String_List_Id;
...@@ -1274,7 +1285,8 @@ package body Make is ...@@ -1274,7 +1285,8 @@ package body Make is
Write_Line (Argv); Write_Line (Argv);
end if; end if;
Scan_Make_Arg (Argv, And_Save => False); Scan_Make_Arg
(Project_Node_Tree, Argv, And_Save => False);
if not Gnatmake_Switch_Found if not Gnatmake_Switch_Found
and then not Switch_May_Be_Passed_To_The_Compiler and then not Switch_May_Be_Passed_To_The_Compiler
...@@ -4019,6 +4031,8 @@ package body Make is ...@@ -4019,6 +4031,8 @@ package body Make is
Mapping_Path : Path_Name_Type := No_Path; Mapping_Path : Path_Name_Type := No_Path;
-- The path name of the mapping file -- The path name of the mapping file
Project_Node_Tree : Project_Node_Tree_Ref;
Discard : Boolean; Discard : Boolean;
pragma Warnings (Off, Discard); pragma Warnings (Off, Discard);
...@@ -4366,7 +4380,7 @@ package body Make is ...@@ -4366,7 +4380,7 @@ package body Make is
Obsoleted.Reset; Obsoleted.Reset;
Make.Initialize; Make.Initialize (Project_Node_Tree);
Bind_Shared := No_Shared_Switch'Access; Bind_Shared := No_Shared_Switch'Access;
Link_With_Shared_Libgcc := No_Shared_Libgcc_Switch'Access; Link_With_Shared_Libgcc := No_Shared_Libgcc_Switch'Access;
...@@ -4845,7 +4859,8 @@ package body Make is ...@@ -4845,7 +4859,8 @@ package body Make is
end if; end if;
Add_Switches Add_Switches
(File_Name => Main_Unit_File_Name, (Project_Node_Tree => Project_Node_Tree,
File_Name => Main_Unit_File_Name,
Index => Main_Index, Index => Main_Index,
The_Package => Builder_Package, The_Package => Builder_Package,
Program => None, Program => None,
...@@ -4900,7 +4915,8 @@ package body Make is ...@@ -4900,7 +4915,8 @@ package body Make is
end if; end if;
Add_Switches Add_Switches
(File_Name => " ", (Project_Node_Tree => Project_Node_Tree,
File_Name => " ",
Index => 0, Index => 0,
The_Package => Builder_Package, The_Package => Builder_Package,
Program => None, Program => None,
...@@ -4916,7 +4932,8 @@ package body Make is ...@@ -4916,7 +4932,8 @@ package body Make is
end if; end if;
Add_Switches Add_Switches
(File_Name => " ", (Project_Node_Tree => Project_Node_Tree,
File_Name => " ",
Index => 0, Index => 0,
The_Package => Builder_Package, The_Package => Builder_Package,
Program => None); Program => None);
...@@ -5007,7 +5024,8 @@ package body Make is ...@@ -5007,7 +5024,8 @@ package body Make is
end if; end if;
Add_Switches Add_Switches
(File_Name => Main_Unit_File_Name, (Project_Node_Tree => Project_Node_Tree,
File_Name => Main_Unit_File_Name,
Index => Main_Index, Index => Main_Index,
The_Package => Binder_Package, The_Package => Binder_Package,
Program => Binder); Program => Binder);
...@@ -5023,7 +5041,8 @@ package body Make is ...@@ -5023,7 +5041,8 @@ package body Make is
end if; end if;
Add_Switches Add_Switches
(File_Name => Main_Unit_File_Name, (Project_Node_Tree => Project_Node_Tree,
File_Name => Main_Unit_File_Name,
Index => Main_Index, Index => Main_Index,
The_Package => Linker_Package, The_Package => Linker_Package,
Program => Linker); Program => Linker);
...@@ -6310,7 +6329,8 @@ package body Make is ...@@ -6310,7 +6329,8 @@ package body Make is
end if; end if;
Add_Switches Add_Switches
(File_Name => Main_Unit_File_Name, (Project_Node_Tree => Project_Node_Tree,
File_Name => Main_Unit_File_Name,
Index => Main_Index, Index => Main_Index,
The_Package => Binder_Package, The_Package => Binder_Package,
Program => Binder); Program => Binder);
...@@ -6327,7 +6347,8 @@ package body Make is ...@@ -6327,7 +6347,8 @@ package body Make is
end if; end if;
Add_Switches Add_Switches
(File_Name => Main_Unit_File_Name, (Project_Node_Tree => Project_Node_Tree,
File_Name => Main_Unit_File_Name,
Index => Main_Index, Index => Main_Index,
The_Package => Linker_Package, The_Package => Linker_Package,
Program => Linker); Program => Linker);
...@@ -6521,7 +6542,7 @@ package body Make is ...@@ -6521,7 +6542,7 @@ package body Make is
-- Initialize -- -- Initialize --
---------------- ----------------
procedure Initialize is procedure Initialize (Project_Node_Tree : out Project_Node_Tree_Ref) is
procedure Check_Version_And_Help is procedure Check_Version_And_Help is
new Check_Version_And_Help_G (Makeusg); new Check_Version_And_Help_G (Makeusg);
...@@ -6529,6 +6550,13 @@ package body Make is ...@@ -6529,6 +6550,13 @@ package body Make is
-- Start of processing for Initialize -- Start of processing for Initialize
begin begin
-- Prepare the project's tree, since this is used to hold external
-- references, project path and other attributes that can be impacted by
-- the command line switches
Project_Node_Tree := new Project_Node_Tree_Data;
Prj.Tree.Initialize (Project_Node_Tree);
-- Override default initialization of Check_Object_Consistency since -- Override default initialization of Check_Object_Consistency since
-- this is normally False for GNATBIND, but is True for GNATMAKE since -- this is normally False for GNATBIND, but is True for GNATMAKE since
-- we do not need to check source consistency again once GNATMAKE has -- we do not need to check source consistency again once GNATMAKE has
...@@ -6611,11 +6639,12 @@ package body Make is ...@@ -6611,11 +6639,12 @@ package body Make is
-- do not include --version or --help. -- do not include --version or --help.
Scan_Args : for Next_Arg in 1 .. Argument_Count loop Scan_Args : for Next_Arg in 1 .. Argument_Count loop
Scan_Make_Arg (Argument (Next_Arg), And_Save => True); Scan_Make_Arg
(Project_Node_Tree, Argument (Next_Arg), And_Save => True);
end loop Scan_Args; end loop Scan_Args;
if N_M_Switch > 0 and RTS_Specified = null then if N_M_Switch > 0 and RTS_Specified = null then
Process_Multilib; Process_Multilib (Project_Node_Tree);
end if; end if;
if Commands_To_Stdout then if Commands_To_Stdout then
...@@ -6700,7 +6729,8 @@ package body Make is ...@@ -6700,7 +6729,8 @@ package body Make is
In_Tree => Project_Tree, In_Tree => Project_Tree,
Project_File_Name => Project_File_Name.all, Project_File_Name => Project_File_Name.all,
Packages_To_Check => Packages_To_Check_By_Gnatmake, Packages_To_Check => Packages_To_Check_By_Gnatmake,
Flags => Gnatmake_Flags); Flags => Gnatmake_Flags,
In_Node_Tree => Project_Node_Tree);
-- The parsing of project files may have changed the current output -- The parsing of project files may have changed the current output
...@@ -7281,7 +7311,9 @@ package body Make is ...@@ -7281,7 +7311,9 @@ package body Make is
-- Process_Multilib -- -- Process_Multilib --
---------------------- ----------------------
procedure Process_Multilib is procedure Process_Multilib
(Project_Node_Tree : Project_Node_Tree_Ref)
is
Output_FD : File_Descriptor; Output_FD : File_Descriptor;
Output_Name : String_Access; Output_Name : String_Access;
Arg_Index : Natural := 0; Arg_Index : Natural := 0;
...@@ -7382,8 +7414,9 @@ package body Make is ...@@ -7382,8 +7414,9 @@ package body Make is
-- Otherwise add -margs --RTS=output -- Otherwise add -margs --RTS=output
Scan_Make_Arg ("-margs", And_Save => True); Scan_Make_Arg (Project_Node_Tree, "-margs", And_Save => True);
Scan_Make_Arg ("--RTS=" & Line (1 .. N_Read), And_Save => True); Scan_Make_Arg
(Project_Node_Tree, "--RTS=" & Line (1 .. N_Read), And_Save => True);
end Process_Multilib; end Process_Multilib;
----------------------------- -----------------------------
...@@ -7485,7 +7518,11 @@ package body Make is ...@@ -7485,7 +7518,11 @@ package body Make is
-- Scan_Make_Arg -- -- Scan_Make_Arg --
------------------- -------------------
procedure Scan_Make_Arg (Argv : String; And_Save : Boolean) is procedure Scan_Make_Arg
(Project_Node_Tree : Project_Node_Tree_Ref;
Argv : String;
And_Save : Boolean)
is
Success : Boolean; Success : Boolean;
begin begin
...@@ -8001,7 +8038,7 @@ package body Make is ...@@ -8001,7 +8038,7 @@ package body Make is
-- -Xext=val (External assignment) -- -Xext=val (External assignment)
elsif Argv (2) = 'X' elsif Argv (2) = 'X'
and then Is_External_Assignment (Argv) and then Is_External_Assignment (Project_Node_Tree, Argv)
then then
-- Is_External_Assignment has side effects -- Is_External_Assignment has side effects
-- when it returns True; -- when it returns True;
......
...@@ -447,7 +447,10 @@ package body Makeutl is ...@@ -447,7 +447,10 @@ package body Makeutl is
-- Is_External_Assignment -- -- Is_External_Assignment --
---------------------------- ----------------------------
function Is_External_Assignment (Argv : String) return Boolean is function Is_External_Assignment
(Tree : Prj.Tree.Project_Node_Tree_Ref;
Argv : String) return Boolean
is
Start : Positive := 3; Start : Positive := 3;
Finish : Natural := Argv'Last; Finish : Natural := Argv'Last;
Equal_Pos : Natural; Equal_Pos : Natural;
...@@ -478,7 +481,8 @@ package body Makeutl is ...@@ -478,7 +481,8 @@ package body Makeutl is
return False; return False;
else else
Prj.Ext.Add Prj.Ext.Add
(External_Name => Argv (Start .. Equal_Pos - 1), (Tree => Tree,
External_Name => Argv (Start .. Equal_Pos - 1),
Value => Argv (Equal_Pos + 1 .. Finish)); Value => Argv (Equal_Pos + 1 .. Finish));
return True; return True;
end if; end if;
......
...@@ -28,6 +28,7 @@ with Namet; use Namet; ...@@ -28,6 +28,7 @@ with Namet; use Namet;
with Opt; with Opt;
with Osint; with Osint;
with Prj; use Prj; with Prj; use Prj;
with Prj.Tree;
with Types; use Types; with Types; use Types;
with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.OS_Lib; use GNAT.OS_Lib;
...@@ -83,7 +84,9 @@ package Makeutl is ...@@ -83,7 +84,9 @@ package Makeutl is
-- source files are still associated with the same units). Return True -- source files are still associated with the same units). Return True
-- if everything is still valid -- if everything is still valid
function Is_External_Assignment (Argv : String) return Boolean; function Is_External_Assignment
(Tree : Prj.Tree.Project_Node_Tree_Ref;
Argv : String) return Boolean;
-- Verify that an external assignment switch is syntactically correct -- Verify that an external assignment switch is syntactically correct
-- --
-- Correct forms are: -- Correct forms are:
......
...@@ -1000,7 +1000,6 @@ package body Prj.Conf is ...@@ -1000,7 +1000,6 @@ package body Prj.Conf is
begin begin
-- Parse the user project tree -- Parse the user project tree
Prj.Tree.Initialize (Project_Node_Tree);
Prj.Initialize (Project_Tree); Prj.Initialize (Project_Tree);
Main_Project := No_Project; Main_Project := No_Project;
......
...@@ -59,6 +59,10 @@ package Prj.Conf is ...@@ -59,6 +59,10 @@ package Prj.Conf is
-- Find the main configuration project and parse the project tree rooted at -- Find the main configuration project and parse the project tree rooted at
-- this configuration project. -- this configuration project.
-- --
-- Project_Node_Tree must have been initialized first (and possibly the
-- value for external references and project path should also have been
-- set).
--
-- If the processing fails, Main_Project is set to No_Project. If the error -- If the processing fails, Main_Project is set to No_Project. If the error
-- happend while parsing the project itself (ie creating the tree), -- happend while parsing the project itself (ie creating the tree),
-- User_Project_Node is also set to Empty_Node. -- User_Project_Node is also set to Empty_Node.
......
...@@ -26,11 +26,10 @@ ...@@ -26,11 +26,10 @@
with Hostparm; with Hostparm;
with Makeutl; use Makeutl; with Makeutl; use Makeutl;
with Osint; use Osint; with Osint; use Osint;
with Prj.Tree; use Prj.Tree;
with Sdefault; with Sdefault;
with Table; with Table;
with GNAT.HTable;
package body Prj.Ext is package body Prj.Ext is
Ada_Project_Path : constant String := "ADA_PROJECT_PATH"; Ada_Project_Path : constant String := "ADA_PROJECT_PATH";
...@@ -52,19 +51,6 @@ package body Prj.Ext is ...@@ -52,19 +51,6 @@ package body Prj.Ext is
procedure Initialize_Project_Path; procedure Initialize_Project_Path;
-- Initialize Current_Project_Path -- Initialize Current_Project_Path
package Htable is new GNAT.HTable.Simple_HTable
(Header_Num => Header_Num,
Element => Name_Id,
No_Element => No_Name,
Key => Name_Id,
Hash => Hash,
Equal => "=");
-- External references are stored in this hash table, either by procedure
-- Add (directly or through a call to function Check) or by function
-- Value_Of when an environment variable is found non empty. Value_Of
-- first for external reference in this table, before checking the
-- environment. Htable is emptied (reset) by procedure Reset.
package Search_Directories is new Table.Table package Search_Directories is new Table.Table
(Table_Component_Type => Name_Id, (Table_Component_Type => Name_Id,
Table_Index_Type => Natural, Table_Index_Type => Natural,
...@@ -79,7 +65,8 @@ package body Prj.Ext is ...@@ -79,7 +65,8 @@ package body Prj.Ext is
--------- ---------
procedure Add procedure Add
(External_Name : String; (Tree : Prj.Tree.Project_Node_Tree_Ref;
External_Name : String;
Value : String) Value : String)
is is
The_Key : Name_Id; The_Key : Name_Id;
...@@ -92,7 +79,7 @@ package body Prj.Ext is ...@@ -92,7 +79,7 @@ package body Prj.Ext is
Name_Buffer (1 .. Name_Len) := External_Name; Name_Buffer (1 .. Name_Len) := External_Name;
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
The_Key := Name_Find; The_Key := Name_Find;
Htable.Set (The_Key, The_Value); Name_To_Name_HTable.Set (Tree.External_References, The_Key, The_Value);
end Add; end Add;
----------- -----------
...@@ -110,14 +97,17 @@ package body Prj.Ext is ...@@ -110,14 +97,17 @@ package body Prj.Ext is
-- Check -- -- Check --
----------- -----------
function Check (Declaration : String) return Boolean is function Check
(Tree : Prj.Tree.Project_Node_Tree_Ref;
Declaration : String) return Boolean is
begin begin
for Equal_Pos in Declaration'Range loop for Equal_Pos in Declaration'Range loop
if Declaration (Equal_Pos) = '=' then if Declaration (Equal_Pos) = '=' then
exit when Equal_Pos = Declaration'First; exit when Equal_Pos = Declaration'First;
exit when Equal_Pos = Declaration'Last; exit when Equal_Pos = Declaration'Last;
Add Add
(External_Name => (Tree => Tree,
External_Name =>
Declaration (Declaration'First .. Equal_Pos - 1), Declaration (Declaration'First .. Equal_Pos - 1),
Value => Value =>
Declaration (Equal_Pos + 1 .. Declaration'Last)); Declaration (Equal_Pos + 1 .. Declaration'Last));
...@@ -294,9 +284,9 @@ package body Prj.Ext is ...@@ -294,9 +284,9 @@ package body Prj.Ext is
-- Reset -- -- Reset --
----------- -----------
procedure Reset is procedure Reset (Tree : Prj.Tree.Project_Node_Tree_Ref) is
begin begin
Htable.Reset; Name_To_Name_HTable.Reset (Tree.External_References);
end Reset; end Reset;
---------------------- ----------------------
...@@ -314,7 +304,8 @@ package body Prj.Ext is ...@@ -314,7 +304,8 @@ package body Prj.Ext is
-------------- --------------
function Value_Of function Value_Of
(External_Name : Name_Id; (Tree : Prj.Tree.Project_Node_Tree_Ref;
External_Name : Name_Id;
With_Default : Name_Id := No_Name) With_Default : Name_Id := No_Name)
return Name_Id return Name_Id
is is
...@@ -325,7 +316,8 @@ package body Prj.Ext is ...@@ -325,7 +316,8 @@ package body Prj.Ext is
Canonical_Case_File_Name (Name); Canonical_Case_File_Name (Name);
Name_Len := Name'Length; Name_Len := Name'Length;
Name_Buffer (1 .. Name_Len) := Name; Name_Buffer (1 .. Name_Len) := Name;
The_Value := Htable.Get (Name_Find); The_Value :=
Name_To_Name_HTable.Get (Tree.External_References, Name_Find);
if The_Value /= No_Name then if The_Value /= No_Name then
return The_Value; return The_Value;
...@@ -341,7 +333,8 @@ package body Prj.Ext is ...@@ -341,7 +333,8 @@ package body Prj.Ext is
Name_Len := Env_Value'Length; Name_Len := Env_Value'Length;
Name_Buffer (1 .. Name_Len) := Env_Value.all; Name_Buffer (1 .. Name_Len) := Env_Value.all;
The_Value := Name_Find; The_Value := Name_Find;
Htable.Set (External_Name, The_Value); Name_To_Name_HTable.Set
(Tree.External_References, External_Name, The_Value);
Free (Env_Value); Free (Env_Value);
return The_Value; return The_Value;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2007, Free Software Foundation, Inc. -- -- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -26,8 +26,14 @@ ...@@ -26,8 +26,14 @@
-- Subprograms to set, get and cache external references, to be used as -- Subprograms to set, get and cache external references, to be used as
-- External functions in project files. -- External functions in project files.
with Prj.Tree;
package Prj.Ext is package Prj.Ext is
------------------
-- Project Path --
------------------
Gpr_Project_Path : constant String := "GPR_PROJECT_PATH"; Gpr_Project_Path : constant String := "GPR_PROJECT_PATH";
-- Name of primary env. variable that contain path name(s) of directories -- Name of primary env. variable that contain path name(s) of directories
-- where project files may reside. -- where project files may reside.
...@@ -48,22 +54,36 @@ package Prj.Ext is ...@@ -48,22 +54,36 @@ package Prj.Ext is
-- always start with the current directory (".") and the path separators -- always start with the current directory (".") and the path separators
-- should be the correct ones for the platform. -- should be the correct ones for the platform.
-------------------------
-- External References --
-------------------------
-- External references influence the way a project tree is processed (in
-- particular they provide the values for the typed string variables that
-- are then used in case constructions).
-- External references are project-tree specific, so that when multiple
-- trees are loaded in parallel we can have different scenarios (or even
-- load the same tree twice and see different views of it).
procedure Add procedure Add
(External_Name : String; (Tree : Prj.Tree.Project_Node_Tree_Ref;
External_Name : String;
Value : String); Value : String);
-- Add an external reference (or modify an existing one) -- Add an external reference (or modify an existing one)
function Value_Of function Value_Of
(External_Name : Name_Id; (Tree : Prj.Tree.Project_Node_Tree_Ref;
External_Name : Name_Id;
With_Default : Name_Id := No_Name) With_Default : Name_Id := No_Name)
return Name_Id; return Name_Id;
-- Get the value of an external reference, and cache it for future uses -- Get the value of an external reference, and cache it for future uses
function Check (Declaration : String) return Boolean; function Check
(Tree : Prj.Tree.Project_Node_Tree_Ref;
Declaration : String) return Boolean;
-- Check that an external declaration <external>=<value> is correct. -- Check that an external declaration <external>=<value> is correct.
-- If it is correct, the external reference is Added. -- If it is correct, the external reference is Added.
procedure Reset; procedure Reset (Tree : Prj.Tree.Project_Node_Tree_Ref);
-- Clear the internal data structure that stores the external references -- Clear the internal data structure that stores the external references
-- and free any allocated memory. -- and free any allocated memory.
......
...@@ -33,11 +33,10 @@ private package Prj.Nmsc is ...@@ -33,11 +33,10 @@ private package Prj.Nmsc is
Flags : Processing_Flags); Flags : Processing_Flags);
-- Perform consistency and semantic checks on all the projects in the tree. -- Perform consistency and semantic checks on all the projects in the tree.
-- This procedure interprets the various case statements in the project -- This procedure interprets the various case statements in the project
-- based on the current environment variables (the "scenario"). After -- based on the current external references. After checking the validity of
-- checking the validity of the naming scheme, it searches for all the -- the naming scheme, it searches for all the source files of the project.
-- source files of the project. The result of this procedure is a filled-in -- The result of this procedure is a filled-in data structure for
-- data structure for Project_Id which contains all the information about -- Project_Id which contains all the information about the project. This
-- the project. This information is only valid while the scenario variables -- information is only valid while the external references are preserved.
-- are preserved.
end Prj.Nmsc; end Prj.Nmsc;
...@@ -45,18 +45,21 @@ package body Prj.Pars is ...@@ -45,18 +45,21 @@ package body Prj.Pars is
Project_File_Name : String; Project_File_Name : String;
Packages_To_Check : String_List_Access := All_Packages; Packages_To_Check : String_List_Access := All_Packages;
Flags : Processing_Flags; Flags : Processing_Flags;
Reset_Tree : Boolean := True) Reset_Tree : Boolean := True;
In_Node_Tree : Prj.Tree.Project_Node_Tree_Ref := null)
is is
Project_Node : Project_Node_Id := Empty_Node; Project_Node : Project_Node_Id := Empty_Node;
The_Project : Project_Id := No_Project; The_Project : Project_Id := No_Project;
Success : Boolean := True; Success : Boolean := True;
Current_Dir : constant String := Get_Current_Dir; Current_Dir : constant String := Get_Current_Dir;
Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref; Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref := In_Node_Tree;
Automatically_Generated : Boolean; Automatically_Generated : Boolean;
Config_File_Path : String_Access; Config_File_Path : String_Access;
begin begin
if Project_Node_Tree = null then
Project_Node_Tree := new Project_Node_Tree_Data; Project_Node_Tree := new Project_Node_Tree_Data;
Prj.Tree.Initialize (Project_Node_Tree); Prj.Tree.Initialize (Project_Node_Tree);
end if;
-- Parse the main project file into a tree -- Parse the main project file into a tree
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
-- General wrapper for the parsing of project files -- General wrapper for the parsing of project files
with Prj.Tree;
package Prj.Pars is package Prj.Pars is
procedure Set_Verbosity (To : Verbosity); procedure Set_Verbosity (To : Verbosity);
...@@ -36,20 +38,21 @@ package Prj.Pars is ...@@ -36,20 +38,21 @@ package Prj.Pars is
Project_File_Name : String; Project_File_Name : String;
Packages_To_Check : String_List_Access := All_Packages; Packages_To_Check : String_List_Access := All_Packages;
Flags : Processing_Flags; Flags : Processing_Flags;
Reset_Tree : Boolean := True); Reset_Tree : Boolean := True;
In_Node_Tree : Prj.Tree.Project_Node_Tree_Ref := null);
-- Parse and process a project files and all its imported project files, in -- Parse and process a project files and all its imported project files, in
-- the project tree In_Tree. -- the project tree In_Tree.
-- All the project files are parsed (through Prj.Tree) to create a tree in -- All the project files are parsed (through Prj.Tree) to create a tree in
-- memory. That tree is then processed (through Prj.Proc) to create a -- memory. That tree is then processed (through Prj.Proc) to create a
-- expanded representation of the tree based on the current scenario -- expanded representation of the tree based on the current external
-- variables. This function is only a convenient wrapper over other -- references. This function is only a convenient wrapper over other
-- services provided in the Prj.* package hierarchy. -- services provided in the Prj.* package hierarchy.
-- --
-- If parsing is successful, Project is the project ID of the root project -- If parsing is successful, Project is the project ID of the root project
-- file; otherwise, Project_Id is set to No_Project. Project_Node_Tree is -- file; otherwise, Project_Id is set to No_Project. Project_Node_Tree is
-- set to the tree (unprocessed) representation of the project file. This -- set to the tree (unprocessed) representation of the project file. This
-- tree is permanently correct, whereas Project will need to be recomputed -- tree is permanently correct, whereas Project will need to be recomputed
-- if the scenario variables change. -- if the external references change.
-- --
-- Packages_To_Check indicates the packages where any unknown attribute -- Packages_To_Check indicates the packages where any unknown attribute
-- produces an error. For other packages, an unknown attribute produces a -- produces an error. For other packages, an unknown attribute produces a
...@@ -57,5 +60,9 @@ package Prj.Pars is ...@@ -57,5 +60,9 @@ package Prj.Pars is
-- --
-- When Reset_Tree is True, all the project data are removed from the -- When Reset_Tree is True, all the project data are removed from the
-- project table before processing. -- project table before processing.
--
-- In_Node_Tree (if given) must have been Initialized. The main reason to
-- pass an existing tree, is to pass the external references that will then
-- be used to process the tree.
end Prj.Pars; end Prj.Pars;
...@@ -1041,7 +1041,8 @@ package body Prj.Proc is ...@@ -1041,7 +1041,8 @@ package body Prj.Proc is
end if; end if;
end if; end if;
Value := Prj.Ext.Value_Of (Name, Default); Value := Prj.Ext.Value_Of
(From_Project_Node_Tree, Name, Default);
if Value = No_Name then if Value = No_Name then
if not Quiet_Output then if not Quiet_Output then
......
...@@ -40,7 +40,7 @@ package Prj.Proc is ...@@ -40,7 +40,7 @@ package Prj.Proc is
Flags : Prj.Processing_Flags; Flags : Prj.Processing_Flags;
Reset_Tree : Boolean := True); Reset_Tree : Boolean := True);
-- Process a project tree (ie the direct resulting of parsing a .gpr file) -- Process a project tree (ie the direct resulting of parsing a .gpr file)
-- based on the current scenario variables. -- based on the current external references.
-- --
-- The result of this phase_1 is a partial project tree (Project) where -- The result of this phase_1 is a partial project tree (Project) where
-- only a few fields have been initialized (in particular the list of -- only a few fields have been initialized (in particular the list of
......
...@@ -983,6 +983,10 @@ package body Prj.Tree is ...@@ -983,6 +983,10 @@ package body Prj.Tree is
begin begin
Project_Node_Table.Init (Tree.Project_Nodes); Project_Node_Table.Init (Tree.Project_Nodes);
Projects_Htable.Reset (Tree.Projects_HT); Projects_Htable.Reset (Tree.Projects_HT);
-- Do not reset the external references, in case we are reloading a
-- project, since we want to preserve the current environment
-- Name_To_Name_HTable.Reset (Tree.External_References);
end Initialize; end Initialize;
---------- ----------
......
...@@ -1001,7 +1001,6 @@ package Prj.Tree is ...@@ -1001,7 +1001,6 @@ package Prj.Tree is
package Tree_Private_Part is package Tree_Private_Part is
-- This is conceptually in the private part -- This is conceptually in the private part
-- However, for efficiency, some packages are accessing it directly -- However, for efficiency, some packages are accessing it directly
type Project_Node_Record is record type Project_Node_Record is record
...@@ -1371,9 +1370,23 @@ package Prj.Tree is ...@@ -1371,9 +1370,23 @@ package Prj.Tree is
end Tree_Private_Part; end Tree_Private_Part;
package Name_To_Name_HTable is new GNAT.Dynamic_HTables.Simple_HTable
(Header_Num => Header_Num,
Element => Name_Id,
No_Element => No_Name,
Key => Name_Id,
Hash => Hash,
Equal => "=");
type Project_Node_Tree_Data is record type Project_Node_Tree_Data is record
Project_Nodes : Tree_Private_Part.Project_Node_Table.Instance; Project_Nodes : Tree_Private_Part.Project_Node_Table.Instance;
Projects_HT : Tree_Private_Part.Projects_Htable.Instance; Projects_HT : Tree_Private_Part.Projects_Htable.Instance;
External_References : Name_To_Name_HTable.Instance;
-- External references are stored in this hash table (and manipulated
-- through subprogrames in prj-ext.ads). External references are
-- project-tree specific so that one can load the same tree twice but
-- have two views of it, for instance.
end record; end record;
-- The data for a project node tree -- The data for a project node tree
......
...@@ -58,7 +58,7 @@ pragma Style_Checks ("M32766"); ...@@ -58,7 +58,7 @@ pragma Style_Checks ("M32766");
** s-oscons-tmpl.s. ** s-oscons-tmpl.s.
** **
** The default one assumes that the template can be compiled by the newly- ** The default one assumes that the template can be compiled by the newly-
** build cross compiler. It uses markup produced in the (pseudo-)assembly ** built cross compiler. It uses markup produced in the (pseudo-)assembly
** listing: ** listing:
** **
** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i ** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
......
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