diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-03 10:19:32 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-03 10:19:32 +0000 |
commit | 039fcfa6316d4a70d271d974f9ded9c2001a97b8 (patch) | |
tree | b0a3d19077a30eaebc12a8b662cc50d870dcdb04 /gcc/ada/prj-conf.adb | |
parent | 3aa582cd74c2d892c68361298d2e6e83b9d1d595 (diff) | |
download | gcc-039fcfa6316d4a70d271d974f9ded9c2001a97b8.tar.gz |
2011-08-03 Emmanuel Briot <briot@adacore.com>
* gnatcmd.adb, prj-proc.adb, prj-proc.ads, make.adb, mlib-prj.adb,
prj.adb, prj.ads, makeutl.adb, makeutl.ads, clean.adb, prj-nmsc.adb,
prj-util.adb, prj-util.ads, prj-conf.adb, prj-conf.ads, prj-env.adb,
prj-env.ads (Shared_Project_Tree_Data): new type
An aggregate project and its aggregated trees need to share the common
data structures used for lists of strings, packages,... This makes the
code simpler since otherwise we have to pass the root tree (also used
for the configuration file data) in addition to the current project
tree. This also avoids ambiguities as to which tree should be used.
And finally this saves a bit of memory.
(For_Every_Project_Imported): new parameter Tree.
Since aggregated projects are using a different tree, we need to let
the caller know which tree to use to manipulate the returned project.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177261 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/prj-conf.adb')
-rw-r--r-- | gcc/ada/prj-conf.adb | 163 |
1 files changed, 93 insertions, 70 deletions
diff --git a/gcc/ada/prj-conf.adb b/gcc/ada/prj-conf.adb index 978d4130ddf..3c39e6190a4 100644 --- a/gcc/ada/prj-conf.adb +++ b/gcc/ada/prj-conf.adb @@ -101,6 +101,17 @@ package body Prj.Conf is pragma No_Return (Raise_Invalid_Config); -- Raises exception Invalid_Config with given message + procedure Apply_Config_File + (Config_File : Prj.Project_Id; + Project_Tree : Prj.Project_Tree_Ref); + -- Apply the configuration file settings to all the projects in the + -- project tree. The Project_Tree must have been parsed first, and + -- processed through the first phase so that all its projects are known. + -- + -- Currently, this will add new attributes and packages in the various + -- projects, so that when the second phase of the processing is performed + -- these attributes are automatically taken into account. + -------------------- -- Add_Attributes -- -------------------- @@ -110,6 +121,7 @@ package body Prj.Conf is Conf_Decl : Declarations; User_Decl : in out Declarations) is + Shared : constant Shared_Project_Tree_Data_Access := Project_Tree.Shared; Conf_Attr_Id : Variable_Id; Conf_Attr : Variable; Conf_Array_Id : Array_Id; @@ -130,10 +142,8 @@ package body Prj.Conf is Conf_Attr_Id := Conf_Decl.Attributes; User_Attr_Id := User_Decl.Attributes; while Conf_Attr_Id /= No_Variable loop - Conf_Attr := - Project_Tree.Variable_Elements.Table (Conf_Attr_Id); - User_Attr := - Project_Tree.Variable_Elements.Table (User_Attr_Id); + Conf_Attr := Shared.Variable_Elements.Table (Conf_Attr_Id); + User_Attr := Shared.Variable_Elements.Table (User_Attr_Id); if not Conf_Attr.Value.Default then if User_Attr.Value.Default then @@ -142,8 +152,7 @@ package body Prj.Conf is -- value of the configuration attribute. User_Attr.Value := Conf_Attr.Value; - Project_Tree.Variable_Elements.Table (User_Attr_Id) := - User_Attr; + Shared.Variable_Elements.Table (User_Attr_Id) := User_Attr; elsif User_Attr.Value.Kind = List and then Conf_Attr.Value.Values /= Nil_String @@ -164,22 +173,20 @@ package body Prj.Conf is -- Create new list String_Element_Table.Increment_Last - (Project_Tree.String_Elements); + (Shared.String_Elements); New_List := String_Element_Table.Last - (Project_Tree.String_Elements); + (Shared.String_Elements); -- Value of attribute is new list User_Attr.Value.Values := New_List; - Project_Tree.Variable_Elements.Table (User_Attr_Id) := - User_Attr; + Shared.Variable_Elements.Table (User_Attr_Id) := User_Attr; loop -- Get each element of configuration list - Conf_Elem := - Project_Tree.String_Elements.Table (Conf_List); + Conf_Elem := Shared.String_Elements.Table (Conf_List); New_Elem := Conf_Elem; Conf_List := Conf_Elem.Next; @@ -189,8 +196,7 @@ package body Prj.Conf is -- first element of user list, and we are done. New_Elem.Next := User_List; - Project_Tree.String_Elements.Table - (New_List) := New_Elem; + Shared.String_Elements.Table (New_List) := New_Elem; exit; else @@ -198,12 +204,10 @@ package body Prj.Conf is -- new list. String_Element_Table.Increment_Last - (Project_Tree.String_Elements); + (Shared.String_Elements); New_Elem.Next := - String_Element_Table.Last - (Project_Tree.String_Elements); - Project_Tree.String_Elements.Table - (New_List) := New_Elem; + String_Element_Table.Last (Shared.String_Elements); + Shared.String_Elements.Table (New_List) := New_Elem; New_List := New_Elem.Next; end if; end loop; @@ -217,11 +221,11 @@ package body Prj.Conf is Conf_Array_Id := Conf_Decl.Arrays; while Conf_Array_Id /= No_Array loop - Conf_Array := Project_Tree.Arrays.Table (Conf_Array_Id); + Conf_Array := Shared.Arrays.Table (Conf_Array_Id); User_Array_Id := User_Decl.Arrays; while User_Array_Id /= No_Array loop - User_Array := Project_Tree.Arrays.Table (User_Array_Id); + User_Array := Shared.Arrays.Table (User_Array_Id); exit when User_Array.Name = Conf_Array.Name; User_Array_Id := User_Array.Next; end loop; @@ -230,11 +234,11 @@ package body Prj.Conf is -- do a shallow copy of the full associative array. if User_Array_Id = No_Array then - Array_Table.Increment_Last (Project_Tree.Arrays); + Array_Table.Increment_Last (Shared.Arrays); User_Array := Conf_Array; User_Array.Next := User_Decl.Arrays; - User_Decl.Arrays := Array_Table.Last (Project_Tree.Arrays); - Project_Tree.Arrays.Table (User_Decl.Arrays) := User_Array; + User_Decl.Arrays := Array_Table.Last (Shared.Arrays); + Shared.Arrays.Table (User_Decl.Arrays) := User_Array; else -- Otherwise, check each array element @@ -242,12 +246,12 @@ package body Prj.Conf is Conf_Array_Elem_Id := Conf_Array.Value; while Conf_Array_Elem_Id /= No_Array_Element loop Conf_Array_Elem := - Project_Tree.Array_Elements.Table (Conf_Array_Elem_Id); + Shared.Array_Elements.Table (Conf_Array_Elem_Id); User_Array_Elem_Id := User_Array.Value; while User_Array_Elem_Id /= No_Array_Element loop User_Array_Elem := - Project_Tree.Array_Elements.Table (User_Array_Elem_Id); + Shared.Array_Elements.Table (User_Array_Elem_Id); exit when User_Array_Elem.Index = Conf_Array_Elem.Index; User_Array_Elem_Id := User_Array_Elem.Next; end loop; @@ -257,15 +261,14 @@ package body Prj.Conf is -- user array. if User_Array_Elem_Id = No_Array_Element then - Array_Element_Table.Increment_Last - (Project_Tree.Array_Elements); + Array_Element_Table.Increment_Last (Shared.Array_Elements); User_Array_Elem := Conf_Array_Elem; User_Array_Elem.Next := User_Array.Value; User_Array.Value := - Array_Element_Table.Last (Project_Tree.Array_Elements); - Project_Tree.Array_Elements.Table (User_Array.Value) := + Array_Element_Table.Last (Shared.Array_Elements); + Shared.Array_Elements.Table (User_Array.Value) := User_Array_Elem; - Project_Tree.Arrays.Table (User_Array_Id) := User_Array; + Shared.Arrays.Table (User_Array_Id) := User_Array; -- Otherwise, if the value is a string list, prepend the -- user array element with the conf array element value. @@ -283,23 +286,22 @@ package body Prj.Conf is begin loop Conf_List_Elem := - Project_Tree.String_Elements.Table - (Conf_List); + Shared.String_Elements.Table (Conf_List); String_Element_Table.Increment_Last - (Project_Tree.String_Elements); + (Shared.String_Elements); Next := String_Element_Table.Last - (Project_Tree.String_Elements); - Project_Tree.String_Elements.Table (Next) := + (Shared.String_Elements); + Shared.String_Elements.Table (Next) := Conf_List_Elem; if Previous = Nil_String then User_Array_Elem.Value.Values := Next; - Project_Tree.Array_Elements.Table + Shared.Array_Elements.Table (User_Array_Elem_Id) := User_Array_Elem; else - Project_Tree.String_Elements.Table + Shared.String_Elements.Table (Previous).Next := Next; end if; @@ -308,8 +310,8 @@ package body Prj.Conf is Conf_List := Conf_List_Elem.Next; if Conf_List = Nil_String then - Project_Tree.String_Elements.Table - (Previous).Next := Link; + Shared.String_Elements.Table (Previous).Next := + Link; exit; end if; end loop; @@ -454,9 +456,10 @@ package body Prj.Conf is ----------------------- procedure Apply_Config_File - (Config_File : Prj.Project_Id; - Project_Tree : Prj.Project_Tree_Ref) + (Config_File : Prj.Project_Id; + Project_Tree : Prj.Project_Tree_Ref) is + Shared : constant Shared_Project_Tree_Data_Access := Project_Tree.Shared; Conf_Decl : constant Declarations := Config_File.Decl; Conf_Pack_Id : Package_Id; Conf_Pack : Package_Element; @@ -467,47 +470,67 @@ package body Prj.Conf is Proj : Project_List; begin + Debug_Output ("Applying config file to a project tree"); + Proj := Project_Tree.Projects; while Proj /= null loop if Proj.Project /= Config_File then User_Decl := Proj.Project.Decl; Add_Attributes - (Project_Tree => Project_Tree, - Conf_Decl => Conf_Decl, - User_Decl => User_Decl); + (Project_Tree => Project_Tree, + Conf_Decl => Conf_Decl, + User_Decl => User_Decl); Conf_Pack_Id := Conf_Decl.Packages; while Conf_Pack_Id /= No_Package loop - Conf_Pack := Project_Tree.Packages.Table (Conf_Pack_Id); + Conf_Pack := Shared.Packages.Table (Conf_Pack_Id); User_Pack_Id := User_Decl.Packages; while User_Pack_Id /= No_Package loop - User_Pack := Project_Tree.Packages.Table (User_Pack_Id); + User_Pack := Shared.Packages.Table (User_Pack_Id); exit when User_Pack.Name = Conf_Pack.Name; User_Pack_Id := User_Pack.Next; end loop; if User_Pack_Id = No_Package then - Package_Table.Increment_Last (Project_Tree.Packages); + Package_Table.Increment_Last (Shared.Packages); User_Pack := Conf_Pack; User_Pack.Next := User_Decl.Packages; - User_Decl.Packages := - Package_Table.Last (Project_Tree.Packages); - Project_Tree.Packages.Table (User_Decl.Packages) := - User_Pack; + User_Decl.Packages := Package_Table.Last (Shared.Packages); + Shared.Packages.Table (User_Decl.Packages) := User_Pack; else Add_Attributes - (Project_Tree => Project_Tree, - Conf_Decl => Conf_Pack.Decl, - User_Decl => Project_Tree.Packages.Table - (User_Pack_Id).Decl); + (Project_Tree => Project_Tree, + Conf_Decl => Conf_Pack.Decl, + User_Decl => + Shared.Packages.Table (User_Pack_Id).Decl); end if; Conf_Pack_Id := Conf_Pack.Next; end loop; Proj.Project.Decl := User_Decl; + + -- For aggregate projects, we need to apply the config to all + -- their aggregated trees as well. + + if Proj.Project.Qualifier = Aggregate then + declare + List : Aggregated_Project_List := + Proj.Project.Aggregated_Projects; + begin + while List /= null loop + Debug_Output + ("Recursively apply config to aggregated tree", + List.Project.Name); + Apply_Config_File + (Config_File, + Project_Tree => List.Tree); + List := List.Next; + end loop; + end; + end if; end if; Proj := Proj.Next; @@ -524,9 +547,10 @@ package body Prj.Conf is Project_Tree : Prj.Project_Tree_Ref; Target : String := "") return Boolean is + Shared : constant Shared_Project_Tree_Data_Access := Project_Tree.Shared; Variable : constant Variable_Value := Value_Of - (Name_Target, Config_File.Decl.Attributes, Project_Tree); + (Name_Target, Config_File.Decl.Attributes, Shared); Tgt_Name : Name_Id := No_Name; OK : Boolean; @@ -585,6 +609,7 @@ package body Prj.Conf is Automatically_Generated : out Boolean; On_Load_Config : Config_File_Hook := null) is + Shared : constant Shared_Project_Tree_Data_Access := Project_Tree.Shared; At_Least_One_Compiler_Command : Boolean := False; -- Set to True if at least one attribute Ide'Compiler_Command is @@ -655,7 +680,7 @@ package body Prj.Conf is Value_Of (Name_Source_Dirs, Project.Decl.Attributes, - Project_Tree); + Shared); if Variable = Nil_Variable_Value or else Variable.Default @@ -665,7 +690,7 @@ package body Prj.Conf is Value_Of (Name_Source_Files, Project.Decl.Attributes, - Project_Tree); + Shared); return Variable = Nil_Variable_Value or else Variable.Default or else Variable.Values /= Nil_String; @@ -690,10 +715,7 @@ package body Prj.Conf is -- Hash table to keep the languages used in the project tree IDE : constant Package_Id := - Value_Of - (Name_Ide, - Project.Decl.Packages, - Project_Tree); + Value_Of (Name_Ide, Project.Decl.Packages, Shared); Prj_Iter : Project_List; List : String_List_Id; @@ -714,7 +736,7 @@ package body Prj.Conf is Value_Of (Name_Languages, Prj_Iter.Project.Decl.Attributes, - Project_Tree); + Shared); if Variable = Nil_Variable_Value or else Variable.Default @@ -730,7 +752,7 @@ package body Prj.Conf is Value_Of (Name_Languages, Prj_Iter.Project.Extends.Decl.Attributes, - Project_Tree); + Shared); Check_Default := Variable /= Nil_Variable_Value and then Variable.Values = Nil_String; @@ -741,7 +763,7 @@ package body Prj.Conf is Value_Of (Name_Default_Language, Prj_Iter.Project.Decl.Attributes, - Project_Tree); + Shared); if Variable /= Nil_Variable_Value and then not Variable.Default @@ -765,7 +787,7 @@ package body Prj.Conf is List := Variable.Values; while List /= Nil_String loop - Elem := Project_Tree.String_Elements.Table (List); + Elem := Shared.String_Elements.Table (List); Get_Name_String (Elem.Value); To_Lower (Name_Buffer (1 .. Name_Len)); @@ -800,7 +822,7 @@ package body Prj.Conf is (Name, Attribute_Or_Array_Name => Name_Compiler_Command, In_Package => IDE, - In_Tree => Project_Tree, + Shared => Shared, Force_Lower_Case_Index => True); declare @@ -857,7 +879,7 @@ package body Prj.Conf is Value_Of (Name_Object_Dir, Project.Decl.Attributes, - Project_Tree); + Shared); Gprconfig_Path : String_Access; Success : Boolean; @@ -1261,6 +1283,7 @@ package body Prj.Conf is On_Load_Config : Config_File_Hook := null; Reset_Tree : Boolean := True) is + Shared : constant Shared_Project_Tree_Data_Access := Project_Tree.Shared; Main_Config_Project : Project_Id; Success : Boolean; @@ -1289,7 +1312,7 @@ package body Prj.Conf is Value_Of (Name_Object_Dir, Main_Project.Decl.Attributes, - Project_Tree); + Shared); begin if Obj_Dir = Nil_Variable_Value or else Obj_Dir.Default then |