44
55plan = buildplan(localfunctions );
66
7- pkg_name = " +stdlib" ;
8-
97if isMATLABReleaseOlderThan(" R2023b" )
108 plan(" clean" ) = matlab .buildtool .Task();
119else
2321
2422cjava = HasTag(" java" ) & ~HasTag(" exe" );
2523
24+ pkg_root = fullfile(plan .RootFolder , " +stdlib" );
25+ test_root = fullfile(plan .RootFolder , " test" );
26+
2627if isMATLABReleaseOlderThan(" R2023b" )
2728 plan(" test_exe" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , HasTag(" exe" )), Dependencies= " exe" );
2829elseif isMATLABReleaseOlderThan(" R2024b" )
29- plan(" test_exe" ) = matlab .buildtool .tasks .TestTask(" test " , Tag= " exe" , Dependencies= " exe" );
30+ plan(" test_exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Dependencies= " exe" );
3031end
3132
3233if isMATLABReleaseOlderThan(" R2024b" )
3839elseif isMATLABReleaseOlderThan(" R2025a" )
3940
4041 plan(" test:java" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , cjava ));
41- plan(" test:exe" ) = matlab .buildtool .tasks .TestTask(" test " , Tag= " exe" , Dependencies= " exe" );
42+ plan(" test:exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Dependencies= " exe" );
4243 plan(" test:nomex" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , cnomex ), Dependencies= " clean" );
4344 plan(" test:mex" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , cmex ), Dependencies= " mex" );
4445
4546else
46- plan(" test:exe" ) = matlab .buildtool .tasks .TestTask(" test " , Tag= " exe" , Description= " test subprocess" ,...
47- SourceFiles= [" +stdlib/ " , " test /*.cpp" , " test /*.c" , " test /*.f90" ], ...
47+ plan(" test:exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Description= " test subprocess" ,...
48+ SourceFiles= [pkg_root , test_root + [ " /*.cpp" , " /*.c" , " /*.f90" ] ], ...
4849 RunOnlyImpactedTests= true ,...
4950 Dependencies= " exe" , TestResults= " TestResults_exe.xml" , Strict= true );
5051
51- plan(" test:nomex" ) = matlab .buildtool .tasks .TestTask(" test" , Description= " Test non-MEX targets" ,...
52- Selector= cnomex , SourceFiles= " +stdlib/" , RunOnlyImpactedTests= true ,...
52+ plan(" test:nomex" ) = matlab .buildtool .tasks .TestTask(test_root , Description= " Test non-MEX targets" ,...
53+ Selector= cnomex , ...
54+ SourceFiles= pkg_root , RunOnlyImpactedTests= true ,...
5355 dependencies= " clean_mex" , TestResults= " TestResults_nomex.xml" , Strict= true );
5456
55- plan(" test:mex" ) = matlab .buildtool .tasks .TestTask(" test" , Description= " Test mex targts" ,...
56- Selector= cmex , SourceFiles= [" +stdlib/" , " src/" ], RunOnlyImpactedTests= true ,...
57+ plan(" test:mex" ) = matlab .buildtool .tasks .TestTask(test_root , Description= " Test mex targts" ,...
58+ Selector= cmex , ...
59+ SourceFiles= [pkg_root , plan .RootFolder + " /src" ], RunOnlyImpactedTests= true ,...
5760 Dependencies= " mex" , TestResults= " TestResults_mex.xml" , Strict= true );
5861
59- plan(" test:java" ) = matlab .buildtool .tasks .TestTask(" test" , Description= " test Java targets" , ...
60- Selector= cjava , SourceFiles= " +stdlib/" , RunOnlyImpactedTests= true ,...
62+ plan(" test:java" ) = matlab .buildtool .tasks .TestTask(test_root , Description= " test Java targets" , ...
63+ Selector= cjava , ...
64+ SourceFiles= pkg_root , RunOnlyImpactedTests= true ,...
6165 TestResults= " TestResults_java.xml" , Strict= true );
6266
63- plan(" test:python" ) = matlab .buildtool .tasks .TestTask(" test" , Description= " test Python targets" , ...
64- Tag= " python" , SourceFiles= " +stdlib/" , RunOnlyImpactedTests= true ,...
67+ plan(" test:python" ) = matlab .buildtool .tasks .TestTask(test_root , Description= " test Python targets" , ...
68+ Tag= " python" , ...
69+ SourceFiles= pkg_root , RunOnlyImpactedTests= true ,...
6570 TestResults= " TestResults_python.xml" , Strict= true );
6671
67- plan(" coverage" ) = matlab .buildtool .tasks .TestTask(Description = " code coverage" , ...
68- Dependencies= [" clean" , " exe" ], SourceFiles= " +stdlib/" , ...
72+ plan(" coverage" ) = matlab .buildtool .tasks .TestTask(test_root , ...
73+ Description= " code coverage" , ...
74+ Dependencies= [" clean" , " exe" ], ...
75+ SourceFiles= pkg_root , ...
6976 Selector= cnomex | HasTag(" java" ) | HasTag(" exe" ) | HasTag(" python" ), ...
7077 Strict= false , ...
7178 CodeCoverageResults= [" code-coverage.xml" , " code-coverage.html" ]);
7582
7683if isMATLABReleaseOlderThan(" R2023a" ), return , end
7784
78- td = fullfile(plan .RootFolder , ' test' );
79-
8085srcs = [" stdout_stderr_c.c" , " stdin_cpp.cpp" , " printenv.cpp" , " sleep.cpp" ];
8186exes = [" stdout_stderr_c.exe" , " stdin_cpp.exe" , " printenv.exe" , " sleep.exe" ];
8287if ~isempty(get_compiler(" fortran" ))
8388 srcs = [srcs , " stdout_stderr_fortran.f90" , " stdin_fortran.f90" ];
8489 exes = [exes , " stdout_stderr_fortran.exe" , " stdin_fortran.exe" ];
8590end
8691
87- srcs = fullfile(td , srcs );
88- exes = fullfile(td , exes );
92+ srcs = fullfile(test_root , srcs );
93+ exes = fullfile(test_root , exes );
8994
9095plan(" exe" ) = matlab .buildtool .Task(Inputs = srcs , Outputs= exes , Actions= @build_exe , ...
9196 Description= " build test exe's for test subprocess" );
9297
9398if ~isMATLABReleaseOlderThan(" R2024a" )
94- plan(" check" ) = matlab .buildtool .tasks .CodeIssuesTask(pkg_name , IncludeSubfolders= true , ...
99+ plan(" check" ) = matlab .buildtool .tasks .CodeIssuesTask(plan .RootFolder , ...
100+ IncludeSubfolders= true , ...
95101 WarningThreshold= 0 , Results= " CodeIssues.sarif" );
96102end
97103
98104%% MexTask
99- bindir = fullfile(plan .RootFolder , pkg_name );
100105[compiler_opt , linker_opt ] = get_compiler_options();
101106
102107use_legacy_mex = isMATLABReleaseOlderThan(" R2024b" );
115120 if use_legacy_mex
116121 mex_name = " mex_" + name ;
117122 plan(mex_name ) = matlab .buildtool .Task(Inputs = src , ...
118- Outputs= fullfile(bindir , name + " ." + mexext()), ...
123+ Outputs= fullfile(pkg_root , name + " ." + mexext()), ...
119124 Actions= @(context ) legacy_mex(context , compiler_opt , linker_opt ), ...
120125 Description= " Legacy MEX" );
121126 mex_deps(end + 1 ) = mex_name ; % #ok<AGROW>
122127 else
123- plan(" mex:" + name ) = matlab .buildtool .tasks .MexTask(src , bindir , ...
128+ plan(" mex:" + name ) = matlab .buildtool .tasks .MexTask(src , pkg_root , ...
124129 Description= " Build MEX target " + name , ...
125130 Options= [compiler_opt , linker_opt ]);
126131 end
@@ -239,14 +244,14 @@ function build_exe(context)
239244shell = string .empty ;
240245if ispc()
241246 if isempty(co )
242- if lang == " fortran " && ~isempty( comp ) && contains(comp , " gfortran" )
247+ if any( contains(comp , [ " gcc " , " g++ " , " gfortran" ]) )
243248 shell = " set PATH=" + fileparts(comp ) + pathsep + " %PATH%" ;
244249 end
245250 else
246251 if startsWith(co .ShortName , [" INTEL" , " MSVC" ])
247252 shell = join([strcat(' "' ,string(co .Details .CommandLineShell ),' "' ), ...
248253 co .Details .CommandLineShellArg ], " " );
249- elseif co .ShortName == " mingw64-gfortran "
254+ elseif startsWith( co .ShortName , " mingw64" )
250255 shell = " set PATH=" + fileparts(comp ) + pathsep + " %PATH%" ;
251256 end
252257 end
@@ -265,7 +270,6 @@ function build_exe(context)
265270 outFlag = " -o" ;
266271end
267272
268-
269273end
270274
271275
@@ -295,21 +299,25 @@ function build_exe(context)
295299srcs{end + 1 } = " src/disk_capacity.cpp" ;
296300end
297301
298- if (isMATLABReleaseOlderThan(" R2024b" ) && ~stdlib .has_dotnet() && ~stdlib .has_java() && ~stdlib .has_python()) || build_all
302+ if isMATLABReleaseOlderThan(" R2024b" )
303+
304+ if (~stdlib .has_dotnet() && ~stdlib .has_java() && ~stdlib .has_python()) || build_all
299305srcs{end + 1 } = [" src/is_symlink.cpp" , win , sym ];
300306end
301307
302- if (isMATLABReleaseOlderThan( " R2024b " ) && ~stdlib .has_java() && ~stdlib .has_python() && stdlib .dotnet_api() < 6 ) || build_all
308+ if (~stdlib .has_java() && ~stdlib .has_python() && stdlib .dotnet_api() < 6 ) || build_all
303309srcs{end + 1 } = [" src/read_symlink.cpp" , win , sym ];
304310end
305311
306- if (isMATLABReleaseOlderThan( " R2024b " ) && ~stdlib .has_python() && stdlib .dotnet_api() < 6 ) || build_all
312+ if (~stdlib .has_python() && stdlib .dotnet_api() < 6 ) || build_all
307313% so that we don't need to run matlab AsAdmin on Windows
308314srcs{end + 1 } = [" src/create_symlink.cpp" , win , sym ];
309315end
310316
311317end
312318
319+ end
320+
313321
314322function [compiler_opt , linker_opt ] = get_compiler_options()
315323
0 commit comments