As we mentioned before, only the package Builder can be specified in an aggregate project. In this package, only the following attributes are valid:
for Switches ("Ada") use ("-d", "-p"); for Switches ("C") use ("-p");
These switches are only read from the main aggregate project (the one passed on the command line), and ignored in all other aggregate projects or projects.
It can only contain builder switches, not compiler switches.
for Global_Compilation_Switches ("Ada") use ("-O1", "-g"); for Global_Compilation_Switches ("C") use ("-O2");
This attribute is only taken into account in the aggregate project specified on the command line, not in other aggregate projects.
In the projects grouped by that aggregate, the attribute Builder.Global_Compilation_Switches is also ignored. However, the attribute Compiler.Default_Switches will be taken into account (but that of the aggregate have higher priority). The attribute Compiler.Switches is also taken into account and can be used to override the switches for a specific file. As a result, it always has priority.
The rules are meant to avoid ambiguities when compiling. For instance, aggregate project Agg groups the projects A and B, that both depend on C. Here is an extra for all of these projects:
aggregate project Agg is for Project_Files use ("a.gpr", "b.gpr"); package Builder is for Global_Compilation_Switches ("Ada") use ("-O2"); end Builder; end Agg; with "c.gpr"; project A is package Builder is for Global_Compilation_Switches ("Ada") use ("-O1"); -- ignored end Builder; package Compiler is for Default_Switches ("Ada") use ("-O1", "-g"); for Switches ("a_file1.adb") use ("-O0"); end Compiler; end A; with "c.gpr"; project B is package Compiler is for Default_Switches ("Ada") use ("-O0"); end Compiler; end B; project C is package Compiler is for Default_Switches ("Ada") use ("-O3", "-gnatn"); for Switches ("c_file1.adb") use ("-O0", "-g"); end Compiler; end C;
then the following switches are used:
Even though C is seen through two paths (through A and through
B), the switches used by the compiler are unambiguous.
Projects can locally add to those by using the
Compiler.Local_Configuration_Pragmas
attribute if they need.
For projects that are build through the aggregate, the package Builder is ignored, except for the Executable attribute which specifies the name of the executables resulting from the link of the main programs, and for the Executable_Suffix.