Main Content

getSourcePaths

Get source paths from model build information

Description

example

srcpaths = getSourcePaths(buildinfo,replaceMatlabroot,includeGroups,excludeGroups) returns the names of source file paths from the build information. The function returns only the file paths that were added to the build information by using addSourcePaths. The build process uses build information source paths to locate source files that were specified without an explicit path.

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

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

Examples

collapse all

Get the source paths from the build information, myModelBuildInfo.

myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo,{'/proj/test1' ...
   '/proj/test2' '/drivers/src'}, {'tests' 'tests' ...
   'drivers'});
srcpaths = getSourcePaths(myModelBuildInfo,false);
>> srcpaths

srcpaths = 

   '\proj\test1'    '\proj\test2'      '\drivers\src'

Get the paths in group tests from the build information, myModelBuildInfo.

myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo,{'/proj/test1' ... 
   '/proj/test2' '/drivers/src'}, {'tests' 'tests' ... 
   'drivers'});
srcpaths = getSourcePaths(myModelBuildInfo,true,'tests');
>> srcpaths

srcpaths = 

     '\proj\test1'    '\proj\test2'

Get a source path from the build information, myModelBuildInfo. First, get the path without replacing $(MATLAB_ROOT) with an absolute path. Then, get it with replacement. Here, the MATLAB® root folder is \\myserver\myworkspace\matlab.

myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo, fullfile(matlabroot, ...
   'rtw', 'c', 'src'));
srcpaths = getSourcePaths(myModelBuildInfo,false);
>> srcpaths{:}

ans =

$(MATLAB_ROOT)\rtw\c\src

>> srcpaths = getSourcePaths(myModelBuildInfo,true);
>> srcpaths{:}

ans = 

\\myserver\myworkspace\matlab\rtw\c\src

Input Arguments

collapse all

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

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

SpecifyFunction Action
trueReplaces 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 with myGroups = getGroups(buildInfo).

Example: ''

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

Example: ''

Output Arguments

collapse all

Paths of source files from the build information.

Introduced in R2006a