In its simplest form, a unique project is used to build a single executable. This section concentrates on such a simple setup. Later sections will extend this basic model to more complex setups.
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.
Builder
, Compiler
, Binder
,
and Linker
. See Packages.
foo.c
is typically the name of a C source file;
bar.ads
or bar.1.ada
are two common naming conventions for a
file containing an Ada spec. A compilation unit is often composed of a main
source file and potentially several auxiliary ones, such as header files in C.
The naming conventions can be user defined See Naming Schemes, and will
drive the builder to call the appropriate compiler for the given source file.
Source files are searched for in the source directories associated with the
project through the Source_Dirs attribute. By default, all the files (in
these source directories) following the naming conventions associated with the
declared languages are considered to be part of the project. It is also
possible to limit the list of source files using the Source_Files or
Source_List_File attributes. Note that those last two attributes only
accept basenames with no directory information.
The following subsections introduce gradually all the attributes of interest for simple build needs. Here is the simple 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 with
s package Pack
. We want to compile
these source files with the ^switch^switch^
^-O2^-O2^, and put the resulting files in
the directory obj/.
^common/^[COMMON]^ pack.ads pack.adb proc.adb ^common/release/^[COMMON.RELEASE]^ proc.ali, proc.o pack.ali, pack.o
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 enough for it. We will thus create a new file, that for now should contain the following code:
project Build is end Build;