Main Content

getSourceFiles

Get source files from build information

Description

srcfiles = getSourceFiles(buildinfo,concatenatePaths,replaceMatlabroot,includeGroups,excludeGroups) returns the names of source files from the build information.

The function requires the buildinfo, concatenatePaths, and replaceMatlabroot arguments. You can use optional includeGroups and excludeGroups arguments. These optional arguments let you include or exclude groups selectively from the source files returned by the function.

If you choose to specify excludeGroups and omit includeGroups, specify a null character vector ('') for includeGroups.

The makefile for the build resolves file locations based on source paths and rules. The build process does not require you to resolve the path of every file in the build information. If you specify true for the concatenatePaths argument, the getSourceFiles function returns the path for each file:

  • If a path was explicitly associated with the file when it was added.

  • If you called updateFilePathsAndExtensions (Simulink Coder) to resolve file paths and extensions before calling getSourceFiles.

example

Examples

collapse all

Get the source paths and file names from the build information, myBuildInfo.

myBuildInfo = RTW.BuildInfo;
addSourceFiles(myBuildInfo, ...
   {'test1.c' 'test2.c' 'driver.c'},'', ...
   {'Tests' 'Tests' 'Drivers'});
srcfiles = getSourceFiles(myBuildInfo,false,false);
>> srcfiles

srcfiles = 

    'test1.c'   'test2.c'   'driver.c'

Get the names of source files in group tests from the build information, myBuildInfo.

myBuildInfo = RTW.BuildInfo;
addSourceFiles(myBuildInfo,{'test1.c' 'test2.c'...
   'driver.c'}, {'/proj/test1' '/proj/test2'...
   '/drivers/src'}, {'tests', 'tests', 'drivers'});
incfiles = getSourceFiles(myBuildInfo,false,false,... 
   'tests');
>> incfiles

incfiles = 

    'test1.c'   'test2.c'

Input Arguments

collapse all

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

SpecifyFunction Action
trueConcatenates and returns each file name with its corresponding path.
falseReturns only file names.

Example: true

Use the replaceMatlabroot argument to control whether the function includes the MATLAB® root definition in the output it returns.

SpecifyFunction Action
true

Replaces the token $(MATLAB_ROOT) with the absolute path for your MATLAB installation folder.

falseDoes not replace the token $(MATLAB_ROOT).

Example: true

Group names of source files to include in the return from the function, specified as a string or a cell array of character vectors. To view the group name of a source file, access the Group property of the corresponding object.

Example: ''

Group names of source files to exclude from the return from the function, specified as a string or a cell array of character vectors. To view the group name of a source file, access the Group property of the corresponding object.

Example: ''

Output Arguments

collapse all

The names of source files that you add with the addIncludeFiles function. If you call the packNGo (Simulink Coder) function, the names include files that packNGo (Simulink Coder) found and added while packaging code.

Version History

Introduced in R2006a