|
NAMEgprtoolsusersguide - GPR Tools User's Guide 26.0.0 Version 26.0.0 Date: Nov 19, 2026 AdaCore Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License <#gnu-fdl>. INTRODUCTIONThis User's Guide describes several software tools that use the GNAT project facility to drive their behavior. GNAT projects are stored in text files with the extension .gpr, commonly called GPR files. These GPR tools use a common facility, the GNAT Project Manager, that is fully described in GNAT Project Manager <#gnat-project-manager>. The main GPR tool is GPRbuild, a multi-language builder for systems organized into subsystems and libraries. This tool is described in Building with GPRbuild <#building-with-gprbuild>. The other GPR tools are described in GPRbuild Companion Tools <#gprbuild-companion-tools>:
GNAT PROJECT MANAGERIntroductionThis chapter describes GNAT's Project Manager, a facility that allows you to manage complex builds involving a number of source files, directories, and options for different system configurations. In particular, project files allow you to specify properties including:
Project files also allow you to:
Project files are written in an Ada-like syntax, using familiar notions such as packages, context clauses, declarations, default values, assignments, and inheritance (see Project File Reference). Project files can depend upon other project files in a modular fashion, simplifying complex system integration and project reuse.
Several tools support project files, generally in addition to specifying the information on the command line itself. They share common switches to control the loading of the project (in particular -Pprojectfile to define the applicable project file and -Xvbl=value to set the value of an external variable). The Project Manager supports a wide range of development strategies, for systems of all sizes. Here are some typical practices that are easily handled:
Project files can be used to achieve some of the effects of a source versioning system (for example, defining separate projects for the different sets of sources that comprise different releases) but the Project Manager is independent of any source configuration management tool that might be used by the developers. The sections below use an example-driven approach to present and illustrate the various concepts related to projects. Building with ProjectsIn its simplest form a project may be used in a stand-alone fashion to build a single executable, and this section will focus on such a setup in order to introduce the main ideas. Later sections will extend this basic model to more complex and realistic configurations. The following concepts are the foundation of project files, and will be further detailed later in this documentation. They are summarized here as a reference.
The following subsections introduce the attributes of interest for simple build needs. Here is the basic setup that will be used in the following examples: The Ada source files pack.ads, pack.adb,
and proc.adb are in the common/ directory. The file
proc.adb contains an Ada main subprogram Proc that withs
package Pack. We want to compile these source files with the switch
-O2, and place the resulting files in the common/obj/ directory.
Here is the directory structure:
common/ Our project is to be called Build. The name of the file is the name of the project (case-insensitive) with the .gpr extension, therefore the project file name is build.gpr. This is not mandatory, but a warning is issued when this convention is not followed. This is a very simple example, and as stated above, a single project file is sufficient. We will thus create a new file, build.gpr, that initially contains an empty project declaration: project Build is end Build; Note that repeating the project name after end is mandatory. Source Files and DirectoriesWhen you create a new project, the first task is to specify where the corresponding source files are located. These are the only settings that are needed by all the tools that will use this project (builder, compiler, binder and linker for the compilation, IDEs to edit the source files, etc.). The first step is thus to declare the source directories, which are the directories to be searched to find source files. In the current example, the common directory is the only source directory. There are several ways to specify the source directories:
When using the Source_Dirs construct, you may sometimes find it convenient to also use the attribute Excluded_Source_Dirs, which is also a list of paths. Each entry specifies a directory whose immediate content, not including subdirs, is to be excluded. It is also possible to exclude a complete directory subtree using the ** notation. It is often desirable to remove, from the source directories, directory subtrees rooted at some subdirectories. An example is the subdirectories created by a Version Control System such as Subversion that creates directory subtrees rooted at a subdirectory named .svn. To do that, attribute Ignore_Source_Sub_Dirs can be used. It specifies the list of simple file names or patterns for the roots of these undesirable directory subtrees. for Source_Dirs use ("./**");
for Ignore_Source_Sub_Dirs use (".svn", "@*");
With the declaration of attribute Ignore_Source_Sub_Dirs above, .svn subtrees as well as subtrees rooted at subdirectories with a name starting with '@' are not part of the source directories of the project. When applied to the simple example, and because we generally prefer to have the project file at the top-level directory rather than mixed with the sources, we will add the relevant definition for the Source_Dirs attribute to our build.gpr project file: project Build is Once the source directories have been specified, you may need to indicate specific source files of interest. By default, all source files present in the source directories are considered by the Project Manager. When this is not desired, it is possible to explicitly specify the list of sources to consider. In such a case, only source file base names are indicated and not their absolute or relative path names. The project manager is in charge of locating the specified source files in the specified source directories.
In most simple cases, such as the above example, the default source file search behavior provides the expected result, and we do not need to add anything after setting Source_Dirs. The Project Manager automatically finds pack.ads, pack.adb, and proc.adb as source files of the project. Note that by default a warning is issued when a project has no sources attached to it and this is not explicitly indicated in the project file. Duplicate Sources in ProjectsIf the order of the source directories is known statically, that is if "/**" is not used in the string list for Source_Dirs, then there may be several files with the same name situated in different directories of the project. In this case, only the file in the first directory is considered as a source of the project and the others are hidden. If "/**" is used in the string list for Source_Dirs, it is an error to have several files with the same name in the same directory "/**" subtree, since there would be an ambiguity as to which one should be used. If there are two sources with the same name in different directories of the same "/**" subtree, one way to resolve the problem is to exclude the directory of the file that should not be used as a source of the project. Object and Exec DirectoryAnother consideration when designing a project is to decide where the compiler should place the object files. In fact, the compiler and other tools might create several different kinds of files (for GNAT, there is the object file and the ALI file). One of the important concepts in projects is that most tools may consider source directories as read-only and thus do not attempt to create new or temporary files there. Instead, all such files are created in the object directory. (This is not true for project-aware IDEs, one of whose purposes is to create the source files.) The object directory is specified through the Object_Dir attribute. Its value is the path to the object directory, either absolute or relative to the directory containing the project file. This directory must already exist and be readable and writable, although some tools have a switch to create the directory if needed (See the switch -p for gprbuild). If the attribute Object_Dir is not specified, it defaults to the directory containing the project file. For our example, we can specify the object directory in this way (assuming that the project file will reside in the parent directory of common): project Build is As mentioned earlier, there is a single object directory per project. As a result, if you have an existing system where the object files are spread across several directories, one option is to move all of them into the same directory if you want to build it with a single project file. An alternative approach is described below (see Organizing Projects into Subsystems), allowing each separate object directory to be associated with a corresponding subsystem of the application. Incidentally, the directory designated by the Object_Dir attribute may be used by project aware tools other than the compilation toolchain to store reports or intermediate files. When the linker is called, it usually creates an executable. By default, this executable is placed in the project's object directory. However in some situations it may be convenient to store it in elsewhere. This can be done through the Exec_Dir attribute, which, like Object_Dir contains a single absolute or relative path and must point to an existing and writable directory, unless you ask the tool to create it on your behalf. If neither Object_Dir nor Exec_Dir is specified then the executable is placed in the directory containing the project file. In our example, let's specify that the executable is to be placed in the same directory as the project file build.gpr. The project file is now: project Build is Main SubprogramsAn important role of a project file is to identify the executable(s) that will be built. It does this by specifying the source file for the main subprogram (for Ada) or the file that contains the main function (for C). There can be any number of such main files within a given project, and thus several executables can be built from a single project file. Of course, a given executable might not (and in general will not) need all the source files referenced by the project. As opposed to other build mechanisms such as through a Makefile, you do not need to specify the list of dependencies of each executable. The project-aware builder knows enough of the semantics of the languages to build and link only the necessary elements. The list of main files is specified via the Main attribute. It contains a list of file names (no directories). If a file name is specified without extension, it is completed using the naming convention defined in the package Naming. If a project defines this attribute, it is not necessary to identify main files on the command line when invoking a builder, and editors like GPS will be able to create extra menus to spawn or debug the corresponding executables. project Build is If this attribute is defined in the project, then spawning the builder with a command such as gprbuild -Pbuild automatically builds all the executables corresponding to the files listed in the Main attribute. It is possible to specify one or more executables on the command line to build a subset of them. One or more spaces may be placed between the -P and the project name, and the project name may be a simple name (no file extension) or a path for the project file. Thus each of the following is equivalent to the command above: gprbuild -P build gprbuild -P build.gpr gprbuild -P ./build.gpr Tools Options in Project FilesWe now have a project file that fully describes our environment, and it can be used to build the application with a simple GPRbuild command as shown above. In fact, the empty project that we saw at the beginning (with no attribute definitions) could already achieve this effect if it was placed in the common directory. Of course, we might want more control. This section shows you how to specify the compilation switches that the various tools involved in the building of the executable should use. Since source names and locations are described in the project file, it is not necessary to use switches on the command line for this purpose (such as -I for gcc). This removes a major source of command line length overflow. Clearly, the builders will have to communicate this information one way or another to the underlying compilers and tools they call, but they usually use various text files, such as response files, for this purpose and thus are not subject to command line overflow. Several tools are used to create an executable: the compiler produces object files from the source files; the binder (when the language is Ada) creates a "source" file that, among other things, takes care of elaboration issues and global variable initialization; and the linker gathers everything into a single executable. All these tools are known to the project manager and will be invoked with user-defined switches from the project files. To obtain this effect, a project file feature known as a package is used. A project file contains zero or more packages, each of which defines the attributes specific to one tool (or one set of tools). Project files use an Ada-like syntax for packages. Package names permitted in project files are restricted to a predefined set (see Packages), and the contents of packages are limited to a small set of constructs and attributes (see Attributes). Our example project file below includes several empty packages. At this stage, they could all be omitted since they are empty, but they show which packages would be involved in the build process. project Build is Let's first examine the compiler switches. As stated in the initial description of the example, we want to compile all files with -O2. This is a compiler switch, although it is typical, on the command line, to pass it to the builder which then passes it to the compiler. We recommend directly using the correct package, which will make the setup easier to understand. Several attributes can be used to specify the switches: Default_Switches: This illustrates the concept of an indexed
attribute. When such an attribute is defined, you must supply an
index in the form of a literal string. In the case of
Default_Switches, the index is the name of the language to which the
switches apply (since a different compiler will likely be used for each
language, and each compiler has its own set of switches). The value of the
attribute is a list of switches.
In this example, we want to compile all Ada source files with the switch -O2; the resulting Compiler package is as follows: package Compiler is Switches: In some cases, we might want to use specific switches for
one or more files. For instance, compiling proc.adb might not be
desirable at a high level of optimization. In such a case, the Switches
attribute (indexed by the file name) can be used and will override the
switches defined by Default_Switches. The Compiler package in
our project file would become:
package Compiler is Switches may take a pattern as an index, such as in: package Compiler is Sources pkg.adb and pkg-child.adb would be compiled with -O0, not -O2. Switches can also be given a language name as index instead of a file name in which case it has the same semantics as Default_Switches. However, indexes with wild cards are never valid for language name. Local_Configuration_Pragmas: This attribute may specify the path of a file containing
configuration pragmas for use by the Ada compiler, such as pragma
Restrictions (No_Tasking). These pragmas will be used for all the sources
of the project.
The switches for the other tools are defined in a similar manner through the Default_Switches and Switches attributes, respectively in the Builder package (for GPRbuild), the Binder package (binding Ada executables) and the Linker package (for linking executables). Compiling with Project FilesNow that our project file is written, let's build our executable. Here is the command we would use from the command line: gprbuild -Pbuild This will automatically build the executables specified in the Main attribute: for each, it will compile or recompile the sources for which the object file does not exist or is not up-to-date; it will then run the binder; and finally run the linker to create the executable itself. The GPRbuild builder can automatically manage C files the same way: create the file utils.c in the common directory, set the attribute Languages to "(Ada, C)", and re-run gprbuild -Pbuild GPRbuild knows how to recompile the C files and will recompile them only if one of their dependencies has changed. No direct indication on how to build the various elements is given in the project file, which describes the project properties rather than a set of actions to be executed. Here is the invocation of GPRbuild when building a multi-language program: $ gprbuild -Pbuild gcc -c proc.adb gcc -c pack.adb gcc -c utils.c gprbind proc ... gcc proc.o -o proc Notice the three steps described earlier:
The default output of GPRbuild is reasonably simple and easy to understand. In particular, some of the less frequently used commands are not shown, and some parameters are abbreviated. Thus it is not possible to rerun the effect of the GPRbuild command by cut-and-pasting its output. The -v option to GPRbuild provides a much more verbose output which includes, among other information, more complete compilation, post-compilation and link commands. Executable File NamesBy default, the executable name corresponding to a main file is computed from the main source file name. Through the attribute Executable in package Builder, it is possible to change this default. For instance, instead of building an executable named "proc" (or "proc.exe" on Windows), we could configure our project file to build proc1 (respectively proc1.exe) as follows: project Build is Attribute Executable_Suffix, when specified, changes the suffix of the executable files when no attribute Executable applies: its value replaces the platform-specific executable suffix. The default executable suffix is the empty string empty on Unix and ".exe" on Windows. It is also possible to change the name of the produced executable by using the command line switch -o. However, when several main programs are defined in the project, it is not possible to use the -o switch; then the only way to change the names of the executable is through the attributes Executable and Executable_Suffix. Using Variables to Avoid DuplicationTo illustrate some other project capabilities, here is a slightly more complex project using similar sources and a main program in C: project C_Main is This project has many similarities with the previous one. As expected, its Main attribute now refers to a C source file. The attribute Exec_Dir is now omitted, thus the resulting executable will be put in the object directory obj. The most noticeable difference is the use of a variable in the Compiler package to store settings used in several attributes. This avoids text duplication and eases maintenance (a single place to modify if we want to add new switches for C files). We will later revisit the use of variables in the context of scenarios (see Scenarios in Projects). In this example, we see that the file main.c will be compiled with the switches used for all the other C files, plus -g. In this specific situation the use of a variable could have been replaced by a reference to the Default_Switches attribute: for Switches ("c_main.c") use Compiler'Default_Switches ("C") & ("-g");
Note the tick character "'", which is used to refer to attributes defined in a package. Here is the output of the GPRbuild command using this project: $ gprbuild -Pc_main gcc -c -pedantic -g main.c gcc -c -gnaty proc.adb gcc -c -gnaty pack.adb gcc -c -pedantic utils.c gprbind main.bexch ... gcc main.o -o main The default switches for Ada sources, the default switches for C sources (in the compilation of lib.c), and the specific switches for main.c have all been taken into account. Naming SchemesSometimes an Ada software system needs to be ported from one compilation environment to another (such as GNAT), but the files might not be named using the default GNAT conventions. Instead of changing all the file names, which for a variety of reasons might not be possible, you can define the relevant file naming scheme in the Naming package of your project file. The naming scheme has two distinct goals for the Project Manager: it allows source files to be located when searching in the source directories, and given a source file name it makes it possible to infer the associated language, and thus which compiler to use. Note that the Ada compiler's use of pragma Source_File_Name is not supported when using project files. You must use the features described here. You can, however, specify other configuration pragmas. The following attributes can be defined in package Naming: Casing: Its value must be one of "lowercase"
(the default if unspecified), "uppercase" or
"mixedcase". It describes the casing of file names with
regard to the Ada unit name.
Given an Ada package body My_Unit, the base file name (i.e. minus the extension, which is controlled by other attributes described below) will respectively be:
On Windows, file names are case insensitive, so this attribute is irrelevant. Dot_Replacement: This attribute specifies the string that should replace
the "." in unit names. Its default value is
"-" so that a unit Parent.Child is expected to be
found in the file parent-child.adb. The replacement string must satisfy
the following requirements to avoid ambiguities in the naming scheme:
Spec_Suffix and Specification_Suffix: For Ada, these attributes specify the suffix used in file
names that contain specifications. For other languages, they give the
extension for files that contain declarations (header files in C for
instance). The attribute is indexed by the language name. The two attributes
are equivalent, but Specification_Suffix is obsolescent.
If the value of the attribute is the empty string, it indicates to the Project Manager that the only specifications/header files for the language are those specified with attributes Spec or Specification_Exceptions. If Spec_Suffix ("Ada") is not specified, then the default is ".ads". A non empty value must satisfy the following requirements:
Body_Suffix and Implementation_Suffix: These attributes are equivalent and specify the extension
used for file names that contain code (bodies in Ada). They are indexed by the
language name. Implementation_Suffix is obsolescent and fully replaced
by the first attribute.
For each language of a project, one of these two attributes needs to be specified, either in the project itself or in the configuration project file. If the value of the attribute is the empty string, it indicates to the Project Manager that the only source files for the language are those specified with attributes Body or Implementation_Exceptions. These attributes must satisfy the same requirements as Spec_Suffix. In addition, they must be different from any of the values in Spec_Suffix. If Body_Suffix ("Ada") is not specified, then the default is ".adb". If Body_Suffix ("Ada") and Spec_Suffix ("Ada") end with the same string, then a file name that ends with the longest of these two suffixes will be a body if the longest suffix is Body_Suffix ("Ada"), or a spec if the longest suffix is Spec_Suffix ("Ada"). If the suffix does not start with a '.', a file with a name exactly equal to the suffix will also be part of the project (for instance if you define the suffix as Makefile.in, a file called Makefile.in will be part of the project. This capability is usually not of interest when building. However, it might become useful when a project is also used to find the list of source files in an editor, like the GNAT Programming System (GPS). Note: Attributes Body_Suffix and Spec_Suffix have
case-insensitive values. This means different languages should not share the
same attribute value in a single project.
For instance : package Naming is will result in : Body_Suffix (".c") for language c is also defined for language c++.
Spec_Suffix (".h") for language c is also defined for language c++.
In that case, having each language inside its own project and individually imported to a master project allows such project architecture. Separate_Suffix: This attribute is specific to Ada. It denotes the suffix
used in file names for files that contain subunits (separate bodies). If it is
not specified, then it defaults to same value as Body_Suffix
("Ada").
The value of this attribute cannot be the empty string. Otherwise, the same rules apply as for the Body_Suffix attribute. Spec or Specification: These attributes are equivalent. The Spec
attribute can be used to define the source file name for a given Ada
compilation unit's spec. The index is the literal name of the Ada unit (case
insensitive). The value is the literal base name of the file that contains
this unit's spec (case sensitive or insensitive depending on the operating
system). This attribute allows the definition of exceptions to the general
naming scheme, in case some files do not follow the usual convention.
When a source file contains several units, the relative position of the unit can be indicated. The first unit in the file is at position 1. for Spec ("MyPack.MyChild") use "mypack.mychild.spec";
for Spec ("top") use "foo.a" at 1;
for Spec ("foo") use "foo.a" at 2;
Body or Implementation: These attribute play the same role as Spec, but
for Ada bodies.
Specification_Exceptions and Implementation_Exceptions: These attributes define exceptions to the naming scheme
for languages other than Ada. They are indexed by the language name, and
contain a list of file names respectively for headers and source code.
As an example of several of these attributes, the following package models the Apex file naming rules: package Naming is Organizing Projects into SubsystemsA subsystem is a coherent part of the complete system to be built. It is represented by a set of sources and a single object directory. A system can consist of a single subsystem when it is simple as we have seen in the earlier examples. Complex systems are usually composed of several interdependent subsystems. A subsystem is dependent on another subsystem if knowledge of the other one is required to build it, and in particular if visibility on some of the sources of this other subsystem is required. Each subsystem is usually represented by its own project file. In this section, we'll enhance the previous example. Let's assume some sources of our Build project depend on other sources. For instance, when building a graphical interface, it is usual to depend upon a graphical library toolkit such as GtkAda. Furthermore, we also need sources from a logging module we had previously written. Importing ProjectsGtkAda comes with its own project file (appropriately called gtkada.gpr), and we will assume we have already built a project called logging.gpr for the logging module. With the information provided so far in build.gpr, building the application would fail with an error indicating that the gtkada and logging units that are relied upon by the sources of this project cannot be found. This is solved by defining build.gpr to import the gtkada and logging projects: this is done by adding the following with clauses at the beginning of our project: with "gtkada.gpr"; with "a/b/logging.gpr"; project Build is When such a project is compiled, gprbuild will automatically check the imported projects and recompile their sources when needed. It will also recompile the sources from Build when needed, and finally create the executable. In some cases, the implementation units needed to recompile a project are not available, or come from some third party and you do not want to recompile it yourself. In this case, set the attribute Externally_Built to "true", indicating to the builder that this project can be assumed to be up-to-date, and should not be considered for recompilation. In Ada, if the sources of this externally built project were compiled with another version of the compiler or with incompatible options, the binder will issue an error. The project's with clause has several effects. It provides source visibility between projects during the compilation process. It also guarantees that the necessary object files from Logging and GtkAda are available when linking Build. As can be seen in this example, the syntax for importing projects is similar to the syntax for importing compilation units in Ada. However, project files use literal strings instead of names, and the with clause identifies project files rather than packages. Each literal string after with is the path (absolute or relative) to a project file. The .gpr extension is optional, but we recommend adding it. If no extension is specified, and no project file with the .gpr extension is found, then the file is searched for exactly as written in the with clause, that is with no extension. As mentioned above, the path after a with has to be a literal string, and you cannot use concatenation, or lookup the value of external variables to change the directories from which a project is loaded. A solution if you need something like this is to use aggregate projects (see Aggregate Projects). When a relative path or a base name is used, the project files are searched relative to each of the directories in the project path. This path includes all the directories found by the following procedure, in decreasing order of priority; the first matching file is used:
The first two paths are only added if the explicit runtime is specified either via --RTS switch or via Runtime attribute. <target> can be communicated via --target switch or Target attribute, otherwise default target will be used. <compiler_prefix> is typically discovered automatically based on target, runtime and language information. In our example, gtkada.gpr is found in the predefined directory if it was installed at the same root as GNAT. Some tools also support extending the project path from the command line, generally through the -aP. You can see the value of the project path by using the gprls -v command. Any symbolic link will be fully resolved in the directory of the importing project file before the imported project file is examined. Any source file in the imported project can be used by the sources of the importing project, transitively. Thus if A imports B, which imports C, the sources of A may depend on the sources of C, even if A does not import C explicitly. However, this is not recommended, because if and when B ceases to import C, some sources in A will no longer compile. GPRbuild has a switch --no-indirect-imports that will report such indirect dependencies. Project import closure The project import closure for a given project proj is the set of projects consisting of proj itself, together with each project that is directly or indirectly imported by proj. The import may be from either a with or, as will be explained below, a limited with. Note: One very important aspect of a project import closure is
that a given source can only belong to one project in this set
(otherwise the project manager would not know which settings apply to it and
when to recompile it). Thus different project files do not usually share
source directories, or, when they do, they need to specify precisely which
project owns which sources using the attribute Source_Files or
equivalent. By contrast, two projects can each own a source with the same base
file name as long as they reside in different directories. The latter is not
true for Ada sources because of the correlation between source files and Ada
units.
Cyclic Project DependenciesIn general, cyclic import dependencies are forbidden: if project A withs project B (directly or indirectly) then B is not allowed to with A. However, there are cases when cyclic dependencies at the project level are necessary, as dependencies at the source level may exist both ways between A's sources and B's sources. For these cases, another form of import between projects is supplied: the limited with. A project A that imports a project B with a simple with may also be imported, directly or indirectly, by B through a limited with. The difference between a simple with and limited with is that the name of a project imported with a limited with cannot be used in the importing project. In particular, its packages cannot be renamed and its variables cannot be referenced. with "b.gpr"; with "c.gpr"; project A is Sharing between ProjectsWhen building an application, it is common to have similar needs in several of the projects corresponding to the subsystems under construction. For instance, they might all have the same compilation switches. As seen above (see Tools Options in Project Files), setting compilation switches for all sources of a subsystem is simple: it is just a matter of adding a Compiler'Default_Switches attribute to each project file with the same value. However, that would entail duplication of data, and both places would need to be changed in order to recompile the whole application with different switches. This may be a serious issue if there are many subsystems and thus many project files to edit. There are two main approaches to avoiding this duplication:
project Logging is The solution used for Compiler gets the same value for all attributes of the package, but you cannot modify anything from the package (adding extra switches or some exceptions). The solution for the Binder package is more flexible, but more verbose. If you need to refer to the value of a variable in an imported project, rather than an attribute, the syntax is similar but uses a "." rather than an apostrophe. For instance: with "imported"; project Main is
abstract project Shared is As with the first example, we could have chosen to set the attributes one by one rather than to rename a package. The reason we explicitly indicate that Shared has no sources is so that it can be created in any directory, and we are sure it shares no sources with Build or Logging, which would be invalid. Note the additional use of the abstract qualifier in shared.gpr. This qualifier is optional, but helps convey the message that we do not intend this project to have source files (see Qualified Projects for additional information about project qualifiers). Global AttributesWe have already seen many examples of attributes used to specify a particular option for one of the tools involved in the build process. Most of those attributes are project specific. That is to say, they only affect the invocation of tools on the sources of the project where they are defined. There are a few additional attributes that, when defined for a "main" project proj, also apply to all other projects in the project import closure of proj. A main project is a project explicitly specified on the command line. Such attributes are known as global attributes; here are several that are commonly used: Builder'Global_Configuration_Pragmas: This attribute specifies a file that contains
configuration pragmas to use when building executables. These pragmas apply to
all executables built from this project import closure. As noted earlier,
additional pragmas can be specified on a per-project basis by setting the
Compiler'Local_Configuration_Pragmas attribute.
Builder'Global_Compilation_Switches: This attribute is a list of compiler switches that apply
when compiling any source file in the project import closure. These switches
are used in addition to the ones defined in the Compiler package, which
only apply to the sources of the corresponding project. This attribute is
indexed by the name of the language.
Using such global capabilities is convenient, but care is needed since it can also lead to unexpected behavior. An example is when several subsystems are shared among different main projects but the different global attributes are not compatible. Note that using aggregate projects can be a safer and more powerful alternative to global attributes. Scenarios in ProjectsVarious project properties can be modified based on scenarios. These are user-defined modes (the values of project variables and attributes) that determine the behavior of a project, based on the values of externally defined variables. Typical examples are the setup of platform-specific compiler options, or the use of a debug and a release mode (the former would activate the generation of debug information, while the latter would request an increased level of code optimization). Let's enhance our example to support debug and release modes. The issue is to let the user choose which kind of system to build: use -g as a compiler switch in debug mode and -O2 in release mode. We will also set up the projects so that we do not share the same object directory in both modes; otherwise switching from one to the other might trigger more recompilations than needed or mix objects from the two modes. One approach is to create two different project files, say build_debug.gpr and build_release.gpr, that set the appropriate attributes as explained in previous sections. This solution does not scale well, because in the presence of multiple projects depending on each other, you will also have to duplicate the complete set of projects and adapt the project files accordingly. Instead, project files support the notion of scenarios controlled by the values of externally defined variables. Such values can come from several sources (in decreasing order of priority):
gprbuild -Pbuild.gpr -Xmode=release which defines the external variable named mode and sets its value to "release".
project Build is The second parameter to external is optional, and is the default value to use if mode is not set from the command line or the environment. If the second parameter is not supplied, and there is no external or environment variable named by the first parameter, then an error is reported. In order to set the switches according to the different scenarios, other constructs are needed, such as typed variables and case constructions. A typed variable is a variable that can take only a limited number of values, similar to variable from an enumeration type in Ada. Such a variable can then be used in a case construction, resulting in conditional sections in the project. The following example shows how this can be done: project Build is This project is larger than the ones we have seen previously, but it has become much more flexible. The Mode_Type type defines the only valid values for the Mode variable. If any other value is read from the environment, an error is reported and the project is considered as invalid. The Mode variable is initialized with an external value defaulting to "debug". This default could be omitted and that would force the user to define the value. Finally, we can use a case construction to set the switches depending on the scenario the user has chosen. Most aspects of a project can depend on scenarios. The notable exception is the identity of an imported project (via a with or limited with clause), which cannot depend on a scenario. Scenarios work analogously across projects in a project import closure. You can either duplicate a variable similar to Mode in each of the projects (as long as the first argument to external is always the same and the type is the same), or simply set the variable in the shared.gpr project (see Sharing between Projects). Library ProjectsSo far, we have seen examples of projects that create executables. However, it is also possible to create libraries instead. A library is a specific type of subsystem where, for convenience, objects are grouped together using system-specific means such as archives or Windows DLLs. Library projects provide a system- and language-independent way of building both static and dynamic libraries. They also support the concept of standalone libraries (SAL) which offer two significant properties: the elaboration (e.g. initialization) of the library is either automatic or very simple; a change in the implementation part of the library implies minimal post-compilation actions on the complete system and potentially no action at all for the rest of the system in the case of dynamic SALs. There is a restriction on shared library projects: by default, they are only allowed to import other shared library projects. They are not allowed to import non-library projects or static library projects. The GNAT Project Manager takes complete care of the library build, rebuild and installation tasks, including recompilation of the source files for which objects do not exist or are not up to date, assembly of the library archive, and installation of the library (i.e., copying associated source, object and ALI files to the specified location). Building LibrariesLet's enhance our example and transform the logging subsystem into a library. In order to do so, a few changes need to be made to logging.gpr. Some attributes need to be defined: at least Library_Name and Library_Dir; in addition, some other attributes can be used to specify specific aspects of the library. For readability, it is also recommended (although not mandatory), to use the qualifier library in front of the project keyword. Library_Name: This attribute is the name of the library to be built.
There is no restriction on the name of a library imposed by the project
manager, except for stand-alone libraries whose names must follow the syntax
of Ada identifiers; however, there may be system-specific restrictions on the
name. In general, we recommend using only alphanumeric characters (and
possibly single underscores), to help portability.
Library_Dir: This attribute is the path (absolute or relative) of the
directory where the library is to be installed. In the process of building a
library, the sources are compiled and the object files are placed in the
explicitly- or implicitly specified Object_Dir directory. When all
sources of a library are compiled, some of the compilation artifacts,
including the library itself, are copied to the library_dir directory. This
directory must exist and be writable. It must also be different from the
object directory so that cleanup activities in the Library_Dir do not affect
recompilation needs.
Here is the new version of logging.gpr that makes it a library: library project Logging is -- "library" is optional Once the above two attributes are defined, the library project is valid and is sufficient for building a library with default characteristics. Other library-related attributes can be used to change the defaults: Library_Kind: The value of this attribute must be either
"static", "static-pic",
"dynamic" or "relocatable" (the last is a
synonym for "dynamic"). It indicates which kind of library
should be built (the default is to build a static library, that is an archive
of object files that can potentially be linked into a static executable). A
static-pic library is also an archive, but the code is Position Independent
Code, usually compiled with the switch -fPIC. When the library is set to be
dynamic, a separate image is created that will be loaded independently,
usually at the start of the main program execution. Support for dynamic
libraries is very platform specific, for instance on Windows it takes the form
of a DLL while on GNU/Linux, it is a dynamic elf image whose suffix is
usually .so. Library project files, on the other hand, can be written
in a platform independent way so that the same project file can be used to
build a library on different operating systems.
If you need to build both a static and a dynamic library, we recommend using two different object directories, since in some cases some extra code needs to be generated for the latter. For such cases, one can either define two different project files, or a single one that uses scenarios to indicate the various kinds of library to be built and their corresponding object_dir. Library_ALI_Dir: This attribute may be specified to indicate the directory
where the ALI files of the library are installed. By default, they are copied
into the Library_Dir directory, but as for the executables where we
have a separate Exec_Dir attribute, you might want to put them in a
separate directory since there may be hundreds of such files. The same
restrictions as for the Library_Dir attribute apply.
Library_Version: This attribute is platform dependent, and has no effect
on Windows. On Unix, it is used only for dynamic libraries as the internal
name of the library (the "soname"). If the library file name (built
from the Library_Name) is different from the Library_Version,
then the library file will be a symbolic link to the actual file whose name
will be Library_Version. This follows the usual installation schemes
for dynamic libraries on many Unix systems.
project Logging is After the compilation, the directory lib will contain both a liblogging.so.1 library and a symbolic link to it called liblogging.so. Library_GCC: This attribute is the name of the tool to use instead of
gcc to link shared libraries. A common use of this attribute is to
define a wrapper script that accomplishes specific actions before calling
gcc (which itself calls the linker to build the library image).
Library_Options: This attribute may be used to specify additional switches
("last switches") when linking a shared library or a static
standalone library. In the case of a simple static library, the values for
this attribute are restricted to paths to object files. Those paths may be
absolute or relative to the object directory.
Leading_Library_Options: This attribute, which is taken into account only by
GPRbuild, may be used to specify leading options ("first
switches") when linking a shared library.
Using Library ProjectsWhen the builder detects that a project file is a library project file, it recompiles all sources of the project that need recompilation and rebuilds the library if any of the sources have been recompiled. It then groups all object files into a single file, which is a shared or a static library. This library can later on be linked with multiple executables. Note that the use of shared libraries reduces the size of the final executable and can also reduce the memory footprint at execution time when the library is shared among several executables. GPRbuild also allows building multi-language libraries when specifying sources from multiple languages. A non-library project NLP can import a library project LP. When the builder is invoked on NLP, it always rebuilds LP even if all of the latter's files are up to date. For instance, let's assume in our example that logging has the following sources: log1.ads, log1.adb, log2.ads and log2.adb. If log1.adb has been modified, then the library liblogging will be rebuilt when compiling all the sources of Build even if proc.ads, pack.ads and pack.adb do not include a "with Log1". To ensure that all the sources in the Logging library are up to date, and that all the sources of Build are also up to date, the following two commands need to be used: gprbuild -Plogging.gpr gprbuild -Pbuild.gpr All ALI files will also be copied from the object directory to the library directory. To build executables, GPRbuild will use the library rather than the individual object files. Library projects can also be useful to specify a library that needs to be used but, for some reason, cannot be rebuilt. Such a situation may arise when some of the library sources are not available. Such library projects need to use the Externally_Built attribute as in the example below: library project Extern_Lib is In the case of externally built libraries, the Object_Dir attribute does not need to be specified because it will never be used. The main effect of using such an externally built library project is mostly to affect the linker command in order to reference the desired library. It can also be achieved by using Linker'Linker_Options or Linker'Switches in the project corresponding to the subsystem needing this external library. This latter method is more straightforward in simple cases but when several subsystems depend upon the same external library, finding the proper place for the Linker'Linker_Options might not be easy and if it is not placed properly, the final link command is likely to present ordering issues. In such a situation, it is better to use the externally built library project so that all other subsystems depending on it can declare this dependency through a project with clause, which in turn will trigger the builder to find the proper order of libraries in the final link command. Stand-alone Library ProjectsA stand-alone library is a library that contains the necessary code to elaborate the Ada units that are included in the library. A stand-alone library is a convenient way to add an Ada subsystem to a more global system whose main is not in Ada since it makes the elaboration of the Ada part mostly transparent. However, stand-alone libraries are also useful when the main is in Ada: they provide a means for minimizing relinking and redeployment of complex systems when localized changes are made. The name of a stand-alone library, specified with attribute Library_Name, must have the syntax of an Ada identifier. The most prominent characteristic of a stand-alone library is that it offers a distinction between interface units and implementation units. Only the former are visible to units outside the library. A stand-alone library project is thus characterized by a third attribute, usually Library_Interface, in addition to the two attributes that make a project a Library Project (Library_Name and Library_Dir). This third attribute may also be Interfaces. Library_Interface only works when the interface is in Ada and takes a list of units as parameter. Interfaces works for any supported language and takes a list of sources as parameter. Library_Interface: This attribute defines an explicit subset of the units of
the project. Units from projects importing this library project may only
"with" units whose sources are listed in the
Library_Interface. Other sources are considered implementation units.
for Library_Dir use "lib";
for Library_Name use "logging";
for Library_Interface use ("lib1", "lib2"); -- unit names
Interfaces This attribute defines an explicit subset of the source
files of a project. Sources from projects importing this project, can only
depend on sources from this subset. This attribute can be used on non library
projects. It can also be used as a replacement for attribute
Library_Interface, in which case, units have to be replaced by source
files. For multi-language library projects, it is the only way to make the
project a Stand-Alone Library project whose interface is not purely Ada.
Library_Standalone: This attribute defines the kind of stand-alone library to
build. Values are either standard (the default), no or
encapsulated. When standard is used the code to elaborate and
finalize the library is embedded, when encapsulated is used the library
can furthermore depend only on static libraries (including the GNAT runtime).
This attribute can be set to no to make it clear that the library
should not be stand-alone in which case the Library_Interface should
not defined. Note that this attribute only applies to shared libraries, so
Library_Kind must be set to dynamic or relocatable.
for Library_Dir use "lib";
for Library_Name use "logging";
for Library_Kind use "dynamic";
for Library_Interface use ("lib1", "lib2"); -- unit names
for Library_Standalone use "encapsulated";
In order to include the elaboration code in the stand-alone library, the binder is invoked on the closure of the library units creating a package whose name depends on the library name (b~logging.ads/b in the example). This binder-generated package includes initialization and finalization procedures whose names depend on the library name (logginginit and loggingfinal in the example). The object corresponding to this package is included in the library. Library_Auto_Init: A dynamic stand-alone Library is automatically
initialized if automatic initialization of stand-alone Libraries is supported
on the platform and if attribute Library_Auto_Init is not specified or
is specified with the value "true". Whether a static
stand-alone Library is automatically initialized is platform dependent.
Specifying "false" for the Library_Auto_Init attribute
prevents automatic initialization.
When a non-automatically initialized stand-alone library is used in an executable, its initialization procedure must be called before any service of the library is used. When the main subprogram is in Ada, it may mean that the initialization procedure has to be called during elaboration of another package. Library_Dir: For a stand-alone library, only the ALI files of
the interface units (those that are listed in attribute
Library_Interface) are copied to the library directory. As a
consequence, only the interface units may be imported from Ada units outside
of the library. If other units are imported, the binding phase will
fail.
Binder'Default_Switches: When a stand-alone library is bound, the switches that
are specified in the attribute Binder'Default_Switches
("Ada") are used in the call to gnatbind.
Library_Src_Dir: This attribute defines the location (absolute or relative
to the project directory) where the sources of the interface units are copied
at installation time. These sources includes the specs of the interface units
along with the closure of sources necessary to compile them successfully. That
may include bodies and subunits, when pragmas Inline are used, or when
there are generic units in specs. This directory cannot point to the object
directory or one of the source directories, but it can point to the library
directory, which is the default value for this attribute.
Library_Symbol_Policy: This attribute controls the export of symbols on some
platforms (like Windows, GNU/Linux). It is not supported on all platforms
(where it will just have no effect). It may have one of the following values:
Library_Symbol_File This attribute may define the name of the symbol file to
be used when building a stand-alone library when the symbol policy is
"restricted", on platforms that support symbol control. This
file must contain one symbol per line and only those symbols will be exported
from the stand-alone library.
Installing a Library with Project FilesWhen using project files, a usable version of the library is created in the directory specified by the Library_Dir attribute of the library project file. Thus no further action is needed in order to make use of the libraries that are built as part of the general application build. You may want to install a library in a context different from where the library is built. This situation arises with third party suppliers, who may want to distribute a library in binary form where the user is not expected to be able to recompile the library. The simplest option in this case is to provide a project file slightly different from the one used to build the library, by using the Externally_Built attribute. See Using Library Projects. Another option is to use gprinstall to install the library in a different context than the build location. The gprinstall tool automatically generates a project to use this library, and also copies the minimum set of sources needed to use the library to the install location. See Package Install Attributes. Project ExtensionDuring development of a large system, it is sometimes necessary to use modified versions of some of the source files, without changing the original sources. This can be achieved through the project extension facility. Suppose that our example Build project is built every night for the whole team, in some shared directory. A developer usually needs to work on a small part of the system, and might not want to have a copy of all the sources and all the object files since that could require too much disk space and too much time to recompile everything. A better approach is to override some of the source files in a separate directory, while still using the object files generated at night for the non-overridden shared sources. Another use case is a large software system with multiple implementations of a common interface; in Ada terms, multiple versions of a package body for the same spec, or perhaps different versions of a package spec that have the same visible part but different private parts. For example, one package might be safe for use in tasking programs, while another might be used only in sequential applications. A third example is different versions of the same system. For instance, assume that a Common project is used by two development branches. One of the branches has now been frozen, and no further change can be done to it or to Common. However, on the other development branch the sources in Common are still evolving. A new version of the subsystem is needed, which reuses as much as possible from the original. Each of these can be implemented in GNAT using project extension: If one project extends another project (the
base project) then by default all source files of the base project are
inherited by the extending project, but the latter can override any of the
base project's source files with a new version, and can also add new files or
remove unnecessary ones. A project can extend at most one base project.
This facility is somewhat analogous to class extension (with single inheritance) in object-oriented programming. Project extension hierarchies are permitted (an extending project may itself serve as a base project and be extended), and a project that extends a project can also import other projects. An extending project implicitly inherits all the sources and objects from its base project. It is possible to create a new version of some of the sources in one of the additional source directories of the extending project. Those new versions hide the original versions. As noted above, adding new sources or removing existing ones is also possible. Here is an example of how to extend the project Build from previous examples: project Work extends "../bld/build.gpr" is end Work; The project after the extends keyword is the base project being extended. As usual, it can be specified using an absolute path, or a path relative to any of the directories in the project path. The Work project does not specify source or object directories, so the default values for these attributes will be used; that is, the current directory (where project Work is placed). We can compile that project with gprbuild -Pwork If no sources have been placed in the current directory, this command has no effect, since this project does not change the sources it inherited from Build and thus all the object files in Build and its dependencies are still valid and are reused automatically. Suppose we now want to supply an alternative version of pack.adb but use the existing versions of pack.ads and proc.adb. We can create the new file in the Work project's directory (for example by copying the one from the Build project and making changes to it). If new packages are needed at the same time, we simply create new files in the source directory of the extending project. When we recompile, GPRbuild will now automatically recompile this file (thus creating pack.o in the current directory) and any file that depends on it (thus creating proc.o). Finally, the executable is also linked locally. Note that we could have obtained the desired behavior using project import rather than project inheritance. Some project proj would contain the sources for pack.ads and proc.adb, and Work would import proj and add pack.adb. In this situation proj cannot contain the original version of pack.adb since otherwise two versions of the same unit would be in project import closure of proj, which is not allowed. In general we do not recommended placing the spec and body of a unit in different projects, since this affects their autonomy and reusability. In a project file that extends another project, it is possible to indicate that an inherited source is not part of the sources of the extending project. This is necessary, for example, when a package spec has been overridden in such a way that a body is forbidden. In this case, it is necessary to indicate that the inherited body is not part of the sources of the project, otherwise there will be a compilation error. Two attributes are available for this purpose:
project Work extends "../bld/build.gpr" is All tool packages that are not declared in the extending project are inherited from the base project, with their attributes, with the exception of Linker'Linker_Options which is never inherited. In particular, an extending project retains all the switches specified in its base project. At the project level, if they are not declared in the extending project, some attributes are inherited from the base project. They are: Languages, Main (for a root non library project) and Library_Name (for a project extending a library project). Importing and Project ExtensionOne of the fundamental restrictions for project extension is the following: A project is not allowed to import, directly or
indirectly, both an extending project P and also some project that P
extends either directly or indirectly
In the absence of this rule, two imports might access different versions of the same source file, or different sets of tool switches for the same source file (one from the base project and the other from an extending project). As an example of this problem, consider the following set of project files:
Suppose we want to extend the projects as follows:
Since c_ext.gpr needs to access sources in b.gpr, it will import b.gpr Finally, main.gpr needs to access the overridden source files in a_ext.gpr and c_ext.gpr and thus will import these two projects. This project structure is as follows:
This violates the restriction above, since main.gpr imports the extending project a_ext.gpr and also (indirectly through c_ext.gpr and b.gpr) the project a.gpr that a_ext.gpr extends. The problem is that the import path through c_ext.gpr and b.gpr would build with the version of foo.adb from a.gpr, whereas the import path through a_ext.gpr would use that project's version of foo.adb. The error will be detected and reported by gprbuild. A solution is to introduce an "empty" extension of b.gpr, which is imported by c_ext.gpr and imports a_ext.gpr: with "a_ext.gpr"; project B_Ext extends "b.gpr" is end B_Ext; This project structure is as follows:
There is now no ambiguity over which version of foo.adb to use; it will be the one from a_ext.gpr. When extending a large system spanning multiple projects, it is often inconvenient to extend every project in the project import closure that is impacted by a small change introduced in a low layer. In such cases, it is possible to create an implicit extension of an entire hierarchy using the extends all relationship. When a project P is extended using extends all inheritance, all projects that are imported by P, both directly and indirectly, are considered virtually extended. That is, the project manager creates implicit projects that extend every project in the project import closure; all these implicit projects do not control sources on their own and use the object directory of the extends all project. It is possible to explicitly extend one or more projects in the import closure in order to adapt the sources. These extending projects must be imported by the extends all project, which will replace the corresponding virtual projects with the explicit ones. When building such a project closure extension, the project manager will ensure recompilation of both the modified sources and the sources in implicit extending projects that depend on them. To illustrate the extends all feature, here's a slight variation on the earlier examples. We have a Main project that imports project C, which imports B, which imports A. The source files in Main refer to compilation units whose sources are in C and A. (Recall that imports is transitive, so A is implicitly accessible in Main.) Thus:
Suppose that we want to extend a.gpr, overriding one of its source files, and create a new version of main.gpr that can access the overridden file in the extending project a_ext.gpr and otherwise use the sources in b.gpr and c.gpr. Instead of explicitly defining empty projects to extend b.gpr and c.gpr, we can create a new project main_ext.gpr that does an extends all of main.gpr and imports a_ext.gpr. The extends_all will implicitly create the empty projects b_ext.gpr and c_ext.gpr as well as the relevant import relationships:
Thus:
where the bracketed elements indicate what was created automatically as an effect of the extends_all. When project main_ext.gpr is built, the entire modified project space is considered for recompilation, including the sources from b.gpr and c.gpr that are affected by the changes to a.gpr. Child ProjectsIn order to more clearly express the relationship between a project Q and some other project P that Q either imports or extends, you can use the notation P.Q to declare Q as a child of P. The project P is then referred to as the parent of Q. This is useful, for example, when the purpose of the child is to serve as a testing subsystem for the parent. The visibility of the child on the sources and other properties of the parent is determined by whether the child imports or extends the parent. No additional visibility is obtained by declaring the project as a child; the parent.child notation serves solely as a naming convention to convey to the reader the closeness of the relationship between the projects. For example: -- math_proj.gpr project Math_Proj is Child projects may in turn be the parents of other projects, so in general a project hierarchy can be created. A project may be the parent of many child projects, but a child project can only have one parent. Note that child projects have slightly different semantics from their Ada language analog (child units). An Ada child unit implicitly withs its parent, whereas a child project must have an explicit with clause (or else extend its parent). The need to explicitly with or extend the parent project helps avoid the error of unintentionally creating a child of some project that happens to be on the project path. Aggregate ProjectsAggregate projects are an extension of the project paradigm, and are designed to handle a few specific situations that cannot be solved directly using standard projects. This section will present several such use cases. Building all main programs from a single project closureA large application is typically organized into modules and submodules, which are conveniently represented as a project graph (the project import closure): a "root" project A withs the projects for modules B and C, which in turn with projects for submodules. Very often, modules will build their own executables (for testing purposes for instance) or libraries (for easier reuse in various contexts). However, if you build your project through GPRbuild, using a syntax similar to gprbuild -PA.gpr this will only rebuild the main programs of project A, not those of the imported projects B and C. Therefore you have to spawn several GPRbuild commands, one per project, to build all executables. This is somewhat inconvenient, but more importantly is inefficient because GPRbuild needs to do duplicate work to ensure that sources are up-to-date, and cannot easily compile things in parallel when using the -j switch. Also, libraries are always rebuilt when building a project. To solve this problem you can define an aggregate project Agg that groups A, B and C: aggregate project Agg is Then, when you build with gprbuild -PAgg.gpr this will build all main programs from A, B and C. If B or C do not define any main program (through their Main attribute), all their sources are built. When you do not group them in an aggregate project, only those sources that are needed by A will be built. If you add a main to a project P not already explicitly referenced in the aggregate project, you will need to add p.gpr in the list of project files for the aggregate project, or the main will not be built when building the aggregate project. Building a set of projects with a single commandAnother application of aggregate projects is when you have multiple applications and libraries that are built independently (but can be built in parallel). For instance, you might have a project graph rooted at A, and another one (which might share some subprojects) rooted at B. Using only GPRbuild, you could do gprbuild -PA.gpr gprbuild -PB.gpr to build both. But again, GPRbuild has to do some duplicate work for those files that are shared between the two, and cannot truly build things in parallel efficiently. If the two projects are really independent, share no sources other than through a common subproject, and have no source files with a common basename, you could create a project C that imports A and B. But these restrictions are often too strong, and one has to build them independently. An aggregate project does not have these limitations and can aggregate two project graphs that have common sources: aggregate project Agg is This scenario is particularly useful in environments like VxWorks 653 where the applications running in the multiple partitions can be built in parallel through a single GPRbuild command. This also works well with Annex E of the Ada Language Reference Manual. Defining a build environmentThe environment variables at the time you launch GPRbuild will influence the view these tools have of the project (for example PATH to find the compiler, ADA_PROJECT_PATH or GPR_PROJECT_PATH to find the projects, and environment variables that are referenced in project files through the external built-in function). Several command line switches can be used to override those (-X or -aP), but on some systems and with some projects, this might make the command line too long, and on all systems often make it hard to read. An aggregate project can be used to set the environment for all projects built through that aggregate. One of the benefits is that you can put the aggregate project under configuration management, and make sure all your users have a consistent environment when building. For example: aggregate project Agg is Another use of aggregate projects is to simulate the referencing of external variables in with clauses, For technical reasons the following project file is not allowed: with external("SETUP") & "path/prj.gpr"; -- ILLEGAL
project MyProject is
However, you can use aggregate projects to obtain an equivalent effect: aggregate project Agg is with "prj.gpr"; -- searched on Agg'Project_Path project MyProject is Improving builder performanceThe loading of aggregate projects is optimized in GPRbuild, so that all files are searched for only once on the disk (thus reducing the number of system calls and yielding faster compilation times, especially on systems with sources on remote servers). As part of the loading, GPRbuild computes how and where a source file should be compiled, and even if it is located several times in the aggregated projects it will be compiled only once. Since there is no ambiguity as to which switches should be used, individual compilations, binds and links can be performed in parallel (through the usual -j switch) and this can be done while maximizing the use of CPUs (compared to launching multiple GPRbuild commands in parallel). The -j option can control parallelization of compilation, binding, and linking separately with -jc, -jb, and -jl variants accordingly. Syntax of aggregate projectsAn aggregate project follows the general syntax of project files. The recommended extension is still .gpr. However, a special aggregate qualifier must appear before the keyword project. An aggregate project cannot with any other project (standard or aggregate), except an abstract project (which can be used to share attribute values). Also, aggregate projects cannot be extended or imported though a with clause by any other project. Building other aggregate projects from an aggregate project is done through the Project_Files attribute (see below). An aggregate 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 project. Here is a (non exhaustive) list:
The Object_Dir attribute is allowed and used by some analysis tools such as gnatcheck to store intermediate files and aggregated results. The attribute value is just ignored by the compilation toolchain, for which every artifact of interest is best associated with the leaf non aggregate projects and stored in the corresponding Object_Dir. The package Naming and packages that control the compilation process (Compiler, Binder, Linker and Install) are forbidden. The following three attributes can be used only in an aggregate project: Project_Files: This attribute is compulsory. It specifies a list of
constituent .gpr files that are grouped in the aggregate. The list may
be empty. The project files can be any projects except configuration or
abstract projects; they can be other aggregate projects. When grouping
standard projects, you can have both the root of a project import closure (and
you do not need to specify all its imported projects), and any project within
the closure.
The basic idea is to specify all those projects that have main programs you want to build and link, or libraries you want to build. You can specify projects that do not use the Main attribute or the Library_* attributes, and the result will be to build all their source files (not just the ones needed by other projects). The file can include paths (absolute or relative). Paths are relative to the location of the aggregate project file itself (if you use a base name, the .gpr file is expected in the same directory as the aggregate project file). The environment variables ADA_PROJECT_PATH, GPR_PROJECT_PATH and GPR_PROJECT_PATH_FILE are not used to find the project files. The extension .gpr is mandatory, since this attribute contains file names, not project names. Paths can also include the "*" and "**" globbing patterns. The latter indicates that any subdirectory (recursively) will be searched for matching files. The "**" pattern can only occur at the last position in the directory part (i.e. "a/**/*.gpr" is supported, but not "**/a/*.gpr"). Starting the pattern with "**" is equivalent to starting with "./**". At present the pattern "*" is only allowed in the filename part, not in the directory part. This is mostly for efficiency reasons to limit the number of system calls that are needed. Here are a few examples: for Project_Files use ("a.gpr", "subdir/b.gpr");
-- two specific projects relative to the directory of agg.gpr
for Project_Files use ("**/*.gpr");
-- all projects recursively, except in the current directory
for Project_Files use ("**/*.gpr", "*.gpr");
-- all projects recursively
Project_Path: This attribute can be used to specify a list of
directories in which to search for project files in with clauses.
When you specify a project in Project_Files (say x/y/a.gpr), and a.gpr imports a project b.gpr, only b.gpr is searched in the project path. The file a.gpr must be exactly at dir of the aggregate/x/y/a.gpr. This attribute, however, does not affect the search for the aggregated project files specified with Project_Files. Each aggregate project has its own Project_Path (thus if agg1.gpr includes agg2.gpr, they can potentially both have a different Project_Path). This project path is defined as the concatenation, in this order, of:
In the example above, the project path for agg2.gpr is not influenced by the attribute agg1'Project_Path, nor is agg1 influenced by agg2'Project_Path. This can potentially lead to errors. Consider the following example: +---------------+ +----------------+ | agg1.gpr | | agg2.gpr | | 'project_path|----includes----->| 'project_path | | | | | +---------------+ +----------------+ When looking for p.gpr, both aggregates find the same physical file on the disk. However, it might happen that with their different project paths, both aggregate projects would in fact find a different r.gpr. Since we have a common project p.gpr withing two different r.gpr, this will be reported as an error by the builder. Directories are relative to the location of the aggregate project file. Example: for Project_Path use ("/usr/local/gpr", "gpr/");
External: This attribute can be used to set the value of
environment variables as retrieved through the external function in
projects. It does not affect the environment variables themselves (so for
instance you cannot use it to change the value of your PATH as seen
from the spawned compiler).
This attribute affects the external values as seen in the rest of the aggregate project, and in the aggregated projects. The exact value of an external variable comes from one of three sources (each level overrides the previous levels):
This attribute is only taken into account in the main aggregate project (i.e. the one specified on the command line to GPRbuild), and ignored in other aggregate projects. It is invalid in standard projects. The goal is to have a consistent value in all projects that are built through the aggregate, which would not be the case in a "diamond" situation: A groups the aggregate projects B and C, which both (either directly or indirectly) build the project P. If B and C could set different values for the environment variables, we would have two different views of P, which in particular might impact the list of source files in P. package Builder in aggregate projectsWhen used in an aggregate project, only the following attributes of this package are valid: Switches: This attribute gives the list of switches to use for
GPRbuild. Because no mains can be specified for aggregate projects, the
only possible index for attribute Switches is others. All other
indexes will be ignored.
Example: for Switches (others) use ("-v", "-k", "-j8");
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. Global_Compilation_Switches This attribute gives the list of compiler switches for
the various languages. For instance,
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 has 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, which both depend on C. Here is an example for all of these projects: aggregate project Agg is with "c.gpr"; project A is with "c.gpr"; project B is project C is 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. Global_Configuration_Pragmas This attribute can be used to specify a file containing
configuration pragmas, to be passed to the Ada compiler. Since we ignore the
package Builder in other aggregate projects and projects, only those
pragmas defined in the main aggregate project will be taken into account.
Projects can locally add to those by using the Compiler'Local_Configuration_Pragmas attribute if they need. Global_Config_File This attribute, indexed with a language name, can be used
to specify a config when compiling sources of the language. For Ada, these
files are configuration pragmas files.
For projects that are built through the aggregate mechanism, 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. Aggregate Library ProjectsAggregate 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 (for example a GUI, database access, and other) 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. Building aggregate library projectsFor example, we can define an aggregate project Agg that groups A, B and C: aggregate library project Agg is Then, when you build with: gprbuild agg.gpr this will build all units from projects A, B and C and will create a static library named libagg.a in the lagg directory. An aggregate library project has the same set of restrictions as a standard library project. Note that a shared aggregate library project cannot aggregate 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: aggregate library project Agg is With the above aggregate library Builder package, the -fPIC option will be passed to the compiler when building any source code from projects a.gpr, b.gpr and c.gpr. Syntax of aggregate library projectsAn aggregate library project follows the general syntax of project files. The recommended extension is still .gpr. However, a special aggregate library qualifier must appear before the keyword project. An aggregate library project cannot 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 a (non-exhaustive) list:
The only package that is allowed (and optional) is Builder. The Project_Files attribute is used to describe the aggregated projects whose object files have to be included into the aggregate library. The environment variables ADA_PROJECT_PATH, GPR_PROJECT_PATH and GPR_PROJECT_PATH_FILE are not used to find the project files. As for regular (not library) aggregate projects, the Object_Dir attribute is allowed and used by some analysis tools in the same fashion. Project File ReferenceThis section describes the syntactic structure of project files, explains the various constructs that can be used, and summarizes the available attributes. The syntax is presented in a notation similar to what is used in the Ada Language Reference Manual. Curly braces '{' and '}' indicate 0 or more occurrences of the enclosed construct, and square brackets '[' and ']' indicate 0 or 1 occurrence of the enclosed construct. Reserved words are enclosed between apostrophes. Project DeclarationProject files have an Ada-like syntax. The minimal project file is: project Empty is end Empty; The identifier Empty is the name of the project. This project name must be present after the reserved word end at the end of the project file, followed by a semicolon. Identifiers (i.e., the user-defined names such as project or variable names) have the same syntax as Ada identifiers: they must start with a letter, and be followed by zero or more letters, digits or underscore characters; it is also illegal to have two underscores next to each other. Identifiers are always case-insensitive ("Name" is the same as "name"). simple_name ::= identifier
name ::= simple_name { . simple_name }
Strings are used for values of attributes or as indexes for these attributes. They are in general case sensitive, except when noted otherwise (in particular, strings representing file names will be case insensitive on some systems, so that "file.adb" and "File.adb" both represent the same file). Reserved words are the standard Ada 95 reserved words, plus several others listed below, and cannot be used for identifiers. In particular, the following Ada 95 reserved words are currently used in project files: abstract all at case end for is limited null others package renames type use when with The additional project file reserved words are: extends external external_as_list project Note that aggregate and library are qualifiers that may appear before the keyword project, but they are not themselves keywords. To avoid possible compatibility issues in the future, we recommend that the reserved words introduced by Ada 2005 and Ada 2012 not be used as identifiers in project files. Note also that new reserved words may be added to the project file syntax in a later release. Comments in project files have the same syntax as in Ada, two consecutive hyphens through the end of the line. A project may be an independent project, entirely defined by a single project file. Any source file in an independent project depends only on the predefined library and other source files in the same project. Alternatively, a project may depend on other projects in various ways:
A given project may exhibit either or both of these dependencies; for example: with "imported_proj.gpr"; project My_Project extends "base_proj.gpr" is end My_Project; The import dependencies form a directed graph, potentially cyclic when using limited with. The subgraph reflecting the extends relationship is a tree (hierarchy). A path name denotes a project file. It can be absolute or relative. An absolute path name includes a sequence of directories, in the syntax of the host operating system, that uniquely identifies the project file in the file system. A relative path name identifies the project file, relative to the directory that contains the current project, or relative to a directory listed in the environment variables ADA_PROJECT_PATH and GPR_PROJECT_PATH. Path names are case sensitive if file names in the host operating system are case sensitive. As a special case, the directory separator can always be '/' even on Windows systems, so that project files can be made portable across architectures. The syntax of the environment variables ADA_PROJECT_PATH and GPR_PROJECT_PATH is a list of directory names separated by colons on Unix and semicolons on Windows. A given project name can appear only once in a context clause, and may not appear in different context clauses for the same project. It is illegal for a project imported by a context clause to refer, directly or indirectly, to the project in which this context clause appears (the dependency graph cannot contain cycles), except when one of the with clauses in the cycle is a limited with. A project's immediate sources are the source files directly defined by that project, either implicitly by residing in the project source directories, or explicitly through any of the source-related attributes. More generally, a project's sources are the immediate sources of the project together with the immediate sources (unless overridden) of any project on which it depends directly or indirectly.
Qualified ProjectsImmediately preceding the reserved project, a qualifier may be specified which identifies the nature of the project. The following qualifiers are allowed:
DeclarationsDeclarations introduce new entities that denote types, variables, attributes, and packages. Some declarations can only appear immediately within a project declaration. Others can appear within a project or within a package. declarative_item ::= simple_declarative_item An empty declaration is allowed anywhere a declaration is allowed. It has no effect. PackagesA project file may contain packages, which group attributes (typically all the attributes that are used by one of the GNAT tools). A package with a given name may only appear once in a project file. The following packages are currently supported in project files (See Attributes for the list of attributes that each can contain).
In its simplest form, a package may be empty: project Simple is A package may contain attribute declarations, variable declarations and case constructions, as will be described below. When there is ambiguity between a project name and a package name, the name always designates the project. To avoid possible confusion, it is always a good idea to avoid naming a project with one of the names allowed for packages or any name that starts with gnat. Package renaming A package may be defined by a renaming declaration. The new package renames a package declared in a different project file, and has the same attributes as the package it renames. The name of the renamed package must be the same as the name of the renaming package. The project must contain a package declaration with this name, and the project must appear in the context clause of the current project, or be its base or parent project. It is not possible to add or override attributes to the renaming project. If you need to do so, you should use an extending declaration (see below). Packages that are renamed in other project files often come from project files that have no sources: they are just used as templates. Any modification in the template will be reflected automatically in all the project files that rename a package from the template. This is a very common way to share settings between projects. Package extension A package can also be defined by an extending declaration. This is similar to a renaming declaration, except that it is possible to add or override attributes. package_declaration ::= package_spec | package_renaming | package_extension package_spec ::= ExpressionsAn expression is any value that can be assigned to an attribute or a variable. It is either a literal value, or a construct requiring run-time computation by the Project Manager. In a project file, the computed value of an expression is either a string or a list of strings. A string value is one of:
A list of strings is one of the following:
The following is the grammar for expressions string_literal ::= "{string_element}" -- Same as Ada
string_expression ::= string_literal
Concatenation involves strings and list of strings. As soon as a list of strings is involved, the result of the concatenation is a list of strings. The following Ada declarations show the existing operators: function "&" (X : String; Y : String) return String; function "&" (X : String_List; Y : String) return String_List; function "&" (X : String_List; Y : String_List) return String_List; Here are some specific examples: List := () & File_Name; -- One string in this list List2 := List & (File_Name & ".orig"); -- Two strings Big_List := List & Lists2; -- Three strings Illegal := "gnat.adc" & List2; -- Illegal, must start with list Built-in FunctionsBuilt-in functions may be used in expression. The names of built-in functions are not reserved words and may also be used as variable names. In an expression, a built-in function is recognized if its name is immediately followed by an open parenthesis ('('). The function externalAn external value is an expression whose value is obtained from the command that invoked the processing of the current project file (typically a gprbuild command). The syntax of a single string external value is: external_value ::= 'external' ( string_literal [, string_literal] ) The first string_literal is the name of the external variable, whose value (a string) may be specified by an environment variable with this name, or on the command line via the -Xname=value option. The command line takes precedence if the name is defined in both contexts, thus allowing the user to locally override an environment variable. The second string_literal, if present, is the default to use if there is no specification for this external value either on the command line or in the environment. If the value of the external variable is not obtained from an environment variable or the command line, and the invocation of the external function does not supply a second parameter, then an error is reported. An external reference may be part of a string expression or of a string list expression, and can therefore appear in a variable declaration or an attribute declaration. This construct is typically used to initialize typed variables, which are then used in case constructions to control the value assigned to attributes in various scenarios. Thus such variables are often called scenario variables. The function external_as_listAn external value is an expression whose value is obtained from the command that invoked the processing of the current project file (typically a gprbuild command). The syntax for a string list external value is: external_value ::= 'external_as_list' ( string_literal , string_literal ) The first string_literal is the name of the external variable, with the same interpretation as for the external function; it is looked up first on the command line (as the name in a -Xname=value option) and, if not so specified, then as an environment variable. If it is not defined by either of these, then the function returns an empty list. The second string_literal is the separator between each component of the string list. An empty list is returned if the separator is an empty string or if the external value is only one separator. Any separator at the beginning or at the end of the external value is discarded. Then, if there is no separator in the external value, the result is a string list with only one string. Otherwise, any string between the beginning and the first separator, between two consecutive separators and between the last separator and the end are components of the string list. Note the following differences between external and external_as_list:
These differences reflect the different use cases for the two functions. External variables evaluated by the external function are often used for configuration control, and misspellings should be detected as errors rather than silently returning the empty string. If the user intended an empty string as the result when the external variable was undefined, then this could easily be obtained: external ("SOME_VAR", "")
In contrast, the external_as_list function more typically is used for external variables that may or may not have definitions (for example, lists of options or paths) and then the desired result in the undefined case is an empty list, not a reported error. Here is an example of the external_as_list function: external_as_list ("SWITCHES", ",")
If the external value of SWITCHES is "-O2,-g", the result is ("-O2", "-g"). If the external value is ",-O2,-g,", the result is also ("-O2", "-g"). if the external value is "-gnatv", the result is ("-gnatv"). If the external value is ",,", the result is (""). If the external value is ",", the result is (), the empty string list. SplitFunction Split takes two single string parameters and return a string list. Example: Split ("-gnatf,-gnatv", ",")
=> ("-gnatf", "gnatv")
The first string argument is the string to be split. The second argument is the separator. Each occurrence of the separator in the first argument is a place where it is split. If the first argument is an empty string or contains only occurrences of the separator, then the result is an empty string list. If the argument does not contains any occurrence of the separator, then the result is a list with only one string: the first argument. Empty strings are not included in the result. Split ("-gnatf -gnatv", " ")
=> ("-gnatf", "gnatv")
Typed String DeclarationA type declaration introduces a discrete set of string literals. If a string variable is declared to have this type, its value is restricted to the given set of literals. These are the only named types in project files. A type declaration may only appear at the project level, not inside a package. typed_string_declaration ::= The string literals in the list are case sensitive and must all be different. They may include any graphic characters allowed in Ada, including spaces. Here is an example of a string type declaration: type OS is ("GNU/Linux", "Unix", "Windows", "VMS");
Variables of a string type are called typed variables; all other variables are called untyped variables. Typed variables are particularly useful in case constructions, to support conditional attribute declarations. (See Case Constructions). A string type may be referenced by its name if it has been declared in the same project file, or by an expanded name whose prefix is the name of the project in which it is declared. VariablesVariables store values (strings or list of strings) and can appear as part of an expression. The declaration of a variable creates the variable and assigns the value of the expression to it. The name of the variable is available immediately after the assignment symbol, if you need to reuse its old value to compute the new value. Before the completion of its first declaration, the value of a variable defaults to the empty string (""). A typed variable can be used as part of a case expression to compute the value, but it can only be declared once in the project file, so that all case constructions see the same value for the variable. This provides more consistency and makes the project easier to understand. The syntax for its declaration is identical to the Ada syntax for an object declaration. In effect, a typed variable acts as a constant. An untyped variable can be declared and overridden multiple times within the same project. It is declared implicitly through an Ada assignment. The first declaration establishes the kind of the variable (string or list of strings) and successive declarations must respect the initial kind. Assignments are executed in the order in which they appear, so the new value replaces the old one and any subsequent reference to the variable uses the new value. A variable may be declared at the project file level, or within a package. typed_variable_declaration ::= Here are some examples of variable declarations: This_OS : OS := external ("OS"); -- a typed variable declaration
That_OS := "GNU/Linux"; -- an untyped variable declaration
Name := "readme.txt";
Save_Name := Name & ".saved";
Empty_List := ();
List_With_One_Element := ("-gnaty");
List_With_Two_Elements := List_With_One_Element & "-gnatg";
Long_List := ("main.ada", "pack1_.ada", "pack1.ada", "pack2_.ada");
A variable reference may take several forms:
A context may be one of the following:
Case ConstructionsA case construction is used in a project file to effect conditional behavior. Through this construction, you can set the value of attributes and variables depending on the value previously assigned to a typed variable. All choices in a choice list must be distinct. Unlike Ada, the choice lists of all alternatives do not need to include all values of the type. An others choice must appear last in the list of alternatives. The syntax of a case construction is based on the Ada case construction (although the null declaration for empty alternatives is optional). The case expression must be a string variable, either typed or not, whose value is often given by an external reference (see The function external). Each alternative starts with the reserved word when, either a list of literal strings separated by the "|" character or the reserved word others, and the "=>" token. When the case expression is a typed string variable, each literal string must belong to the string type that is the type of the case variable. After each =>, there are zero or more declarations. The only declarations allowed in a case construction are other case constructions, attribute declarations, and variable declarations. String type declarations and package declarations are not allowed. Variable declarations are restricted to variables that have already been declared before the case construction. case_construction ::= Here is a typical example, with a typed string variable: project MyProj is AttributesA project (and its packages) may have attributes that define the project's properties. Some attributes have values that are strings; others have values that are string lists. attribute_declaration ::= There are two categories of attributes: simple attributes and indexed attributes. Each simple attribute has a default value: the empty string (for string attributes) and the empty list (for string list attributes). An attribute declaration defines a new value for an attribute, and overrides the previous value. The syntax of a simple attribute declaration is similar to that of an attribute definition clause in Ada. Some attributes are indexed. These attributes are mappings whose domain is a set of strings. They are declared one association at a time, by specifying a point in the domain and the corresponding image of the attribute. Like untyped variables and simple attributes, indexed attributes may be declared several times. Each declaration supplies a new value for the attribute, and replaces the previous setting. Here are some examples of attribute declarations: -- simple attributes
for Object_Dir use "objects";
for Source_Dirs use ("units", "test/drivers");
-- indexed attributes
for Body ("main") use "Main.ada";
for Switches ("main.ada")
When an attribute is defined in the configuration project but not in the user project, it is inherited in the user project. When a single string attribute is defined in both the configuration project and the user project, its value in the user project is as declared; the value in the configuration project does not matter. For string list attributes, there are two cases. Some of these attributes are configuration concatenable. For these attributes, when they are declared in both the configuration project and the user project, the final value is the concatenation of the value in the configuration project with the value in the user project. The configuration concatenable attributes are indicated in the list below. Attributes references may appear anywhere in expressions, and are used to retrieve the value previously assigned to the attribute. If an attribute has not been set in a given package or project, its value defaults to the empty string or the empty list, with some exceptions. attribute_reference ::= Here are some examples: project'Object_Dir
Naming'Dot_Replacement
Imported_Project'Source_Dirs
Imported_Project.Naming'Casing
Builder'Default_Switches ("Ada")
The exceptions to the empty defaults are:
The prefix of an attribute may be:
In the following sections, all predefined attributes are succinctly described, first the project level attributes (that is, those attributes that are not in a package), then the attributes in the different packages. It is possible for different tools to dynamically create new packages with attributes, or new attributes in predefined packages. These attributes are not documented here. The attributes under Configuration headings are usually found only in configuration project files. The characteristics of each attribute are indicated as follows:
Project Level Attributes
for Inherit_Source_Path ("C++") use ("C");
Package Binder Attributes
Package Builder Attributes
Index is a language name. Value is the list of builder switches to be used when building an executable of the language, if there is no applicable attribute Switches.
Index is either a language name or a source file name. Value is the list of builder switches to be used when building an executable. Index is either the source file name of the executable to be built or its language name.
Index is a language name. Value is the list of compilation switches to be used when building an executable. Index is either the source file name of the executable to be built or its language name.
Package Check Attributes
Package Clean Attributes
Package Compiler Attributes
Package Cross_Reference Attributes
Package Documentation AttributesPlease refer to GNATdoc documentation for the list of supported attributes and their meaning. Package Finder Attributes
Package Gnatls Attributes
Package gnatstub Attributes
Package IDE AttributesPlease refer to your IDE documentation for the list of supported attributes and their meaning. Package Install Attributes
Package Linker Attributes
Package Metrics Attribute
Package Naming Attributes
Also has case-insensitive values in gprbuild and
GNATcool.Project-based tools
Also has case-insensitive values in gprbuild and
GNATcool.Project-based tools
Also has case-insensitive values in gprbuild and
GNATcool.Project-based tools
Also has case-insensitive values in gprbuild and
GNATcool.Project-based tools
Package Pretty_Printer Attributes
Package Remote Attributes
Package Stack Attributes
Package Synchronize Attributes
Environment VariablesProject processing can be affected by environment variables.
Glossary
BUILDING WITH GPRBUILDIntroductionGPRbuild is a generic build tool designed for the construction of large multi-language systems organized into subsystems and libraries. It is well-suited for compiled languages supporting separate compilation, such as Ada, C, C++ and Fortran. GPRbuild manages a three step build process.
The tool is generic in that it provides, when possible, equivalent build capabilities for all supported languages. For this, it uses a configuration file <file>.cgpr that has a syntax and structure very similar to a project file, but which defines the characteristics of the supported languages and toolchains. The configuration file contains information such as:
On the other hand, GPRbuild is not a replacement for general-purpose build tools such as make or ant which give the user a high level of control over the build process itself. When building a system requires complex actions that do not fit well in the three-phase process described above, GPRbuild might not be sufficient. In such situations, GPRbuild can still be used to manage the appropriate part of the build. For instance it can be called from within a Makefile. Command LineThree elements can optionally be specified on GPRbuild's command line:
The general syntax is thus: gprbuild [<proj>.gpr] [switches] [names] GPRbuild requires a project file, which may be specified on the command line either directly or through the -P switch. If not specified, GPRbuild uses the project file default.gpr if there is one in the current working directory. Otherwise, if there is only one project file in the current working directory, GPRbuild uses this project file. Main source files represent the sources to be used as the main programs. If they are not specified on the command line, GPRbuild uses the source files specified with the Main attribute in the project file. If none exists, then no executable will be built. It is also possible to specify absolute file names, or file names relative to the current directory. When source files are specified along with the option -c, then recompilation will be considered only for those source files. In all other cases, GPRbuild compiles or recompiles all sources in the project tree that are not up to date, and builds or rebuilds libraries that are not up to date. If invoked without the --config= or --autoconf= options, then GPRbuild will look for a configuration project file. The file name or path name of this configuration project file depends on the target, the runtime and environment variable GPR_CONFIG See Configuring with GPRconfig <#configuring-with-gprconfig>. If there is no such file in the default locations expected by GPRbuild (<install>/share/gpr and the current directory) then GPRbuild will invoke GPRconfig with the languages from the project files, and create a configuration project file auto.cgpr in the object directory of the main project. The project auto.cgpr will be rebuilt at each GPRbuild invocation unless you use the switch --autoconf=path/auto.cgpr, which will use the configuration project file if it exists and create it otherwise. Options given on the GPRbuild command line may be passed along to individual tools by preceding them with one of the "command line separators" shown below. Options following the separator, up to the next separator (or end of the command line), are passed along. The different command line separators are:
SwitchesGPRbuild takes into account switches that may be specified on the command line or in attributes Switches(<main or language>) or Default_Switches (<language>) in package Builder of the main project. When there are a single main (specified on the command line or in attribute Main in the main project), the switches that are taken into account in package Builder of the main project are Switches (<main>), if declared, or Switches (<language of main>), if declared. When there are several mains, if there are sources of the same language, then Switches (<language of main>) is taken into account, if specified. When there are no main specified, if there is only one compiled language (that is a language with a non empty Compiler Driver), then Switches (<single language>) is taken into account, if specified. The switches that are interpreted directly by GPRbuild are listed below. First, the switches that may be specified only on the command line, but not in package Builder of the main project:
$ gprbuild --hash=$(echo $ADA_PROJECT_PATH | shasum) --distributed=...
Then, the switches that may be specified on the command line as well as in package Builder of the main project (attribute Switches):
Switches that are accepted for compatibility with gnatmake, either on the command line or in the Builder Ada switches in the main project file:
These switches are passed to the Ada compiler. InitializationBefore performing one or several of its three phases, GPRbuild has to read the command line, obtain its configuration, and process the project files. If GPRbuild is invoked with an invalid switch or without any project file on the command line, it will fail immediately. Examples: $ gprbuild -P gprbuild: project file name missing after -P $ gprbuild -P c_main.gpr -WW gprbuild: illegal option "-WW" GPRbuild looks for the configuration project file first in the current working directory, then in the default configuration project directory. If the GPRbuild executable is located in a subdirectory <prefix>/bin, then the default configuration project directory is <prefix>/share/gpr, otherwise there is no default configuration project directory. When it has found its configuration project path, GPRbuild needs to obtain its configuration. By default, the file name of the main configuration project is default.cgpr. This default may be modified using the switch --config=... Example: $ gprbuild --config=my_standard.cgpr -P my_project.gpr If GPRbuild cannot find the main configuration project on the configuration project path, then it will look for all the languages specified in the user project tree and invoke GPRconfig to create a temporary configuration project file. This file is located in the directory computed by the following sequence: * Look for a valid absolute path in the environment variables TMPDIR, TEMP, and TMP. * If this fails, check some predefined platform-specific temp dirs (e.g. /tmp for linux). * Finally if none is accessible we fall back onto the current working directory. The invocation of GPRconfig will take into account the target, if specified either by switch --target= on the command line or by attribute Target in the main project. Also, if Ada is one of the languages, it will take into account the Ada runtime directory, specified either by switches --RTS= or --RTS:ada= on the command line or by attribute Runtime ("Ada") in the main project file. If the Ada runtime is specified as a relative path, gprbuild will try to locate the Ada runtime directory as a subdirectory of the main project directory, or if environment variable GPR_RUNTIME_PATH is defined in the path specified by GPR_RUNTIME_PATH. Once it has found the configuration project, GPRbuild will process its configuration: if a single string attribute is specified in the configuration project and is not specified in a user project, then the attribute is added to the user project. If a string list attribute is specified in the configuration project then its value is prepended to the corresponding attribute in the user project. After GPRbuild has processed its configuration, it will process the user project file or files. If these user project files are incorrect then GPRbuild will fail with the appropriate error messages: $ gprbuild -P my_project.gpr ada_main.gpr:3:26: "src" is not a valid directory gprbuild: "my_project.gpr" processing failed Once the user project files have been dealt with successfully, GPRbuild will start its processing. Compilation of one or several sourcesIf GPRbuild is invoked with -u or -U and there are one or several source file names specified on the command line, GPRbuild will compile or recompile these sources, if they are not up to date or if -f is also specified. Then GPRbuild will stop its execution. The options/switches used to compile these sources are described in section Compilation Phase. If GPRbuild is invoked with -u and no source file name is specified on the command line, GPRbuild will compile or recompile all the sources of the main project and then stop. In contrast, if GPRbuild is invoked with -U, and again no source file name is specified on the command line, GPRbuild will compile or recompile all the sources of all the projects in the project tree and then stop. Compilation PhaseWhen switch -c is used or when switches -b or -l are not used, GPRbuild will first compile or recompile the sources that are not up to date in all the projects in the project tree. The sources considered are:
Attribute Roots takes as an index a main and a string list value. Each string in the list is the name of an Ada library unit. Example: for Roots ("main.c") use ("pkga", "pkgb");
Package PkgA and PkgB will be considered, and all the Ada units in their closure will also be considered. GPRbuild will first consider each source and decide if it needs to be (re)compiled. A source needs to be compiled in the following cases:
When a source is successfully compiled, the following files are normally created in the object directory of the project of the source:
The compiler for the language corresponding to the source file name is invoked with the following switches/options:
If compilation is needed, then all the options/switches, except those described as 'Various other options' are written to the switch file. The switch file is a text file. Its file name is obtained by replacing the suffix of the source with .cswi. For example, the switch file for source main.adb is main.cswi and for toto.c it is toto.cswi. If the compilation is successful, then if the creation of the dependency file is not done during compilation but after (see configuration attribute Compute_Dependency), then the process to create the dependency file is invoked. For each project file, attribute Interfaces may be declared. Its value is a list of sources or header files of the project file. For a project file extending another one, directly or indirectly, inherited sources may be in the list. When Interfaces is not declared, all sources or header files are part of the interface of the project. When Interfaces is declared, only those sources or header files are part of the interface of the project file. After a successful compilation, gprbuild checks that all imported or included sources or header files that are from an imported project are part of the interface of the imported project. If this check fails, the compilation is invalidated and the compilation artifacts (dependency, object and switches files) are deleted. Example: project Prj is If a source from a project importing project Prj imports sources from Prj other than package Pkg or includes header files from Prj other than "toto.h", then its compilation will be invalidated. Simultaneous compilationIf GPRbuild is invoked with a switch -j specifying more than one compilation process, then several compilation processes for several sources of possibly different languages are spawned concurrently. Furthermore, GPRbuild is GNU make jobserver compatible when using the switch --autodetect-jobserver. This means if GPRbuild is embedded in a GNU make recursive invocation and --autodetect-jobserver is set, then GPRbuild will only spawn an additionnal compilation process if GNU make's jobserver allows it. This is particularly useful to ensure that GPRbuild comply to the ressource management of GNU make. Example: build1: calling make build_all -j4 will spawn two GPRbuild processes, resulting in two remaining and available slots for both GPRbuild compilation phase. Note: If --autodetect-jobserver is set, then any -jnum will simply be ignored by GPRbuild and a warning will be issued. Post-Compilation PhaseThe post-compilation phase has two parts: library building and program binding. If there are libraries that need to be built or rebuilt, gprbuild will call the library builder, specified by attribute Library_Builder. This is generally the tool gprlib, provided with GPRbuild. If gprbuild can determine that a library is already up to date, then the library builder will not be called. If there are mains specified, and for these mains there are sources of languages with a binder driver (specified by attribute Binder'Driver (<language>), then the binder driver is called for each such main, but only if it needs to. For Ada, the binder driver is normally gprbind, which will call the appropriate version of gnatbind, that either the one in the same directory as the Ada compiler or the fist one found on the path. When neither of those is appropriate, it is possible to specify to gprbind the full path of gnatbind, using the Binder switch --gnatbind_path=. Example: package Binder is If GPRbuild can determine that the artifacts from a previous post-compilation phase are already up to date, the binder driver is not called. If there are no libraries and no binder drivers, then the post-compilation phase is empty. Linking PhaseWhen there are mains specified, either in attribute Main or on the command line, and these mains are not up to date, the linker is invoked for each main, with all the specified or implied options, including the object files generated during the post-compilation phase by the binder drivers. If switch -jnnn is used, with nnn other than 1, gprbuild will attempt to link simultaneously up to nnn executables. Introduction to distributed compilationFor large projects the compilation time can become a limitation in the development cycle. To cope with that, GPRbuild supports distributed compilation. In the distributed mode, the local machine (called the build master) compiles locally but also sends compilation requests to remote machines (called the build slaves). The compilation process can use one or more build slaves. Once the compilation phase is done, the build master will conduct the binding and linking phases locally. Setup build environmentsThe configuration process to be able to use the distributed compilation support is the following:
package Remote is
When all the requirement are set, just launch the slave driver: $ gprslave When all this is done, the remote compilation can be used simply by running GPRbuild in distributed mode from the build master: $ gprbuild --distributed=comp1.xyz.com,comp2.xyz.com prj.gpr Alternatively the slaves can be set using the GPR_SLAVES environment variable. So the following command is equivalent to the above: $ export GPR_SLAVES=comp1.xyz.com,comp2.xyz.com $ gprbuild --distributed prj.gpr A third alternative is proposed using a list of slaves in a file (one per line). In this case the GPR_SLAVES_FILE environment variable must contain the path name to this file: $ export GPR_SLAVES_FILE=$HOME/slave-list.txt $ gprbuild --distributed prj.gpr Finally note that the search for the slaves are in this specific order. First the command line values, then GPR_SLAVES if set and finally GPR_SLAVES_FILES. The build slaves are specified with the following form: <machine_name>[:port] GPRslaveThis is the slave driver in charge of running the compilation jobs as requested by the build master. One instance of this tool must be launched in each build slave referenced in the project file. Compilations for a specific project are conducted under a sub-directory from where the slave is launched by default. This can be overridden with the -d option below. The current options are:
$ gprslave --hash=$(echo $ADA_PROJECT_PATH | shasum)
Note that a slave can be pinged to see if it is running and in response a set of information are delivered. The ping command has the following format: <lower-bound><upper-bound>PG When <lower-bound> and <upper-bound> are 32bits binary values for the PG string command. As an example here is how to send a ping command from a UNIX shell using the echo command: echo -e "\x01\x00\x00\x00\x02\x00\x00\x00PG" | nc <HOSTNAME> 8484 The answer from the ping command has the following format:
The ASCII.GS is the Group Separator character whose code is 29. GPRBUILD COMPANION TOOLSThis chapter describes the various tools that can be used in conjunction with GPRbuild. ConfigurationGPRbuild requires one configuration file describing the languages and toolchains to be used, and project files describing the characteristics of the user project. Typically the configuration file can be created automatically by GPRbuild based on the languages defined in your projects and the compilers on your path. In more involved situations --- such as cross compilation, or environments with several compilers for the same language --- you may need to control more precisely the generation of the desired configuration of toolsets. A tool, GPRconfig, described in Configuring with GPRconfig), offers this capability. In this chapter most of the examples can use autoconfiguration. GPRbuild will start its build process by trying to locate a configuration file, using the following rules.
GPRbuild assumes that there are known compilers on your path for each of the necessary languages. A user can manually generate a configuration file (and reference it using --config switch); this is especially useful when:
GPRconfig provides several ways of generating configuration files. By default, a simple interactive mode lists all the known compilers for all known languages. You can then select a compiler for each of the languages; once a compiler has been selected, only compatible compilers for other languages are proposed. Here are a few examples of GPRconfig invocation:
gprconfig
gprconfig -o path/my_config.cgpr gprbuild --config=path/my_config.cgpr
gprconfig --target=ppc-elf
gprconfig --config=Ada --config=C --batch
gprconfig --target=leon-elf --config=Ada,,hi --config=C --batch -o x.cgpr DescriptionThe GPRconfig tool helps you generate the configuration files for GPRbuild. It automatically detects the available compilers on your system and, after you have selected the one needed for your application, it generates the proper configuration file. Note: In general, you will not launch GPRconfig explicitly.
Instead, it is used implicitly by GPRbuild through the use of --config
and --autoconf switches.
Command line argumentsGPRconfig supports the following command line switches: --target=platform This switch indicates the target computer on which your
application will be run. It is mostly useful for cross configurations.
Examples include ppc-elf, ppc-vx6-windows. It can also be used
in native configurations and is useful when the same machine can run different
kind of compilers such as mingw32 and cygwin on Windows or x86-32 and x86-64
on GNU Linux. Since different compilers will often return a different name for
those targets, GPRconfig has an extensive knowledge of which targets are
compatible, and will for example accept x86-linux as an alias for
i686-pc-linux-gnu. The default target is the machine on which GPRconfig
is run.
If you enter the special target all, then all compilers found on the PATH will be displayed. --show-targets As mentioned above, GPRconfig knows which targets are
compatible. You can use this switch to find the list of targets that are
compatible with --target.
--config=language[,version[,runtime[,path[,name]]]] The intent of this switch is to preselect one or more
compilers directly from the command line. This switch takes several optional
arguments, which you can omit simply by passing the empty string. When
omitted, the arguments will be computed automatically by GPRconfig.
In general, only language needs to be specified, and the first compiler on the PATH that can compile this language will be selected. As an example, for a multi-language application programmed in C and Ada, the command line would be: --config=Ada --config=C path is the directory that contains the compiler executable, for instance /usr/bin (and not the installation prefix /usr). name should be one of the compiler names defined in the GPRconfig knowledge base. The list of supported names includes GNAT, GCC,.... This name is generally not needed, but can be used to distinguish among several compilers that could match the other arguments of --config. Another possible more frequent use of name is to specify the base name of an executable. For instance, if you prefer to use a diab C compiler (executable is called dcc) instead of gcc, even if the latter appears first in the path, you could specify dcc as the name parameter. gprconfig --config Ada,,,/usr/bin # automatic parameters gprconfig --config C,,,/usr/bin,GCC # automatic version gprconfig --config C,,,/usr/bin,gcc # same as above, with exec name This switch is also the only possibility to include in your project some languages that are not associated with a compiler. This is sometimes useful especially when you are using environments like GPS that support project files. For instance, if you select "Project file" as a language, the files matching the .gpr extension will be shown in the editor, although they of course play no role for gprbuild itself. --batch If this switch is specified, GPRconfig automatically
selects the first compiler matching each of the --config switches, and
generates the configuration file immediately. It will not display an
interactive menu.
-o file This specifies the name of the configuration file that
will be generated. If this switch is not specified, a default file is
generated in the installation directory of GPRbuild (assuming you have write
access to that directory), so that it is automatically picked up by GPRbuild
later on. If you select a different output file, you will need to specify it
to GPRbuild.
Interactive useWhen you launch GPRconfig, it first searches for all compilers it can find on your PATH, that match the target specified by --target. It is recommended, although not required, that you place the compilers that you expect to use for your application in your PATH before you launch gprconfig, since that simplifies the setup. GPRconfig then displays the list of all the compilers it has found, along with the language they can compile, the run-time they use (when applicable),.... It then waits for you to select one of the compilers. This list is sorted by language, then by order in the PATH environment variable (so that compilers that you are more likely to use appear first), then by run-time names and finally by version of the compiler. Thus the first compiler for any language is most likely the one you want to use. You make a selection by entering the letter that appears on the line for each compiler (be aware that this letter is case sensitive). If the compiler was already selected, it is deselected. A filtered list of compilers is then displayed: only compilers that target the same platform as the selected compiler are now shown. GPRconfig then checks whether it is possible to link sources compiled with the selected compiler and each of the remaining compilers; when linking is not possible, the compiler is not displayed. Likewise, all compilers for the same language are hidden, so that you can only select one compiler per language. As an example, if you need to compile your application with several C compilers, you should create another language, for instance called C2, for that purpose. That will give you the flexibility to indicate in the project files which compiler should be used for which sources. The goal of this filtering is to make it more obvious whether you have a good chance of being able to link. There is however no guarantee that GPRconfig will know for certain how to link any combination of the remaining compilers. You can select as many compilers as are needed by your application. Once you have finished selecting the compilers, select s, and GPRconfig will generate the configuration file. The GPRconfig knowledge baseGPRconfig itself has no hard-coded knowledge of compilers. Thus there is no need to recompile a new version of GPRconfig when a new compiler is distributed. Note: The role and format of the knowledge base are irrelevant
for most users of GPRconfig, and are only needed when you need to add support
for new compilers. You can skip this section if you only want to learn how to
use GPRconfig.
All knowledge of compilers is embedded in a set of XML files called the knowledge base. Users can easily contribute to this general knowledge base, and have GPRconfig immediately take advantage of any new data. The knowledge base contains various kinds of information:
The end of this section will describe in more detail the format of this knowledge base, so that you can add your own information and have GPRconfig advantage of it. General file formatThe knowledge base is implemented as a set of XML files. None of these files has a special name, nor a special role. Instead, the user can freely create new files, and put them in the knowledge base directory, to contribute new knowledge. The location of the knowledge base is $prefix/share/gprconfig, where $prefix is the directory in which GPRconfig was installed. Any file with extension .xml in this directory will be parsed automatically by GPRconfig at startup after sorting them alphabetically. All files must have the following format: <?xml version="1.0" ?> <gprconfig> The root tag must be <gprconfig>. The remaining sections in this chapter will list the valid XML tags that can be used to replace the '...' code above. These tags can either all be placed in a single XML file, or split across several files. Compiler descriptionOne of the XML tags that can be specified as a child of <gprconfig> is <compiler_description>. This node and its children describe one of the compilers known to GPRconfig. The tool uses them when it initially looks for all compilers known on the user's PATH environment variable. This is optional information, but simplifies the use of GPRconfig, since the user is then able to omit some parameters from the --config command line argument, and have them automatically computed. The <compiler_description> node doesn't accept any XML attribute. However, it accepts a number of child tags that explain how to query the various attributes of the compiler. The child tags are evaluated (if necessary) in the same order as they are documented below.
<compiler_description> <name>GNAT</name> </compiler_description>
<compilers> <executable prefix="1">(powerpc-wrs-vxworks-)?gnatmake</executable>
<version><external>${PREFIX}gnatls -v</external></version>
GPRconfig searches in all directories listed on the PATH for such an executable. When one is found, the rest of the <compiler_description> children are checked to know whether the compiler is valid. The directory in which the executable was found becomes the 'current directory' for the remaining XML children.
GPRconfig external valuesA number of the XML nodes described above can contain one or more children, and specify how to query a value from an executable. Here is the list of valid contents for these nodes. The <directory> and <external> children can be repeated multiple times, and the <filter> and <must_match> nodes will be applied to each of these. The final value of the external value is the concatenation of the computation for each of the <directory> and <external> nodes.
<compiler_description> <name>GNAT</name> <executable>gnatmake</executable> <languages>Ada</languages> </compiler_description> for the GNAT compiler, since this is an Ada-only compiler. Variables can be referenced in simple strings.
<compiler_description> <name>GCC-WRS</name> <executable prefix="1">cc(arm|pentium)</executable> <version> <getenv name="WIND_BASE" /> </version> </compile_description>
<version> <external>gcc -dumpmachine</external> </version> Since the PATH has been modified, we know that the gcc command that is executed is the one from the same directory as the <external> node. Variables are substituted in command.
<version> <external>gcc -v</external> <grep regexp="^gcc version (\S+)" group="1" /> </version>
<runtimes>
<directory group="1">
\.\./lib/gcc/${TARGET/.*/rts-(.*)/adainclude
</directory>
<directory group="default">
\.\./lib/gcc/${TARGET}/.*/adainclude
</directory>
</runtimes>}
Note the second node, which matches the default run-time, and displays it as such.
<languages> <external regexp="languages=(\S+)" group="1">gcc -v</external> <filter>c,c++,fortran</filter> </languages>
<version> <external regexp="gcc version (\S+)" group="1">gcc -v </external> <must_match>2.8.1</must_match> </version> Other versions of gcc will not match this <compiler_description> node. GPRconfig variable substitutionThe various compiler attributes defined above are made available as variables in the rest of the XML files. Each of these variables can be used in the value of the various nodes (for instance in <directory>), and in the configurations (Configuration). A variable is referenced by ${name} where name is either a user variable or a predefined variable. An alternate reference is $name where name is a sequence of alpha numeric characters or underscores. Finally $$ is replaced by a simple $. User variables are defined by <variable> nodes and may override predefined variables. To avoid a possible override use lower case names. The variables are used in two contexts: either in a <compiler_description> node, in which case the variable refers to the compiler we are describing, or within a <configuration> node. In the latter case, and since there might be several compilers selected, you need to further specify the variable by adding in parenthesis the language of the compiler you are interested in. For instance, the following is invalid: <configuration> <compilers> <compiler name="GNAT" /> </compilers> <targets negate="true"> <target name="^powerpc-elf$"/> </targets> <config> package Compiler is The trouble with the above is that if you are using multiple languages like C and Ada, both compilers will match the "negate" part, and therefore there is an ambiguity for the value of ${PATH}. To prevent such issues, you need to use the following syntax instead when inside a <configuration> node: for Driver ("Ada") use "${PATH(ada)}gcc"; -- Correct
Predefined variables are always in upper case. Here is the list of predefined variables
If a variable is not defined, an error message is issued and the variable is substituted by an empty string. ConfigurationsThe second type of information stored in the knowledge base are the chunks of gprbuild configuration files. Each of these chunks is also placed in an XML node that provides optional filters. If all the filters match, then the chunk will be merged with other similar chunks and placed in the final configuration file that is generated by GPRconfig. For instance, it is possible to indicate that a chunk should only be included if the GNAT compiler with the soft-float runtime is used. Such a chunk can for instance be used to ensure that Ada sources are always compiled with the -msoft-float command line switch. GPRconfig does not perform sophisticated merging of chunks. It simply groups packages together. For example, if the two chunks are: chunk1: Then the final configuration file will look like: package Language_Processing is As a result, to avoid conflicts, it is recommended that the chunks be written so that they easily collaborate together. For instance, to obtain something equivalent to package Language_Processing is the two chunks above should be written as: chunk1: The chunks are described in a <configuration> XML node. The most important child of such a node is <config>, which contains the chunk itself. For instance, you would write: <configuration> If <config> is an empty node (i.e., <config/> or <config></config> was used), then the combination of selected compilers will be reported as invalid, in the sense that code compiled with these compilers cannot be linked together. As a result, GPRconfig will not create the configuration file. The special variables (GPRconfig variable substitution) are also substituted in the chunk. That allows you to compute some attributes of the compiler (its path, the runtime,...), and use them when generating the chunks. The filters themselves are of course defined through XML tags, and can be any of:
<configuration> If the attribute negate is true, then the meaning of this filter is inverted, and it will match if none of its children matches. The format of the <compiler> is the following: <compiler name="name" version="..." runtime="..." language="..." /> The language attribute, when specified, matches the corresponding attribute used in the <compiler_description> children. All other attributes are regular expressions, which are matched against the corresponding selected compilers. Runtime attribute is matched against the base name of corresponding compiler runtime if it is given as a full path. When an attribute is not specified, it will always match. Matching is done in a case-insensitive manner. For instance, to check a GNAT compiler in the 5.x family, use: <compiler name="GNAT" version="5.\d+" />
<hosts>
<targets> Configuration File ReferenceA text file using the project file syntax. It defines languages and their characteristics as well as toolchains for those languages and their characteristics. GPRbuild needs to have a configuration file to know the different characteristics of the toolchains that can be used to compile sources and build libraries and executables. A configuration file is a special kind of project file: it uses the same syntax as a standard project file. Attributes in the configuration file define the configuration. Some of these attributes have a special meaning in the configuration. The default name of the configuration file, when not specified to GPRbuild by switches --config= or --autoconf= is default.cgpr. Although the name of the configuration file can be any valid file name, it is recommended that its suffix be .cgpr (for Configuration GNAT Project), so that it cannot be confused with a standard project file which has the suffix .gpr. When default.cgpr cannot be found in the configuration project path, GPRbuild invokes GPRconfig to create a configuration file. In the following description of the attributes, when an attribute is an indexed attribute and its index is a language name, for example Spec_Suffix (<language>), then the name of the language is case insensitive. For example, both C and c are allowed. Any attribute may appear in a configuration project file. All attributes in a configuration project file are inherited by each user project file in the project tree. However, usually only the attributes listed below make sense in the configuration project file. General Attributes
for Default_Language use "ada";
for Run_Path_Option use ("-Wl,-rpath,");
for Run_Path_Origin use "$ORIGIN";
for Toolchain_Version ("Ada") use "GNAT 6.1";
This attribute is used by GPRbind to decide on the names of the shared GNAT runtime libraries.
for Toolchain_Description ("C") use "gcc version 4.1.3 20070425";
General Library Related Attributes
for Library_Support use "full";
for Library_Builder use "/.../gprlib"; Archive Related Attributes
for Archive_Builder use ("ar", "cr");
for Archive_Indexer use ("ranlib");
for Archive_Suffix use ".olb"; -- for VMS
for Library_Partial_Linker use ("gcc", "-nostdlib", "-Wl,-r", "-o");
Shared Library Related Attributes
for Shared_Library_Prefix use ""; -- for Windows, if needed
for Shared_Library_Suffix use ".dll"; -- for Windows
for Symbolic_Link_Supported use "true";
for Library_Major_Minor_ID_Supported use "True";
for Library_Auto_Init_Supported use "true";
for Shared_Library_Minimum_Switches use ("-shared");
for Library_Version_Switches use ("-Wl,-soname,");
for Runtime_Library_Dir ("Ada") use "/path/to/adalib";
This attribute is used by GPRlib to link shared libraries with Ada code.
for Object_Lister use ("nm", "-g", "--demangle");
for Object_Lister_Matcher use " T (.*)";
for Export_File_Format use "GNU";
for Export_File_Switch use "-Wl,--version-script="; Package NamingAttributes in package Naming of a configuration file specify defaults. These attributes may be used in user project files to replace these defaults. The following attributes usually appear in package Naming of a configuration file:
for Spec_Suffix ("Ada") use ".ads";
for Spec_Suffix ("C") use ".h";
for Spec_Suffix ("C++") use ".hh";
for Body_Suffix ("Ada") use ".adb";
for Body_Suffix ("C") use ".c";
for Body_Suffix ("C++") use ".cpp";
for Separate_Suffix use ".sep";
for Dot_Replacement use "-"; Package Builder
for Executable_Suffix use ".exe"; General Compilation Attributes
for Driver ("C++") use "g++";
for Driver ("Ada") use "/.../bin/gcc";
for Driver ("Project file") use "";
for Required_Switches ("C") use ("-c", "-x", "c");
for Required_Switches ("Ada") use ("-c", "-x", "ada", "-gnatA");
for PIC_Option ("C") use ("-fPIC");
Mapping File Related Attributes
for Mapping_File_Switches ("Ada") use ("-gnatem=");
for Mapping_Spec_Suffix ("Ada") use "%s";
for Mapping_Spec_Suffix ("Ada") use "%b";
Config File Related AttributesIn the value of config file attributes defined below, there are some placeholders that GPRbuild will replace. These placeholders are:
Attributes:
for Config_File_Switches ("Ada") use ("-gnatec=");
for Config_Body_File_Name ("Ada") use
for Config_Spec_File_Name ("Ada") use
for Config_Body_File_Name_Pattern ("Ada") use
for Config_Spec_File_Name_Pattern ("Ada") use
for Config_File_Unique ("Ada") use "True";
Dependency Related AttributesThere are two dependency-related attributes: Dependency_Switches and Dependency_Driver. If neither of these two attributes are specified for a language other than Ada, then the source needs to be (re)compiled if the object file does not exist or the source file is more recent than the object file or the switch file.
for Dependency_Switches ("C") use ("-Wp,-MD,");
With these Dependency_Switches, when compiling file.c the compiler will be invoked with the option -Wp,-MD,file.d.
for Dependency_Driver ("C") use ("gcc", "-E", "-Wp,-M", "");
Usually, attributes Dependency_Switches and Dependency_Driver are not both specified. Search Path Related Attributes
for Include_Switches ("C") use ("-I");
Attribute Include_Switches is ignored if either one of the attributes Include_Path or Include_Path_File are specified.
for Include_Path ("C") use "CPATH";
for Include_Path ("Ada") use "ADA_INCLUDE_PATH";
Attribute Include_Path is ignored if attribute Include_Path_File is declared for the language.
for Include_Path_File ("Ada") use "ADA_PRJ_INCLUDE_FILE";
Package Binder
for Driver ("Ada") use "/.../gprbind";
for Required_Switches ("Ada") use ("--prefix=<prefix>");
for Prefix ("C++") use ("c__");
for Objects_Path ("Ada") use "ADA_OBJECTS_PATH";
for Objects_Path_File ("Ada") use "ADA_PRJ_OBJECTS_FILE";
Package Linker
for Driver use "g++";
for Map_File_Option use "-Wl,-Map,";
for Max_Command_Line_Length use "8000";
for Response_File_Format use "GCC_GNU";
for Response_File_Switches use ("-Wl,-f,");
Cleaning up with GPRcleanThe GPRclean tool removes the files created by GPRbuild. At a minimum, to invoke GPRclean you must specify a main project file in a command such as gprclean proj.gpr or gprclean -P proj.gpr. Examples of invocation of GPRclean: gprclean -r prj1.gpr gprclean -c -P prj2.gpr Switches for GPRcleanThe switches for GPRclean are:
Installing with GPRinstallThe GPRinstall tool installs projects. With GPRinstall it is not needed to create complex makefiles to install the components. This also removes the need for OS specific commands (like cp, mkdir on UNIXs) and so makes the installation process easier on all supported platforms. After building a project it is often necessary to install the project to make it accessible to other projects. GPRinstall installs only what is necessary and nothing more. That is, for a library project the library itself is installed with the corresponding ALI files for Ada sources, but the object code is not installed as it not needed. Also if the Ada specs are installed the bodies are not, because they are not needed in most cases. The cases where the bodies are required (if the spec has inline routines or is a generic) are properly detected by GPRinstall. Furthermore, we can note that GPRinstall handles the preprocessed sources. So it installs the correct variant of the source after resolving the preprocessing directives. The parts of a project that can be installed are:
Moreover, GPRinstall will create, when needed, a project to use the installed sources, objects or library. By default, this project file is installed in the GPRbuild's default path location so that it can be "with"ed easily without further configuration. The installation process keeps record of every file installed for easy and safe removal. GPRinstall supports all kinds of project:
Projects that won't be installed are:
At a minimum, to invoke GPRinstall you must specify a main project file in a command such as gprinstall proj.gpr or gprinstall -P proj.gpr (in installing mode) or the install name (in uninstalling mode) gprinstall --uninstall proj. Examples of invocation of GPRinstall: gprinstall prj1.gpr gprinstall -r --prefix=/my/root/install -P prj2.gpr GPRinstall will record the installation under the install name which is by default the name of the project without the extension. That is above the project install names are prj1 and prj2. The installation name can be specified with the option --install-name. This makes it possible to record the installation of multiple projects under the same name. This is handy if an application comes with a library and a set of tools built with multiple projects. In this case we may want to record the installation under the same name. The install name is also used as a suffix to group include and library directories. Examples of installation under the same name: gprinstall --install-name=myapp lib.gpr gprinstall --install-name=myapp --mode=usage tools/tools.gpr Note the --mode=usage option above. This tells GPRinstall to only install the executable built as part of the project. It is possible to uninstall a project by using the --uninstall option. In this case we just pass the install name to GPRinstall: gprinstall --uninstall prj1 gprinstall --uninstall prj2 And both lib.gpr and tools.gpr above will be uninstalled with: gprinstall --uninstall myapp Note that GPRinstall does not deal with dependencies between projects. Also GPRinstall in uninstall mode does not need nor use information in the installed project. This is because the project may not be present anymore and many different project scenario may have been installed. So when uninstalling GPRinstall just use the manifest file (whose name is the install name) information. Switches for GPRinstallThe switches for GPRinstall are:
$ gprinstall -Pproject1 \
Specifying a Naming Scheme with GPRnameWhen the Ada source file names do not follow a regular naming scheme, the mapping of Ada units to source file names must be indicated in package Naming with attributes Spec and Body. To help maintain the correspondence between compilation unit names and source file names within the compiler, the tool gprname may be used to generate automatically these attributes. Running gprnameThe usual form of the gprname command is: $ gprname [`switches`] `naming_pattern` [`naming_patterns`] Most of the arguments are optional: switch -P must be specified to indicate the project file and at least one Naming Pattern. gprname will attempt to find all the compilation units in files that follow at least one of the naming patterns. To find Ada compilation units, gprname will use the GNAT compiler in syntax-check-only mode on all regular files. One or several Naming Patterns may be given as arguments to gprname. Each Naming Pattern is enclosed between double quotes (or single quotes on Windows). A Naming Pattern is a regular expression similar to the wildcard patterns used in file names by the Unix shells or the DOS prompt. gprname may be called with several sections of directories/patterns. Sections are separated by switch --and. In each section, there must be at least one pattern. If no directory is specified in a section, the project directory is implied. The options other that the directory switches and the patterns apply globally even if they are in different sections. Examples of Naming Patterns are: "*.[12].ada" "*.ad[sb]*" "body_*" "spec_*" For a more complete description of the syntax of Naming Patterns, see the second kind of regular expressions described in g-regexp.ads (the 'Glob' regular expressions). Switches for GPRnameSwitches for gprname must precede any specified Naming Pattern. You may specify any of the following switches to gprname:
gprname -P prj.gpr -f"*.c" "*.ada" -f "*.clang" will look for Ada units in all files with the .ada extension, and will add to the list of file for project prj.gpr the C files with extensions .c and .clang. Attribute Languages will be declared with the list of languages with sources. In the above example, it will be ("Ada", "C") if Ada and C sources have been found.
gprname -P prj.gpr "*.ada" -f:C++ "*.cpp" -f:C++ "*.CPP" Files with extensions .cpp and *.CPP are C++ sources. Attribute Languages will have value ("Ada", "C++") if Ada and C++ sources are found.
gprname -P prj.gpr -x "*_nt.ada" "*.ada" will look for Ada units in all files with the .ada extension, except those whose names end with _nt.ada. Example of gprname Usage$ gprname -P/home/me/proj.gpr -x "*_nt_body.ada" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" Note that several switches -d may be used, even in conjunction with one or several switches -D. Several Naming Patterns and one excluded pattern are used in this example. The Library Browser GPRlsgprls is a tool that outputs information about compiled sources. It gives the relationship between objects, unit names and source files. It can also be used to check source dependencies as well as various characteristics. Running gprlsThe gprls command has the form $ gprls switches `object_or_dependency_files` The main argument is the list of object files or ali files for Ada sources for which information is requested. gprls uses a project file, either specified through a single switch -P, or the default project file. If no object_or_dependency_files is specified then all the object files corresponding to the sources of the project are deemed to be specified. If object_or_dependency_files is specified for an aggregate project and there is more than one such file in different aggregated projects then the file found first is used to show the information. In normal mode, without option other that -P <project file>, gprls produces information for each object/dependency file: the full path of the object, the name of the principal unit in this object if the source is in Ada, the status of the source and the full path of the source. Here is a simple example of use: $ gprls -P prj.gpr /my_path/obj/pkg.o The first three lines can be interpreted as follows: the main unit which is contained in object file pkg.o is pkg, whose main source is in pkg.adb. Furthermore, the version of the source used for the compilation of pkg has been modified (DIF). Each source file has a status qualifier which can be:
Switches for GPRlsgprls recognizes the following switches:
Examples of gprls Usage$ gprls -v -P prj.gpr GNU FREE DOCUMENTATION LICENSEVersion 1.3, 3 November 2008 Copyright 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others. This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. 1. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The Document, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law. A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none. The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words. A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called Opaque. Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only. The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. The "publisher" means any person or entity that distributes copies of the Document to the public. A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License. 2. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties---for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. 5. COMBINING DOCUMENTS You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements". 6. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate. 8. TRANSLATION Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail. If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title. 9. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License. However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it. 10. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See <http://www.gnu.org/copyleft/>. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Document. 11. RELICENSING "Massive Multiauthor Collaboration Site" (or "MMC Site") means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A "Massive Multiauthor Collaboration" (or "MMC") contained in the site means any set of copyrightable works thus published on the MMC site. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization. "Incorporate" means to publish or republish a Document, in whole or in part, as part of another Document. An MMC is "eligible for relicensing" if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008. The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing. ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright © YEAR YOUR NAME. Permission is granted
to copy, distribute and/or modify this document under the terms of the GNU
Free Documentation License, Version 1.3 or any later version published by the
Free Software Foundation; with no Invariant Sections, no Front-Cover Texts,
and no Back-Cover Texts. A copy of the license is included in the section
entitled "GNU Free Documentation License".
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the "with ... Texts." line with this: with the Invariant Sections being LIST THEIR TITLES, with
the Front-Cover Texts being LIST, and with the Back-Cover Texts being
LIST.
If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software. AuthorAuthor name not set Copyright2008-2026, Free Software Foundation
|