1919 plan(" clean" ) = matlab .buildtool .tasks .CleanTask ;
2020end
2121
22+ plan(" build_c" ) = matlab .buildtool .Task(Actions = @subprocess_build_c );
23+ plan(" build_fortran" ) = matlab .buildtool .Task(Actions = @subprocess_build_fortran );
24+ plan(" test" ).Dependencies = [" build_c" , " build_fortran" ];
25+
2226if ~isMATLABReleaseOlderThan(" R2024a" )
2327 plan(" check" ) = matlab .buildtool .tasks .CodeIssuesTask(pkg_name , IncludeSubfolders= true , ...
2428 WarningThreshold= 0 , Results= " CodeIssues.sarif" );
@@ -68,7 +72,7 @@ function legacy_mex(context, compiler_opt, linker_opt)
6872
6973
7074function legacy_test(context )
71- r = runtests(fullfile( context .Plan .RootFolder , " test" ) , Strict= false );
75+ r = runtests(context .Plan .RootFolder + " / test" , Strict= false );
7276% Parallel Computing Toolbox takes more time to startup than is worth it for this task
7377
7478assert(~isempty(r ), " No tests were run" )
@@ -78,7 +82,7 @@ function legacy_test(context)
7882
7983function publishTask(context )
8084% publish HTML inline documentation strings to individual HTML files
81- outdir = fullfile( context .Plan .RootFolder , " docs" ) ;
85+ outdir = context .Plan .RootFolder + " / docs" ;
8286
8387publish_gen_index_html(" stdlib" , ...
8488 " A standard library of functions for Matlab." , ...
@@ -87,6 +91,64 @@ function publishTask(context)
8791end
8892
8993
94+ function subprocess_build_c(context )
95+
96+ td = context .Plan .RootFolder + " /test" ;
97+ src_c = td + " /main.c" ;
98+ exe = td + " /printer_c.exe" ;
99+
100+ ccObj = mex .getCompilerConfigurations(' c' );
101+
102+ cc = ccObj .Details .CompilerExecutable ;
103+
104+ outFlag = " -o" ;
105+ shell = " " ;
106+ shell_arg = " " ;
107+ msvcLike = ispc && endsWith(cc , " cl" );
108+ if msvcLike
109+ shell = strtrim(c .Details .CommandLineShell );
110+ shell_arg = c .Details .CommandLineShellArg ;
111+ outFlag = " /link /out:" ;
112+ end
113+
114+ cmd = join([cc , src_c , outFlag , exe ]);
115+ if shell ~= " "
116+ cmd = join([shell , shell_arg , cmd ]);
117+ end
118+
119+ [r , m ] = system(cmd );
120+ if r ~= 0
121+ warning(" failed to build TestSubprocess printer_c.exe " + m )
122+ end
123+
124+ end
125+
126+
127+ function subprocess_build_fortran(context )
128+
129+ td = context .Plan .RootFolder + " /test" ;
130+ src = td + " /main.f90" ;
131+ exe = td + " /printer_fortran.exe" ;
132+
133+ fcObj = mex .getCompilerConfigurations(' Fortran' );
134+ if isempty(fcObj )
135+ fc = " gfortran" ;
136+ else
137+ fc = fcObj .Details .CompilerExecutable ;
138+ end
139+
140+ outFlag = " -o" ;
141+
142+ cmd = join([fc , src , outFlag , exe ]);
143+
144+ [r , m ] = system(cmd );
145+ if r ~= 0
146+ warning(" failed to build TestSubprocess printer_fortran.exe " + m )
147+ end
148+
149+ end
150+
151+
90152function srcs = get_mex_sources(build_all )
91153arguments
92154 build_all (1 ,1 ) logical = false
0 commit comments