@@ -99,16 +99,23 @@ function publishTask(context)
9999function subprocess_build_c(context )
100100
101101td = context .Plan .RootFolder + " /test" ;
102- src = td + " /main.c" ;
103- exe = td + " /printer_c.exe" ;
102+ src = td + " /stdout_stderr_c.c" ;
104103
105- cmd = get_build_cmd(" c" , src );
106- if isempty(cmd ), return , end
107- cmd = join([cmd , exe ]);
104+ for s = src
105+ [~ , n ] = fileparts(s );
106+ exe = fullfile(td , n + " .exe" );
107+ if stdlib .get_modtime(s ) < stdlib .get_modtime(exe )
108+ continue
109+ end
108110
109- [r , m ] = system(cmd );
110- if r ~= 0
111- warning(" failed to build TestSubprocess printer_c.exe " + m )
111+ cmd = get_build_cmd(" c++" , s );
112+ if isempty(cmd ), return , end
113+ cmd = cmd + exe ;
114+ disp(cmd )
115+ [r , m ] = system(cmd );
116+ if r ~= 0
117+ disp(" failed to build TestSubprocess " + exe + " " + m )
118+ end
112119end
113120
114121end
@@ -117,16 +124,23 @@ function subprocess_build_c(context)
117124function subprocess_build_cpp(context )
118125
119126td = context .Plan .RootFolder + " /test" ;
120- src = td + " /sleep.cpp" ;
121- exe = td + " /sleep.exe" ;
127+ src = [td + " /sleep.cpp" , td + " /stdin_cpp.cpp" ];
122128
123- cmd = get_build_cmd(" c++" , src );
124- if isempty(cmd ), return , end
125- cmd = join([cmd , exe ]);
129+ for s = src
130+ [~ , n ] = fileparts(s );
131+ exe = fullfile(td , n + " .exe" );
132+ if stdlib .get_modtime(s ) < stdlib .get_modtime(exe )
133+ continue
134+ end
126135
127- [r , m ] = system(cmd );
128- if r ~= 0
129- warning(" failed to build TestSubprocess " + exe + " " + m )
136+ cmd = get_build_cmd(" c++" , s );
137+ if isempty(cmd ), return , end
138+ cmd = cmd + exe ;
139+ disp(cmd )
140+ [r , m ] = system(cmd );
141+ if r ~= 0
142+ disp(" failed to build TestSubprocess " + exe + " " + m )
143+ end
130144end
131145
132146end
@@ -135,16 +149,23 @@ function subprocess_build_cpp(context)
135149function subprocess_build_fortran(context )
136150
137151td = context .Plan .RootFolder + " /test" ;
138- src = td + " /main.f90" ;
139- exe = td + " /printer_fortran.exe" ;
152+ src = [td + " /stdout_stderr_fortran.f90" , td + " /stdin_fortran.f90" ];
140153
141- cmd = get_build_cmd(" Fortran" , src );
142- if isempty(cmd ), return , end
143- cmd = join([cmd , exe ]);
154+ for s = src
155+ [~ , n ] = fileparts(s );
156+ exe = fullfile(td , n + " .exe" );
157+ if stdlib .get_modtime(s ) < stdlib .get_modtime(exe )
158+ continue
159+ end
144160
145- [r , m ] = system(cmd );
146- if r ~= 0
147- warning(" failed to build TestSubprocess " + exe + " " + m )
161+ cmd = get_build_cmd(" Fortran" , s );
162+ if isempty(cmd ), return , end
163+ cmd = cmd + exe ;
164+ disp(cmd )
165+ [r , m ] = system(cmd );
166+ if r ~= 0
167+ disp(" failed to build TestSubprocess " + exe + " " + m )
168+ end
148169end
149170
150171end
@@ -159,28 +180,27 @@ function subprocess_build_fortran(context)
159180 if lang == " Fortran"
160181 fc = getenv(" FC" );
161182 if isempty(fc )
162- warning (" set FC environment variable to the Fortran compiler executable, or do 'mex -setup fortran' to configure the Fortran compiler" )
183+ disp (" set FC environment variable to the Fortran compiler executable, or do 'mex -setup fortran' to configure the Fortran compiler" )
163184 end
164185 end
165- warning (lang + " compiler not found" )
186+ disp (lang + " compiler not found" )
166187 return
167188else
168189 comp = co .Details .CompilerExecutable ;
169190end
170191
171192outFlag = " -o" ;
172- shell = " " ;
173- shell_arg = " " ;
174- msvcLike = ispc && endsWith(comp , " cl" );
193+ shell = string .empty ;
194+ msvcLike = ispc && (contains(co .Name , " Visual Studio" ));
175195if msvcLike
176- shell = strtrim( co .Details .CommandLineShell );
177- shell_arg = co .Details .CommandLineShellArg ;
178- outFlag = " /link /out:" ;
196+ shell = join([strcat( ' " ' ,string( co .Details .CommandLineShell ), ' " ' ), ...
197+ co .Details .CommandLineShellArg ], " " ) ;
198+ outFlag = " /Fo " + tempdir + " / link /out:" ;
179199end
180200
181201cmd = join([comp , src , outFlag ]);
182- if shell ~= " "
183- cmd = join([shell , shell_arg , cmd ]);
202+ if ~isempty( shell )
203+ cmd = join([shell , " && " , cmd ]);
184204end
185205
186206end
0 commit comments