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
Make_Integer_Literal (Loc, Num_Attach_Handler))));
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 :=
Make_Subtype_Indication (
Sloc => Loc,
......
......@@ -474,7 +474,8 @@ package Makeutl is
procedure Initialize
(Queue_Per_Obj_Dir : Boolean;
Force : Boolean := False);
-- Initialize the queue.
-- Initialize the queue
--
-- Queue_Per_Obj_Dir matches the --single-compile-per-obj-dir switch:
-- when True, there cannot be simultaneous compilations with the object
-- files in the same object directory when project files are used.
......@@ -483,11 +484,10 @@ package Makeutl is
-- initialized.
procedure Remove_Marks;
-- Remove all marks set for the files.
-- This means that the files will be handed to the compiler if they are
-- added to the queue, and is mostly useful when recompiling several
-- executables in non-project mode, as the switches may be different
-- and -s may be in use.
-- Remove all marks set for the files. This means that the files will be
-- handed to the compiler if they are added to the queue, and is mostly
-- useful when recompiling several executables in non-project mode, as
-- the switches may be different and -s may be in use.
function Is_Empty return Boolean;
-- Returns True if the queue is empty
......
......@@ -510,8 +510,8 @@ package body Prj.Conf is
Add_Attributes
(Project_Tree => Project_Tree,
Conf_Decl => Conf_Pack.Decl,
User_Decl =>
Shared.Packages.Table (User_Pack_Id).Decl);
User_Decl => Shared.Packages.Table
(User_Pack_Id).Decl);
end if;
Conf_Pack_Id := Conf_Pack.Next;
......@@ -522,11 +522,11 @@ package body Prj.Conf is
-- For aggregate projects, we need to apply the config to all
-- their aggregated trees as well.
if Proj.Project.Qualifier = Aggregate then
if Proj.Project.Qualifier in Aggregate_Project then
declare
List : Aggregated_Project_List :=
Proj.Project.Aggregated_Projects;
List : Aggregated_Project_List;
begin
List := Proj.Project.Aggregated_Projects;
while List /= null loop
Debug_Output
("Recursively apply config to aggregated tree",
......
......@@ -216,7 +216,7 @@ package body Prj.Dect is
Project_Qualifier_Of (Project, In_Tree);
Name : constant Name_Id := Name_Of (Current_Package, In_Tree);
begin
if Qualif = Aggregate
if Qualif in Aggregate_Project
and then Name /= Snames.Name_Builder
then
Error_Msg_Name_1 := Name;
......@@ -243,7 +243,7 @@ package body Prj.Dect is
begin
case Qualif is
when Aggregate =>
when Aggregate | Aggregate_Library =>
if Name = Snames.Name_Languages
or else Name = Snames.Name_Source_Files
or else Name = Snames.Name_Source_List_File
......
......@@ -980,7 +980,7 @@ package body Prj.Nmsc is
-- Start of processing for Check_Aggregate_Project
begin
pragma Assert (Project.Qualifier = Aggregate);
pragma Assert (Project.Qualifier in Aggregate_Project);
if Project_Files.Default then
Error_Msg_Name_1 := Snames.Name_Project_Files;
......@@ -1032,18 +1032,26 @@ package body Prj.Nmsc is
Check_If_Externally_Built (Project, Data);
if Project.Qualifier /= Aggregate then
Get_Directories (Project, Data);
Check_Programming_Languages (Project, Data);
case Project.Qualifier is
when Aggregate =>
null;
if Current_Verbosity = High then
Show_Source_Dirs (Project, Shared);
end if;
end if;
when Aggregate_Library =>
if Project.Object_Directory = No_Path_Information then
Project.Object_Directory := Project.Directory;
end if;
case Project.Qualifier is
when Dry => Check_Abstract_Project (Project, Data);
when others => null;
when others =>
Get_Directories (Project, Data);
Check_Programming_Languages (Project, Data);
if Current_Verbosity = High then
Show_Source_Dirs (Project, Shared);
end if;
if Project.Qualifier = Dry then
Check_Abstract_Project (Project, Data);
end if;
end case;
-- Check configuration. This must be done even for gnatmake (even though
......@@ -1055,7 +1063,13 @@ package body Prj.Nmsc is
if Project.Qualifier /= Aggregate then
Check_Library_Attributes (Project, Data);
Check_Package_Naming (Project, Data);
Look_For_Sources (Prj_Data, 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);
end if;
Check_Interfaces (Project, Data);
if Project.Library then
......@@ -3378,7 +3392,9 @@ package body Prj.Nmsc is
end;
end if;
if Project.Library then
if Project.Library
and then Project.Qualifier /= Aggregate_Library
then
Debug_Output ("this is a library project file");
Check_Library (Project.Extends, Extends => True);
......@@ -6214,8 +6230,10 @@ package body Prj.Nmsc is
-- need for an object directory, if not specified.
if Project.Project.Extends = No_Project
and then Project.Project.Object_Directory =
Project.Project.Directory
and then
Project.Project.Object_Directory = Project.Project.Directory
and then
not (Project.Project.Qualifier = Aggregate_Library)
then
Project.Project.Object_Directory := No_Path_Information;
end if;
......
......@@ -2576,8 +2576,9 @@ package body Prj.Proc is
List : Aggregated_Project_List;
Loaded_Project : Prj.Tree.Project_Node_Id;
Success : Boolean := True;
Tree : Project_Tree_Ref;
begin
if Project.Qualifier /= Aggregate then
if Project.Qualifier not in Aggregate_Project then
return;
end if;
......@@ -2607,6 +2608,15 @@ package body Prj.Proc is
Prj.Initialize (List.Tree);
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
-- not have access to the configuration file yet (this is
-- called when doing phase 1 of the processing for the root
......@@ -2614,7 +2624,7 @@ package body Prj.Proc is
if In_Tree.Is_Root_Tree then
Process_Project_Tree_Phase_1
(In_Tree => List.Tree,
(In_Tree => Tree,
Project => List.Project,
Success => Success,
From_Project_Node => Loaded_Project,
......@@ -2625,7 +2635,7 @@ package body Prj.Proc is
-- use the same environment as the rest of the aggregated
-- projects, ie the one that was setup by the root aggregate
Process_Project_Tree_Phase_1
(In_Tree => List.Tree,
(In_Tree => Tree,
Project => List.Project,
Success => Success,
From_Project_Node => Loaded_Project,
......@@ -2826,6 +2836,10 @@ package body Prj.Proc is
if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then
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
-- No need to initialize Child_Env, since it will not be
-- used anyway by Process_Declarative_Items (only the root
......@@ -2866,6 +2880,26 @@ package body Prj.Proc is
if Err_Vars.Total_Errors_Detected = 0 then
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;
if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then
......
......@@ -522,7 +522,7 @@ package body Prj is
-- Visit all aggregated projects
if Include_Aggregated
and then Project.Qualifier = Aggregate
and then Project.Qualifier in Aggregate_Project
then
declare
Agg : Aggregated_Project_List;
......@@ -857,7 +857,7 @@ package body Prj is
Free_List (Project.Languages);
case Project.Qualifier is
when Aggregate =>
when Aggregate | Aggregate_Library =>
Free (Project.Aggregated_Projects);
when others =>
......@@ -1665,7 +1665,7 @@ package body Prj is
begin
Action (Root_Project, Root_Tree);
if Root_Project.Qualifier = Aggregate then
if Root_Project.Qualifier in Aggregate_Project then
Agg := Root_Project.Aggregated_Projects;
while Agg /= null loop
For_Project_And_Aggregated (Agg.Project, Agg.Tree);
......
......@@ -77,6 +77,9 @@ package Prj is
-- Aggregate_Library: aggregate library project is ...
-- Configuration: configuration project is ...
subtype Aggregate_Project
is Project_Qualifier range Aggregate .. Aggregate_Library;
All_Packages : constant String_List_Access;
-- Default value of parameter Packages of procedures Parse, in Prj.Pars and
-- Prj.Part, indicating that all packages should be checked.
......@@ -1343,7 +1346,7 @@ package Prj is
-- The following fields are only valid for specific types of projects
case Qualifier is
when Aggregate =>
when Aggregate | Aggregate_Library =>
Aggregated_Projects : Aggregated_Project_List := null;
-- List of aggregated projects (which could themselves be
-- aggregate projects).
......
......@@ -19,6 +19,7 @@
* Library Projects::
* Project Extension::
* Aggregate Projects::
* Aggregate Library Projects::
* Project File Reference::
@end menu
......@@ -2608,6 +2609,106 @@ name of the executables resulting from the link of the main units, and
for the Executable_Suffix.
@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
@section Project File Reference
@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