Previous: Source Directories, Up: Objects and Sources in Project Files


11.4.4 Source File Names

In a project that contains source files, their names may be specified by the attributes Source_Files (a string list) or Source_List_File (a string). Source file names never include any directory information.

If the attribute Source_Files is given an explicit value, then each element of the list is a source file name.

        for Source_Files use ("main.adb");
        for Source_Files use ("main.adb", "pack1.ads", "pack2.adb");

If the attribute Source_Files is not given an explicit value, but the attribute Source_List_File is given a string value, then the source file names are contained in the text file whose path name (absolute or relative to the directory of the project file) is the value of the attribute Source_List_File.

Each line in the file that is not empty or is not a comment contains a source file name.

        for Source_List_File use "source_list.txt";

By default, if neither the attribute Source_Files nor the attribute Source_List_File is given an explicit value, then each file in the source directories that conforms to the project's naming scheme (see Naming Schemes) is an immediate source of the project.

A warning is issued if both attributes Source_Files and Source_List_File are given explicit values. In this case, the attribute Source_Files prevails.

Each source file name must be the name of one existing source file in one of the source directories.

A Source_Files attribute whose value is an empty list indicates that there are no source files in the project.

If the order of the source directories is known statically, that is if "/**" is not used in the string list Source_Dirs, then there may be several files with the same source file name. In this case, only the file in the first directory is considered as an immediate source of the project file. If the order of the source directories is not known statically, it is an error to have several files with the same source file name.

Projects can be specified to have no Ada source files: the value of (Source_Dirs or Source_Files may be an empty list, or the "Ada" may be absent from Languages:

        for Source_Dirs use ();
        for Source_Files use ();
        for Languages use ("C", "C++");

Otherwise, a project must contain at least one immediate source.

Projects with no source files are useful as template packages (see Packages in Project Files) for other projects; in particular to define a package Naming (see Naming Schemes).