Next: Main Subprograms, Previous: Project File Packages, Up: Common Sources with Different Switches and Different Output Directories
Switch settings for a project-aware tool can be specified through attributes
in the package corresponding to the tool.
The example above illustrates one of the relevant attributes,
Default_Switches
, defined in the packages in both project files.
Unlike simple attributes like Source_Dirs
, Default_Switches
is
known as an associative array. When you define this attribute, you must
supply an "index" (a literal string), and the effect of the attribute
definition is to set the value of the "array" at the specified "index".
For the Default_Switches
attribute, the index is a programming
language (in our case, Ada) , and the value specified (after use
)
must be a list of string expressions.
The attributes permitted in project files are restricted to a predefined set. Some may appear at project level, others in packages. For any attribute that is an associate array, the index must always be a literal string, but the restrictions on this string (e.g., a file name or a language name) depend on the individual attribute. Also depending on the attribute, its specified value will need to be either a string or a string list.
In the Debug
project, we set the switches for two tools,
gnatmake and the compiler, and thus we include corresponding
packages, with each package defining the Default_Switches
attribute
with index "Ada"
.
Note that the package corresponding to
gnatmake is named Builder
. The Release
project is
similar, but with just the Compiler
package.
In project Debug
above the switches starting with -gnat that
are specified in package Compiler
could have been placed in package
Builder
, since gnatmake transmits all such switches to the
compiler.