The compilerSourceFiles
definition
Work in progress.
Purpose
Specify the source files that should be compiled when this object is active and enabled.
Syntax
{
"cdlOptions": {
"<name>": {
...
"compilerSourceFiles": [ "<relative file path>",... ],
...
}
}
}
The value of the compilerSourceFiles
property is an array of strings containing file paths, relative to the current xCDL file's folder, that include source code to be compiled as part of the build..
Default value
If missing, the current object will not contribute any source files to the build.
Description
The compilerSourceFiles
property allows component developers to specify source files which should be compiled.
Details of the build process, including such issues as compiler flags and the order in which things happen, can be found in The xCDL Build Process.
The compilerSourceFiles
properties can occur in any of cdlOptions
, cdlComponents
, cdlPackage
or cdlInterfaces
objects. A compilerSourceFiles
property has effect if and only if the object that contains it is active and enabled. Typically, the body of a package will define any source files that need to be built irrespective of individual options, and each component, option, and interface will define source files that are more specific. The compilerSourceFiles
property can list any number of source files. It is possible for a given source file to be specified in compilerSourceFiles
properties for several different objects, in which case the source file will get built if any of these objects are active and enabled.
The configuration tools will search for the specified source files in the folder where the current xCDL file is located.
Note: A shortcoming of the current specification of compilerSourceFiles
properties is that there is no easy way to specify source files that should be built unless an option is enabled. It would sometimes be useful to be able to say: "if option A is enabled then compile file x.c, otherwise compile file y.c". There are two simple ways of achieving this:
- Always compile y.c, typically by listing it in the body of the
cdlPackage
, but use#ifndef A
to produce an empty object file if option A is not enabled. This has the disadvantage that the file always gets compiled and hence for some configurations, builds will take longer than necessary. - Use a computed option whose value is !A, and have a
compilerSourceFiles
y.c property in its body. This has the disadvantage of adding another computed option to the configuration.
The order in which files get compiled is undefined. It is not possible to control the priority of a compilerSourceFiles
property.
Example
{
"cdlPackage": {
"name": "infra",
"display": "Infrastructure",
"description": "Common types and useful macros. Tracing and assertion facilities. Package startup options.",
"generatedDefinition": "OS_PACKAGE_INFRA",
"compilerSourceFiles": [
"src/startup.cpp",
"src/prestart.cpp",
"src/pkgstart.cpp"
]
}
}
eCos reference
compile
property