Main Content

addSourceFiles

Add source files to build information

Description

addSourceFiles(buildinfo,filenames,paths,groups) specifies source files and paths to add to the build information.

The function requires the buildinfo and filenames arguments. You can use an optional groups argument to group your options.

The code generator stores the source file and path options in a build information object. The function adds options to the object based on the order in which you specify them.

example

Examples

collapse all

Add the source file driver.c to the build information myBuildInfo and place the file in the group Drivers.

myBuildInfo = RTW.BuildInfo;
addSourceFiles(myBuildInfo,'driver.c', ...
   '/proj/src', 'Drivers');

Add the source files test1.c and test2.c to the build information myBuildInfo and place the files in the group Tests.

myBuildInfo = RTW.BuildInfo;
addSourceFiles(myBuildInfo, ...
   {'test1.c' 'test2.c'}, ...
   '/proj/src','Tests');

Add the source files test1.c, test2.c, and driver.c to the build information myBuildInfo. Group the files test1.c and test2.c with the character vector Tests. Group the file driver.c with the character vector Drivers.

myBuildInfo = RTW.BuildInfo;
addSourceFiles(myBuildInfo, ...
   {'test1.c' 'test2.c' 'driver.c'}, ... 
   '/proj/src', ...
   {'Tests' 'Tests' 'Drivers'});

Add the .c files in a specified folder to the build information myBuildInfo and place the files in the group CFiles.

myBuildInfo = RTW.BuildInfo;
addSourceFiles(myBuildInfo, ... 
   '*.c','/proj/src','CFiles');

Input Arguments

collapse all

RTW.BuildInfo object that holds information for compiling and linking generated code.

Example: myBuildInfo

You can specify the filenames argument as a character vector, as an array of character vectors, or as a string. If you specify the filenames argument as multiple character vectors, for example, 'etc.c' 'etc_private.c', the filenames argument is added to the build information as an array of character vectors.

If the dot delimiter (.) is present, the file name text can include wildcard characters. Examples are '*.*', '*.c', and '*.c*'.

The function removes duplicate included file entries with an exact match of a path and file name to a previously defined entry in the build information object.

Example: '*.c'

You can specify the paths argument as a character vector, as an array of character vectors, or as a string. If you specify a single path as a character vector, the function uses that path for all files. If you specify the paths argument as multiple character vectors, for example, '/proj/src' and '/proj/inc', the paths argument is added to the build information as an array of character vectors.

Example: '/proj/src'

You can specify the groups argument as a character vector, as an array of character vectors, or as a string. If you specify multiple groups, for example, 'Tests' 'Tests' 'Drivers', the function relates the groups to the filenames in order of appearance. For example, the filenames argument 'test1.c' 'test2.c' 'driver.c' is an array of character vectors with three elements. The first element is in the 'Tests' group, and the second element is in the 'Tests' group, and the third element is in the 'Drivers' group.

Example: 'Tests' 'Tests' 'Drivers'

Version History

Introduced in R2006a