@@ -127,10 +127,15 @@ function compileAndLinkModel(modelname, modelSourceFolder, coptim, debug, funs,
127127 sources = cellfun(@(x ) [' "' fullfile(modelSourceFolder ,[modelname ' _' x ' .cpp' ]) ' "' ],funsForRecompile ,' UniformOutput' ,false );
128128 sources = strjoin(sources ,' ' );
129129
130- eval( [' mex ' DEBUG COPT ...
130+ cmd = [' mex ' DEBUG COPT ...
131131 ' -c -outdir "' modelObjectFolder ' " ' ...
132- sources ' ' ...
133- includesstr ]);
132+ sources ' ' includesstr ];
133+ try
134+ eval(cmd );
135+ catch ME
136+ disp(cmd );
137+ rethrow(ME );
138+ end
134139 cellfun(@(x ) updateFileHashSource(modelSourceFolder , modelObjectFolder , [modelname ' _' x ]),funsForRecompile ,' UniformOutput' ,false );
135140 end
136141
@@ -156,10 +161,17 @@ function compileAndLinkModel(modelname, modelSourceFolder, coptim, debug, funs,
156161
157162 % compile the wrapfunctions object
158163 fprintf(' wrapfunctions | ' );
159- eval( [' mex ' DEBUG COPT ...
164+ cmd = [' mex ' DEBUG COPT ...
160165 ' -c -outdir "' modelObjectFolder ' " "' ...
161166 fullfile(modelSourceFolder ,' wrapfunctions.cpp' ) ' " ' model_cpp ...
162- includesstr ]);
167+ includesstr ];
168+ try
169+ eval(cmd );
170+ catch ME
171+ disp(cmd );
172+ rethrow(ME );
173+ end
174+
163175 objectsstr = [objectsstr , ' "' fullfile(modelObjectFolder ,[' wrapfunctions' objectFileSuffix ]) ' " ' model_cpp_obj ];
164176
165177 % now we have compiled everything model-specific, so we can replace hashes.mat to prevent recompilation
@@ -186,8 +198,15 @@ function compileAndLinkModel(modelname, modelSourceFolder, coptim, debug, funs,
186198 end
187199
188200 mexFilename = fullfile(modelSourceFolder ,[' ami_' modelname ]);
189- eval([' mex ' DEBUG ' ' COPT ' ' CLIBS ...
190- ' -output "' mexFilename ' " ' objectsstr ])
201+ cmd = [' mex ' DEBUG ' ' COPT ' ' CLIBS ...
202+ ' -output "' mexFilename ' " ' objectsstr ];
203+ try
204+ eval(cmd );
205+ catch ME
206+ disp(cmd );
207+ rethrow(ME );
208+ end
209+
191210end
192211
193212function [objectStrAmici ] = compileAmiciBase(amiciRootPath , objectFolder , objectFileSuffix , includesstr , DEBUG , COPT )
@@ -217,8 +236,15 @@ function compileAndLinkModel(modelname, modelSourceFolder, coptim, debug, funs,
217236 baseFilename = fullfile(amiciSourcePath , sourcesForRecompile{j });
218237 sourceStr = [sourceStr , ' "' , baseFilename , ' .cpp"' ];
219238 end
220- eval([' mex ' DEBUG COPT ' -c -outdir "' objectFolder ' " ' ...
221- includesstr ' ' sourceStr ]);
239+ cmd = [' mex ' DEBUG COPT ' -c -outdir "' objectFolder ' " ' ...
240+ includesstr ' ' sourceStr ];
241+ try
242+ eval(cmd );
243+ catch ME
244+ disp(cmd );
245+ rethrow(ME );
246+ end
247+
222248 cellfun(@(x ) updateFileHashSource(amiciSourcePath , objectFolder , x ), sourcesForRecompile );
223249 updateHeaderFileHashes(amiciIncludePath , objectFolder );
224250 end
0 commit comments