Next: Tools Options in Project Files, Previous: Object and Exec Directory, Up: Building With Projects
In the previous section, executables were mentioned. The project manager needs
to be taught what they are. In a project file, an executable is indicated by
pointing to source file of the main subprogram. In C this is the file that
contains the main
function, and in Ada the file that contains the main
unit.
There can be any number of such main files within a given project, and thus several executables can be built in the context of a single project file. Of course, one given executable might not (and in fact will not) need all the source files referenced by the project. As opposed to other build environments such as makefile, one does not need to specify the list of dependencies of each executable, the project-aware builders knows enough of the semantics of the languages to build ands 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 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 for Source_Dirs use ("common"); for Object_Dir use "obj"; for Exec_Dir use "."; for Main use ("proc.adb"); -- <<<< end Build;
If this attribute is defined in the project, then spawning the builder with a command such as
gnatmake ^-Pbuild^/PROJECT_FILE=build^
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.