2011-08-03 Emmanuel Briot <briot@adacore.com>
+ * prj-proc.adb, prj.ads, makeutl.adb, makeutl.ads, prj-conf.adb,
+ prj-tree.adb, prj-tree.ads (Environment): new type.
+
+2011-08-03 Emmanuel Briot <briot@adacore.com>
+
* prj-tree.ads: Remove unused variable.
2011-08-03 Yannick Moy <moy@adacore.com>
----------------------------
function Is_External_Assignment
- (Tree : Prj.Tree.Project_Node_Tree_Ref;
+ (Env : Prj.Tree.Environment;
Argv : String) return Boolean
is
Start : Positive := 3;
end if;
return Prj.Ext.Check
- (Self => Tree.External,
+ (Self => Env.External,
Declaration => Argv (Start .. Finish));
end Is_External_Assignment;
-- --
-- S p e c --
-- --
--- Copyright (C) 2004-2010, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-2011, Free Software Foundation, Inc. --
-- --
-- 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- --
-- if everything is still valid.
function Is_External_Assignment
- (Tree : Prj.Tree.Project_Node_Tree_Ref;
+ (Env : Prj.Tree.Environment;
Argv : String) return Boolean;
-- Verify that an external assignment switch is syntactically correct
--
(Project : Project_Id;
Project_Tree : Project_Tree_Ref;
Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
+ Env : Prj.Tree.Environment;
Allow_Automatic_Generation : Boolean;
Config_File_Name : String := "";
Autoconf_Specified : Boolean;
Config_Project_Node : Project_Node_Id := Empty_Node;
begin
- pragma Assert (Prj.Env.Is_Initialized (Project_Node_Tree.Project_Path));
+ pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
Free (Config_File_Path);
Config := No_Project;
Project => Project.Extends,
Flags => Flags,
From_Project_Node => Extended_Project_Of
- (Declaration_Node,
- From_Project_Node_Tree),
+ (Declaration_Node, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree,
Extended_By => Project);
In_Tree => In_Tree,
Flags => Flags,
From_Project_Node => From_Project_Node,
- Node_Tree => From_Project_Node_Tree,
+ Node_Tree => From_Project_Node_Tree,
Pkg => No_Package,
Item => First_Declarative_Item_Of
- (Declaration_Node,
- From_Project_Node_Tree));
+ (Declaration_Node, From_Project_Node_Tree));
if Project.Extends /= No_Project then
Process_Extended_Project;
-- Initialize --
----------------
- procedure Initialize (Tree : Project_Node_Tree_Ref) is
+ procedure Initialize
+ (Tree : Project_Node_Tree_Ref; Env : in out Environment) is
begin
Project_Node_Table.Init (Tree.Project_Nodes);
Projects_Htable.Reset (Tree.Projects_HT);
+ Initialize (Env);
+ end Initialize;
+ ----------------
+ -- Initialize --
+ ----------------
+
+ procedure Initialize (Self : in out Environment) is
+ begin
-- Do not reset the external references, in case we are reloading a
-- project, since we want to preserve the current environment.
-- But we still need to ensure that the external references are properly
-- initialized.
- Prj.Ext.Initialize (Tree.External);
+ Prj.Ext.Initialize (Self.External);
-- Prj.Ext.Reset (Tree.External);
end Initialize;
-- Free --
----------
- procedure Free (Proj : in out Project_Node_Tree_Ref) is
+ procedure Free (Self : in out Environment) is
+ begin
+ Prj.Ext.Free (Self.External);
+ Free (Self.Project_Path);
+ end Free;
+
+ ----------
+ -- Free --
+ ----------
+
+ procedure Free
+ (Proj : in out Project_Node_Tree_Ref;
+ Env : in out Environment)
+ is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Project_Node_Tree_Data, Project_Node_Tree_Ref);
begin
if Proj /= null then
Project_Node_Table.Free (Proj.Project_Nodes);
Projects_Htable.Reset (Proj.Projects_HT);
- Prj.Ext.Free (Proj.External);
- Free (Proj.Project_Path);
Unchecked_Free (Proj);
end if;
+ Free (Env);
end Free;
-------------------------------
package Prj.Tree is
+ -----------------
+ -- Environment --
+ -----------------
+
+ type Environment is record
+ External : Prj.Ext.External_References;
+ -- External references are stored in this hash table (and manipulated
+ -- through subprograms 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.
+
+ Project_Path : aliased Prj.Env.Project_Search_Path;
+ -- The project path is tree specific, since we might want to load
+ -- simultaneously multiple projects, each with its own search path, in
+ -- particular when using different compilers with different default
+ -- search directories.
+ end record;
+ -- This record contains the context in which projects are parsed and
+ -- processed (finding importing project, resolving external values,...)
+
+ procedure Initialize (Self : in out Environment);
+ -- Initialize a new environment
+
+ procedure Free (Self : in out Environment);
+ -- Free the memory used by Self
+
+ -------------------
+ -- Project nodes --
+ -------------------
+
type Project_Node_Tree_Data;
type Project_Node_Tree_Ref is access all Project_Node_Tree_Data;
-- Type to designate a project node tree, so that several project node
pragma Inline (No);
-- Return True if Node = Empty_Node
- procedure Initialize (Tree : Project_Node_Tree_Ref);
+ procedure Initialize (Tree : Project_Node_Tree_Ref;
+ Env : in out Environment);
-- Initialize the Project File tree: empty the Project_Nodes table
-- and reset the Projects_Htable.
type Project_Node_Tree_Data is record
Project_Nodes : Tree_Private_Part.Project_Node_Table.Instance;
Projects_HT : Tree_Private_Part.Projects_Htable.Instance;
-
- External : Prj.Ext.External_References;
- -- External references are stored in this hash table (and manipulated
- -- through subprograms 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.
-
- Project_Path : aliased Prj.Env.Project_Search_Path;
- -- The project path is tree specific, since we might want to load
- -- simultaneously multiple projects, each with its own search path, in
- -- particular when using different compilers with different default
- -- search directories.
end record;
- procedure Free (Proj : in out Project_Node_Tree_Ref);
+ procedure Free (Proj : in out Project_Node_Tree_Ref;
+ Env : in out Environment);
-- Free memory used by Prj
private
case Qualifier is
when Aggregate =>
Aggregated_Projects : Aggregated_Project_List := null;
+ -- List of aggregated projects (which could themselves be
+ -- aggregate projects).
when others =>
null;