Main Content

getSourceFiles

Get source files from model build information

Description

example

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 model 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 to resolve file paths and extensions before calling getSourceFiles.

Examples

collapse all

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

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

srcfiles = 

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

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

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

incfiles = 

    'test1.c'   'test2.c'

Input Arguments

collapse all

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

To use the includeGroups argument, view available groups by using myGroups = getGroups(buildInfo).

Example: ''

To use the excludeGroups argument, view available groups by using myGroups = getGroups(buildInfo).

Example: ''

Output Arguments

collapse all

The names of source files that you add with the addSourceFiles function. If you call the packNGo function, the names include files that packNGo found and added while packaging model code.

Introduced in R2006a