Commit 5415acbd by Arnaud Charlet

[multiple changes]

2011-09-02  Pascal Obry  <obry@adacore.com>

	* prj-proc.adb, prj.adb, prj.ads, prj-dect.adb, prj-nmsc.adb,
	prj-conf.adb, projects.texi: Add support for aggregate library projects.

2011-09-02  Hristian Kirtchev  <kirtchev@adacore.com>

	* exp_ch9.adb (Expand_N_Protected_Type_Declaration): Use
	Dynamic_Interrupt_Protection as the proper protection type when
	dynamic handler association is actually allowed.

2011-09-02  Robert Dewar  <dewar@adacore.com>

	* makeutl.ads: Minor reformatting

From-SVN: r178446
parent 735ca1b9
...@@ -7991,7 +7991,9 @@ package body Exp_Ch9 is ...@@ -7991,7 +7991,9 @@ package body Exp_Ch9 is
Make_Integer_Literal (Loc, Num_Attach_Handler)))); Make_Integer_Literal (Loc, Num_Attach_Handler))));
end if; end if;
elsif Has_Interrupt_Handler (Prot_Typ) then elsif Has_Interrupt_Handler (Prot_Typ)
and then not Restriction_Active (No_Dynamic_Attachment)
then
Protection_Subtype := Protection_Subtype :=
Make_Subtype_Indication ( Make_Subtype_Indication (
Sloc => Loc, Sloc => Loc,
......
...@@ -474,7 +474,8 @@ package Makeutl is ...@@ -474,7 +474,8 @@ package Makeutl is
procedure Initialize procedure Initialize
(Queue_Per_Obj_Dir : Boolean; (Queue_Per_Obj_Dir : Boolean;
Force : Boolean := False); Force : Boolean := False);
-- Initialize the queue. -- Initialize the queue
--
-- Queue_Per_Obj_Dir matches the --single-compile-per-obj-dir switch: -- Queue_Per_Obj_Dir matches the --single-compile-per-obj-dir switch:
-- when True, there cannot be simultaneous compilations with the object -- when True, there cannot be simultaneous compilations with the object
-- files in the same object directory when project files are used. -- files in the same object directory when project files are used.
...@@ -483,11 +484,10 @@ package Makeutl is ...@@ -483,11 +484,10 @@ package Makeutl is
-- initialized. -- initialized.
procedure Remove_Marks; procedure Remove_Marks;
-- Remove all marks set for the files. -- Remove all marks set for the files. This means that the files will be
-- This means that the files will be handed to the compiler if they are -- handed to the compiler if they are added to the queue, and is mostly
-- added to the queue, and is mostly useful when recompiling several -- useful when recompiling several executables in non-project mode, as
-- executables in non-project mode, as the switches may be different -- the switches may be different and -s may be in use.
-- and -s may be in use.
function Is_Empty return Boolean; function Is_Empty return Boolean;
-- Returns True if the queue is empty -- Returns True if the queue is empty
......
...@@ -510,8 +510,8 @@ package body Prj.Conf is ...@@ -510,8 +510,8 @@ package body Prj.Conf is
Add_Attributes Add_Attributes
(Project_Tree => Project_Tree, (Project_Tree => Project_Tree,
Conf_Decl => Conf_Pack.Decl, Conf_Decl => Conf_Pack.Decl,
User_Decl => User_Decl => Shared.Packages.Table
Shared.Packages.Table (User_Pack_Id).Decl); (User_Pack_Id).Decl);
end if; end if;
Conf_Pack_Id := Conf_Pack.Next; Conf_Pack_Id := Conf_Pack.Next;
...@@ -522,11 +522,11 @@ package body Prj.Conf is ...@@ -522,11 +522,11 @@ package body Prj.Conf is
-- For aggregate projects, we need to apply the config to all -- For aggregate projects, we need to apply the config to all
-- their aggregated trees as well. -- their aggregated trees as well.
if Proj.Project.Qualifier = Aggregate then if Proj.Project.Qualifier in Aggregate_Project then
declare declare
List : Aggregated_Project_List := List : Aggregated_Project_List;
Proj.Project.Aggregated_Projects;
begin begin
List := Proj.Project.Aggregated_Projects;
while List /= null loop while List /= null loop
Debug_Output Debug_Output
("Recursively apply config to aggregated tree", ("Recursively apply config to aggregated tree",
......
...@@ -216,7 +216,7 @@ package body Prj.Dect is ...@@ -216,7 +216,7 @@ package body Prj.Dect is
Project_Qualifier_Of (Project, In_Tree); Project_Qualifier_Of (Project, In_Tree);
Name : constant Name_Id := Name_Of (Current_Package, In_Tree); Name : constant Name_Id := Name_Of (Current_Package, In_Tree);
begin begin
if Qualif = Aggregate if Qualif in Aggregate_Project
and then Name /= Snames.Name_Builder and then Name /= Snames.Name_Builder
then then
Error_Msg_Name_1 := Name; Error_Msg_Name_1 := Name;
...@@ -243,7 +243,7 @@ package body Prj.Dect is ...@@ -243,7 +243,7 @@ package body Prj.Dect is
begin begin
case Qualif is case Qualif is
when Aggregate => when Aggregate | Aggregate_Library =>
if Name = Snames.Name_Languages if Name = Snames.Name_Languages
or else Name = Snames.Name_Source_Files or else Name = Snames.Name_Source_Files
or else Name = Snames.Name_Source_List_File or else Name = Snames.Name_Source_List_File
......
...@@ -980,7 +980,7 @@ package body Prj.Nmsc is ...@@ -980,7 +980,7 @@ package body Prj.Nmsc is
-- Start of processing for Check_Aggregate_Project -- Start of processing for Check_Aggregate_Project
begin begin
pragma Assert (Project.Qualifier = Aggregate); pragma Assert (Project.Qualifier in Aggregate_Project);
if Project_Files.Default then if Project_Files.Default then
Error_Msg_Name_1 := Snames.Name_Project_Files; Error_Msg_Name_1 := Snames.Name_Project_Files;
...@@ -1032,18 +1032,26 @@ package body Prj.Nmsc is ...@@ -1032,18 +1032,26 @@ package body Prj.Nmsc is
Check_If_Externally_Built (Project, Data); Check_If_Externally_Built (Project, Data);
if Project.Qualifier /= Aggregate then case Project.Qualifier is
when Aggregate =>
null;
when Aggregate_Library =>
if Project.Object_Directory = No_Path_Information then
Project.Object_Directory := Project.Directory;
end if;
when others =>
Get_Directories (Project, Data); Get_Directories (Project, Data);
Check_Programming_Languages (Project, Data); Check_Programming_Languages (Project, Data);
if Current_Verbosity = High then if Current_Verbosity = High then
Show_Source_Dirs (Project, Shared); Show_Source_Dirs (Project, Shared);
end if; end if;
end if;
case Project.Qualifier is if Project.Qualifier = Dry then
when Dry => Check_Abstract_Project (Project, Data); Check_Abstract_Project (Project, Data);
when others => null; end if;
end case; end case;
-- Check configuration. This must be done even for gnatmake (even though -- Check configuration. This must be done even for gnatmake (even though
...@@ -1055,7 +1063,13 @@ package body Prj.Nmsc is ...@@ -1055,7 +1063,13 @@ package body Prj.Nmsc is
if Project.Qualifier /= Aggregate then if Project.Qualifier /= Aggregate then
Check_Library_Attributes (Project, Data); Check_Library_Attributes (Project, Data);
Check_Package_Naming (Project, Data); Check_Package_Naming (Project, Data);
-- An aggregate library has no source, no need to look for them
if Project.Qualifier /= Aggregate_Library then
Look_For_Sources (Prj_Data, Data); Look_For_Sources (Prj_Data, Data);
end if;
Check_Interfaces (Project, Data); Check_Interfaces (Project, Data);
if Project.Library then if Project.Library then
...@@ -3378,7 +3392,9 @@ package body Prj.Nmsc is ...@@ -3378,7 +3392,9 @@ package body Prj.Nmsc is
end; end;
end if; end if;
if Project.Library then if Project.Library
and then Project.Qualifier /= Aggregate_Library
then
Debug_Output ("this is a library project file"); Debug_Output ("this is a library project file");
Check_Library (Project.Extends, Extends => True); Check_Library (Project.Extends, Extends => True);
...@@ -6214,8 +6230,10 @@ package body Prj.Nmsc is ...@@ -6214,8 +6230,10 @@ package body Prj.Nmsc is
-- need for an object directory, if not specified. -- need for an object directory, if not specified.
if Project.Project.Extends = No_Project if Project.Project.Extends = No_Project
and then Project.Project.Object_Directory = and then
Project.Project.Directory Project.Project.Object_Directory = Project.Project.Directory
and then
not (Project.Project.Qualifier = Aggregate_Library)
then then
Project.Project.Object_Directory := No_Path_Information; Project.Project.Object_Directory := No_Path_Information;
end if; end if;
......
...@@ -2576,8 +2576,9 @@ package body Prj.Proc is ...@@ -2576,8 +2576,9 @@ package body Prj.Proc is
List : Aggregated_Project_List; List : Aggregated_Project_List;
Loaded_Project : Prj.Tree.Project_Node_Id; Loaded_Project : Prj.Tree.Project_Node_Id;
Success : Boolean := True; Success : Boolean := True;
Tree : Project_Tree_Ref;
begin begin
if Project.Qualifier /= Aggregate then if Project.Qualifier not in Aggregate_Project then
return; return;
end if; end if;
...@@ -2607,6 +2608,15 @@ package body Prj.Proc is ...@@ -2607,6 +2608,15 @@ package body Prj.Proc is
Prj.Initialize (List.Tree); Prj.Initialize (List.Tree);
List.Tree.Shared := In_Tree.Shared; List.Tree.Shared := In_Tree.Shared;
-- In aggregate library, aggregated projects are parsed using
-- the aggregate library tree.
if Project.Qualifier = Aggregate_Library then
Tree := In_Tree;
else
Tree := List.Tree;
end if;
-- We can only do the phase 1 of the processing, since we do -- We can only do the phase 1 of the processing, since we do
-- not have access to the configuration file yet (this is -- not have access to the configuration file yet (this is
-- called when doing phase 1 of the processing for the root -- called when doing phase 1 of the processing for the root
...@@ -2614,7 +2624,7 @@ package body Prj.Proc is ...@@ -2614,7 +2624,7 @@ package body Prj.Proc is
if In_Tree.Is_Root_Tree then if In_Tree.Is_Root_Tree then
Process_Project_Tree_Phase_1 Process_Project_Tree_Phase_1
(In_Tree => List.Tree, (In_Tree => Tree,
Project => List.Project, Project => List.Project,
Success => Success, Success => Success,
From_Project_Node => Loaded_Project, From_Project_Node => Loaded_Project,
...@@ -2625,7 +2635,7 @@ package body Prj.Proc is ...@@ -2625,7 +2635,7 @@ package body Prj.Proc is
-- use the same environment as the rest of the aggregated -- use the same environment as the rest of the aggregated
-- projects, ie the one that was setup by the root aggregate -- projects, ie the one that was setup by the root aggregate
Process_Project_Tree_Phase_1 Process_Project_Tree_Phase_1
(In_Tree => List.Tree, (In_Tree => Tree,
Project => List.Project, Project => List.Project,
Success => Success, Success => Success,
From_Project_Node => Loaded_Project, From_Project_Node => Loaded_Project,
...@@ -2826,6 +2836,10 @@ package body Prj.Proc is ...@@ -2826,6 +2836,10 @@ package body Prj.Proc is
if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then
Initialize_And_Copy (Child_Env, Copy_From => Env); Initialize_And_Copy (Child_Env, Copy_From => Env);
elsif Project.Qualifier = Aggregate_Library then
-- The child environment is the same as the current one
Child_Env := Env;
else else
-- No need to initialize Child_Env, since it will not be -- No need to initialize Child_Env, since it will not be
-- used anyway by Process_Declarative_Items (only the root -- used anyway by Process_Declarative_Items (only the root
...@@ -2866,6 +2880,26 @@ package body Prj.Proc is ...@@ -2866,6 +2880,26 @@ package body Prj.Proc is
if Err_Vars.Total_Errors_Detected = 0 then if Err_Vars.Total_Errors_Detected = 0 then
Process_Aggregated_Projects; Process_Aggregated_Projects;
-- For an aggregate library we add the aggregated projects as
-- imported ones. This is necessary to give visibility to all
-- sources from the aggregates from the aggregated library
-- projects.
if Project.Qualifier = Aggregate_Library then
declare
L : Aggregated_Project_List :=
Project.Aggregated_Projects;
begin
while L /= null loop
Project.Imported_Projects :=
new Project_List_Element'
(Project => L.Project,
Next => Project.Imported_Projects);
L := L.Next;
end loop;
end;
end if;
end if; end if;
if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then
......
...@@ -522,7 +522,7 @@ package body Prj is ...@@ -522,7 +522,7 @@ package body Prj is
-- Visit all aggregated projects -- Visit all aggregated projects
if Include_Aggregated if Include_Aggregated
and then Project.Qualifier = Aggregate and then Project.Qualifier in Aggregate_Project
then then
declare declare
Agg : Aggregated_Project_List; Agg : Aggregated_Project_List;
...@@ -857,7 +857,7 @@ package body Prj is ...@@ -857,7 +857,7 @@ package body Prj is
Free_List (Project.Languages); Free_List (Project.Languages);
case Project.Qualifier is case Project.Qualifier is
when Aggregate => when Aggregate | Aggregate_Library =>
Free (Project.Aggregated_Projects); Free (Project.Aggregated_Projects);
when others => when others =>
...@@ -1665,7 +1665,7 @@ package body Prj is ...@@ -1665,7 +1665,7 @@ package body Prj is
begin begin
Action (Root_Project, Root_Tree); Action (Root_Project, Root_Tree);
if Root_Project.Qualifier = Aggregate then if Root_Project.Qualifier in Aggregate_Project then
Agg := Root_Project.Aggregated_Projects; Agg := Root_Project.Aggregated_Projects;
while Agg /= null loop while Agg /= null loop
For_Project_And_Aggregated (Agg.Project, Agg.Tree); For_Project_And_Aggregated (Agg.Project, Agg.Tree);
......
...@@ -77,6 +77,9 @@ package Prj is ...@@ -77,6 +77,9 @@ package Prj is
-- Aggregate_Library: aggregate library project is ... -- Aggregate_Library: aggregate library project is ...
-- Configuration: configuration project is ... -- Configuration: configuration project is ...
subtype Aggregate_Project
is Project_Qualifier range Aggregate .. Aggregate_Library;
All_Packages : constant String_List_Access; All_Packages : constant String_List_Access;
-- Default value of parameter Packages of procedures Parse, in Prj.Pars and -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
-- Prj.Part, indicating that all packages should be checked. -- Prj.Part, indicating that all packages should be checked.
...@@ -1343,7 +1346,7 @@ package Prj is ...@@ -1343,7 +1346,7 @@ package Prj is
-- The following fields are only valid for specific types of projects -- The following fields are only valid for specific types of projects
case Qualifier is case Qualifier is
when Aggregate => when Aggregate | Aggregate_Library =>
Aggregated_Projects : Aggregated_Project_List := null; Aggregated_Projects : Aggregated_Project_List := null;
-- List of aggregated projects (which could themselves be -- List of aggregated projects (which could themselves be
-- aggregate projects). -- aggregate projects).
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* Library Projects:: * Library Projects::
* Project Extension:: * Project Extension::
* Aggregate Projects:: * Aggregate Projects::
* Aggregate Library Projects::
* Project File Reference:: * Project File Reference::
@end menu @end menu
...@@ -2608,6 +2609,106 @@ name of the executables resulting from the link of the main units, and ...@@ -2608,6 +2609,106 @@ name of the executables resulting from the link of the main units, and
for the Executable_Suffix. for the Executable_Suffix.
@c --------------------------------------------- @c ---------------------------------------------
@node Aggregate Library Projects
@section Aggregate Library Projects
@c ---------------------------------------------
@noindent
Aggregate library projects make it possible to build a single library
using object files built using other standard or library
projects. This gives the flexibility to describe an application as
having multiple modules (a GUI, database access, ...) using different
project files (so possibly built with different compiler options) and
yet create a single library (static or relocatable) out of the
corresponding object files.
@subsection Building aggregate library projects
For example, we can define an aggregate project Agg that groups A, B
and C:
@smallexample @c projectfile
aggregate library project Agg is
for Project_Files use ("a.gpr", "b.gpr", "c.gpr");
for Library_Name use ("agg");
for Library_Dir use ("lagg");
end Agg;
@end smallexample
Then, when you build with:
@smallexample
gprbuild agg.gpr
@end smallexample
This will build all units from projects A, B and C and will create a
static library named @file{libagg.a} into the @file{lagg}
directory. An aggregate library project has the same set of
restriction as a standard library project.
Note that a shared aggregate library project cannot aggregates a
static library project. In platforms where a compiler option is
required to create relocatable object files, a Builder package in the
aggregate library project may be used:
@smallexample @c projectfile
aggregate library project Agg is
for Project_Files use ("a.gpr", "b.gpr", "c.gpr");
for Library_Name use ("agg");
for Library_Dir use ("lagg");
for Library_Kind use "relocatable";
package Builder is
for Global_Compilation_Switches ("Ada") use ("-fPIC");
end Builder;
end Agg;
@end smallexample
With the above aggregate library Builder package, the @code{-fPIC}
option will be passed to the compiler when building any source code
from projects @file{a.gpr}, @file{b.gpr} and @file{c.gpr}.
@subsection Syntax of aggregate library projects
An aggregate library project follows the general syntax of project
files. The recommended extension is still @file{.gpr}. However, a special
@code{aggregate library} qualifier must be put before the keyword
@code{project}.
An aggregate library project cannot @code{with} any other project
(standard or aggregate), except an abstract project which can be used
to share attribute values.
An aggregate library project does not have any source files directly (only
through other standard projects). Therefore a number of the standard
attributes and packages are forbidden in an aggregate library
project. Here is the (non exhaustive) list:
@itemize @bullet
@item Languages
@item Source_Files, Source_List_File and other attributes dealing with
list of sources.
@item Source_Dirs, Exec_Dir and Object_Dir
@item Library_Dir, Library_Name and other library-related attributes
@item Main
@item Roots
@item Externally_Built
@item Inherit_Source_Path
@item Excluded_Source_Dirs
@item Locally_Removed_Files
@item Excluded_Source_Files
@item Excluded_Source_List_File
@item Interfaces
@end itemize
The only package that is authorized (albeit optional) is Builder.
The Project_Files attribute (See @pxref{Aggregate Projects}) is used to
described the aggregated projects whose object files have to be
included into the aggregate library.
@c ---------------------------------------------
@node Project File Reference @node Project File Reference
@section Project File Reference @section Project File Reference
@c --------------------------------------------- @c ---------------------------------------------
......
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