Next: Naming Schemes, Previous: Packages in Project Files, Up: GNAT Project Manager
An attribute or variable defined in an imported or parent project can be used in expressions in the importing / extending project. Such an attribute or variable is prefixed with the name of the project and (if relevant) the name of package where it is defined.
with "imported";
project Main extends "base" is
Var1 := Imported.Var;
Var2 := Base.Var & ".new";
package Builder is
for Default_Switches ("Ada") use Imported.Builder.Ada_Switches &
"-gnatg" & "-v";
end Builder;
package Compiler is
for Default_Switches ("Ada") use Base.Compiler.Ada_Switches;
end Compiler;
end Main;
In this example:
Var1 is a copy of the variable Var defined in the project file
"imported.gpr"
Var2 is a copy of the value of variable Var
defined in the project file base.gpr, concatenated with ".new"
Default_Switches ("Ada") in package Builder
is a string list that includes in its value a copy of variable
Ada_Switches defined in the Builder package in project file
imported.gpr plus two new elements: "-gnatg" and "-v";
Default_Switches ("Ada") in package Compiler
is a copy of the variable Ada_Switches defined in the Compiler
package in project file base.gpr, the project being extended.