@@ -199,7 +199,8 @@ function build_exe(context)
199199 end
200200
201201 disp(cmd )
202- system(cmd );
202+ [s , msg ] = system(cmd );
203+ assert(s == 0 , " Error %d: %s" , s , msg )
203204end
204205
205206end
@@ -236,10 +237,18 @@ function build_exe(context)
236237end
237238
238239shell = string .empty ;
239- if ispc() && ~isempty(co )
240- if startsWith(co .ShortName , [" INTEL" , " MSVC" ])
241- shell = join([strcat(' "' ,string(co .Details .CommandLineShell ),' "' ), ...
242- co .Details .CommandLineShellArg ], " " );
240+ if ispc()
241+ if isempty(co )
242+ if lang == " fortran" && ~isempty(comp ) && contains(comp , " gfortran" )
243+ shell = " set PATH=" + fileparts(comp ) + pathsep + " %PATH%" ;
244+ end
245+ else
246+ if startsWith(co .ShortName , [" INTEL" , " MSVC" ])
247+ shell = join([strcat(' "' ,string(co .Details .CommandLineShell ),' "' ), ...
248+ co .Details .CommandLineShellArg ], " " );
249+ elseif co .ShortName == " mingw64-gfortran"
250+ shell = " set PATH=" + fileparts(comp ) + pathsep + " %PATH%" ;
251+ end
243252 end
244253end
245254
@@ -250,10 +259,10 @@ function build_exe(context)
250259
251260[comp , shell ] = get_compiler(lang );
252261
253- if isempty(shell )
254- outFlag = " -o" ;
255- else
262+ if contains(shell , " Visual Studio" )
256263 outFlag = " /Fo" + tempdir + " /link /out:" ;
264+ else
265+ outFlag = " -o" ;
257266end
258267
259268
@@ -357,6 +366,14 @@ function build_exe(context)
357366 disp(" on macOS, environment variables propagate in to GUI programs like Matlab by using 'launchctl setenv FC' and a reboot." )
358367 disp(" if having trouble, try:" )
359368 disp(" FC=gfortran matlab -batch 'buildtool exe'" )
369+ elseif ispc()
370+ p = getenv(' CMPLR_ROOT' );
371+ if isempty(p )
372+ p = getenv(" MW_MINGW64_LOC" );
373+ end
374+ if ~isempty(p ) && ~endsWith(p , [" bin" , " bin/" ])
375+ p = p + " /bin" ;
376+ end
360377else
361378 p = ' ' ;
362379end
0 commit comments