function addExternalModeInfo(buildInfo, extModeTransport, rtiostreamSrcFileFullPath)
% ADDEXTERNALMODEINFO method that adds External mode related info BuildInfo
%
% As an example of how to use this, please see call sites in
% realtime.BuildExtension and tests.

%  Copyright 2013-2019 The MathWorks, Inc.

narginchk(3, 3);

extModeSources = {};
extModePaths = {};
includePaths = {};
switch(extModeTransport)
    case {'tcpip', 'serial_no_acks'}
        % source files and paths
        extModeSources{end+1} = 'rtiostream_interface.c';
        extModePaths{end+1}   = fullfile(matlabroot, 'rtw', 'c', 'src', 'ext_mode', 'common');
        
        % include paths
        includePaths{end+1}   = fullfile(matlabroot, 'rtw', 'c', 'src', 'ext_mode', 'common');
    case 'serial_acks' 
        % source files and paths
        extModeSources{end+1} = 'ext_serial_pkt.c';
        extModeSources{end+1} = 'rtiostream_serial_interface.c';
        extModeSources{end+1} = 'ext_svr_serial_transport.c';
        extModePaths(1:length(extModeSources)) = {fullfile(matlabroot, 'rtw', 'c', 'src', 'ext_mode', 'serial')};
        
        % include paths
        includePaths{end+1} = fullfile(matlabroot, 'rtw', 'c', 'src', 'ext_mode', 'serial');        
    otherwise
        assert(false, 'Unsupported extModeTransport "%s".',extModeTransport);
end

% Add the rtiostream file
assert(~isempty(dir(rtiostreamSrcFileFullPath)) , ...
    'File "%s" does not exist. Make sure you pass the file with full path.',...
    rtiostreamSrcFileFullPath);
[rtiostreamPath, rtiostreamFile, ext] = fileparts(rtiostreamSrcFileFullPath);
assert(~isempty(rtiostreamPath) , ...
    'File "%s" should be passed with full path.', rtiostreamSrcFileFullPath);
extModeSources{end+1} = [rtiostreamFile ext];
extModePaths{end+1}   = rtiostreamPath;
includePaths{end+1}   = rtiostreamPath;

% add the source files to buildInfo
buildInfo.addSourceFiles(extModeSources, extModePaths, 'EXT_MODE');
buildInfo.addSourcePaths(extModePaths, 'EXT_MODE');

% add include path
buildInfo.addIncludePaths(includePaths, 'EXT_MODE');
