function [srcs, objs] = getMATLABSourcesAndObjects(h)

% Copyright 2015-2019 The MathWorks, Inc.

[srcs, ~] = h.getSourceFilesFromDependencyTree();
srcs_tmp = regexprep( srcs, regexptranslate( 'escape', h.SpecialDirs.toks ), h.SpecialDirs.regexpPats );
containsSpaces = coder.make.MakefileWriter.containsSpaces( srcs_tmp );
idxs = 1:numel(srcs);
idxs = idxs(containsSpaces);
for ii=idxs
if ~h.isAttribute( 'SupportsSpacesInPaths') && ~h.isAttribute( 'TransformPathsWithSpaces')
% If a toolchain does not support paths with spaces, and we cannot
% transform these paths, we have to copy over the required source
% file to the build area
if ~isequal(exist('tmp','dir'),7)
mkdir('./tmp');
end
success = builtin('copyfile', srcs_tmp{ii}, 'tmp');
if success
%if the copy fails the build error should suffice
FILESEP = h.getBuildAppDirective( 'FileSeparator' );
[~, lFile, lExt] = fileparts(srcs_tmp{ii});
srcs{ii} = ['.', FILESEP, 'tmp', FILESEP, lFile, lExt];
end
end
end
objs = h.Components.ObjectFiles.value;
end