Skip to content

Commit 1c0ae6c

Browse files
committed
buildfile: validate arguments
1 parent 58f584b commit 1c0ae6c

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

buildfile.m

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
Tag="python", ...
6969
SourceFiles=pkg_root, RunOnlyImpactedTests=true,...
7070
TestResults="TestResults_python.xml", Strict=true);
71-
71+
7272
addons = matlab.addons.installedAddons;
7373
if contains(addons.Name, "Matlab Test")
7474
plan("coverage") = matlab.buildtool.tasks.TestTask(test_root, ...
@@ -189,6 +189,13 @@ function build_exe(context)
189189

190190

191191
function [comp, shell] = get_compiler(lang)
192+
arguments (Input)
193+
lang (1,1) string {mustBeMember(lang, ["c", "c++", "fortran"])}
194+
end
195+
arguments (Output)
196+
comp (1,1) string
197+
shell (1,1) string
198+
end
192199

193200
lang = lower(lang);
194201

@@ -211,14 +218,13 @@ function build_exe(context)
211218
if isempty(comp)
212219
disp("set CC environment variable to the C compiler path, or do 'mex -setup c'")
213220
end
214-
otherwise, error("language not known " + lang)
215221
end
216222
else
217223
comp = co.Details.CompilerExecutable;
218224
% disp(lang + " compiler: " + co.ShortName + " " + co.Name + " " + co.Version + " " + comp)
219225
end
220226

221-
shell = string.empty;
227+
shell = "";
222228
if ispc()
223229
if isempty(co)
224230
if any(contains(comp, ["gcc", "g++", "gfortran"]))
@@ -238,6 +244,14 @@ function build_exe(context)
238244

239245

240246
function [comp, shell, outFlag] = get_build_cmd(lang)
247+
arguments (Input)
248+
lang (1,1) string {mustBeMember(lang, ["c", "c++", "fortran"])}
249+
end
250+
arguments (Output)
251+
comp (1,1) string
252+
shell (1,1) string
253+
outFlag (1,1) string
254+
end
241255

242256
[comp, shell] = get_compiler(lang);
243257

@@ -251,9 +265,12 @@ function build_exe(context)
251265

252266

253267
function srcs = get_mex_sources(build_all)
254-
arguments
268+
arguments (Input)
255269
build_all (1,1) logical = false
256270
end
271+
arguments (Output)
272+
srcs cell
273+
end
257274

258275
srcs = {
259276
"src/remove.cpp", ...
@@ -272,6 +289,10 @@ function build_exe(context)
272289

273290

274291
function [compiler_opt, linker_opt] = get_compiler_options()
292+
arguments (Output)
293+
compiler_opt (1,1) string
294+
linker_opt (1,1) string
295+
end
275296

276297
cxx = mex.getCompilerConfigurations('c++');
277298
flags = cxx.Details.CompilerFlags;
@@ -318,6 +339,9 @@ function build_exe(context)
318339

319340

320341
function comp = get_fortran_compiler()
342+
arguments (Output)
343+
comp (1,1) string
344+
end
321345

322346
disp("set FC environment variable to the Fortran compiler path, or do 'mex -setup fortran'")
323347

0 commit comments

Comments
 (0)