4343bindir = fullfile(plan .RootFolder , pkg_name );
4444[compiler_opt , linker_opt ] = get_compiler_options();
4545
46- if isMATLABReleaseOlderThan(" R2024b" )
46+ use_legacy_mex = isMATLABReleaseOlderThan(" R2024b" );
47+
48+ if use_legacy_mex
4749 % dummy task to allow "buildtool mex" to build all MEX targets
4850 plan(" mex" ) = matlab .buildtool .Task();
4951 mex_deps = string .empty ;
5052end
5153
5254for s = get_mex_sources()
5355 src = s{1 };
54- [ ~ , name ] = fileparts (src(1 ));
56+ name = stdlib .stem (src(1 ));
5557
5658 % name of MEX target function is name of first source file
57- if isMATLABReleaseOlderThan( " R2024b " )
59+ if use_legacy_mex
5860 mex_name = " mex_" + name ;
59- plan(mex_name ) = matlab .buildtool .Task(Inputs = src , Outputs= fullfile(bindir , name + " ." + mexext()), ...
60- Actions= @(context ) legacy_mex(context , compiler_opt , linker_opt ));
61+ plan(mex_name ) = matlab .buildtool .Task(Inputs = src , ...
62+ Outputs= fullfile(bindir , name + " ." + mexext()), ...
63+ Actions= @(context ) legacy_mex(context , compiler_opt , linker_opt ), ...
64+ Description= " Legacy MEX" );
6165 mex_deps(end + 1 ) = mex_name ; % #ok<AGROW>
6266 else
6367 plan(" mex:" + name ) = matlab .buildtool .tasks .MexTask(src , bindir , ...
6468 Options= [compiler_opt , linker_opt ]);
6569 end
6670end
6771
68- if isMATLABReleaseOlderThan( " R2024b " )
72+ if use_legacy_mex
6973 plan(" mex" ).Dependencies = mex_deps ;
7074end
7175
@@ -105,7 +109,7 @@ function build_exe(context)
105109 exe = context .Task .Outputs(i ).paths;
106110 exe = exe(1 );
107111
108- [ ~ , ~ , ext ] = fileparts (src .paths );
112+ ext = stdlib .suffix (src .paths );
109113 switch ext
110114 case " .c" , lang = " c" ;
111115 case " .cpp" , lang = " c++" ;
@@ -145,7 +149,7 @@ function build_exe(context)
145149 for fc = [" flang" , " gfortran" ]
146150 comp = stdlib .which(fc , p );
147151 if ~isempty(comp )
148- disp(" found " + fc + " compiler: " + comp )
152+ % disp(lang + " compiler: " + comp)
149153 setenv(" FC" , comp );
150154 return
151155 end
@@ -167,7 +171,7 @@ function build_exe(context)
167171 end
168172else
169173 comp = co .Details .CompilerExecutable ;
170- disp(lang + " compiler: " + co .ShortName + " " + co .Name + " " + co .Version + " " + comp )
174+ % disp(lang + " compiler: " + co.ShortName + " " + co.Name + " " + co.Version + " " + comp)
171175end
172176
173177
@@ -186,11 +190,11 @@ function build_exe(context)
186190
187191function [comp , shell , outFlag ] = get_build_cmd(lang )
188192
189- outFlag = " -o" ;
190-
191193[comp , shell ] = get_compiler(lang );
192194
193- if ~isempty(shell )
195+ if isempty(shell )
196+ outFlag = " -o" ;
197+ else
194198 outFlag = " /Fo" + tempdir + " /link /out:" ;
195199end
196200
0 commit comments