Next: , Previous: Object and Exec Directory, Up: Building With Projects


5.2.4 Main Subprograms

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 the source file of a 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 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 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.

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.