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


10.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. A comment line starts with two hyphens.

        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 and only one existing source file in one of the source directories.

A Source_Files attribute defined with an empty list as its value indicates that there are no source files in the project.

Except for projects that are clearly specified as containing no Ada source files (Source_Dirs or Source_Files specified as an empty list, or Languages specified without "Ada" in the list)

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

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).