Skip to content

Commit c89dc72

Browse files
committed
buildfile: full path for no ambiguity
1 parent 8a7465e commit c89dc72

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

buildfile.m

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
plan = buildplan(localfunctions);
66

7-
pkg_name = "+stdlib";
8-
97
if isMATLABReleaseOlderThan("R2023b")
108
plan("clean") =matlab.buildtool.Task();
119
else
@@ -23,10 +21,13 @@
2321

2422
cjava = HasTag("java") & ~HasTag("exe");
2523

24+
pkg_root = fullfile(plan.RootFolder, "+stdlib");
25+
test_root = fullfile(plan.RootFolder, "test");
26+
2627
if isMATLABReleaseOlderThan("R2023b")
2728
plan("test_exe") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, HasTag("exe")), Dependencies="exe");
2829
elseif 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");
3031
end
3132

3233
if isMATLABReleaseOlderThan("R2024b")
@@ -38,34 +39,40 @@
3839
elseif 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

4546
else
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"]);
@@ -75,28 +82,26 @@
7582

7683
if isMATLABReleaseOlderThan("R2023a"), return, end
7784

78-
td = fullfile(plan.RootFolder, 'test');
79-
8085
srcs = ["stdout_stderr_c.c", "stdin_cpp.cpp", "printenv.cpp", "sleep.cpp"];
8186
exes = ["stdout_stderr_c.exe", "stdin_cpp.exe", "printenv.exe", "sleep.exe"];
8287
if ~isempty(get_compiler("fortran"))
8388
srcs = [srcs, "stdout_stderr_fortran.f90", "stdin_fortran.f90"];
8489
exes = [exes, "stdout_stderr_fortran.exe", "stdin_fortran.exe"];
8590
end
8691

87-
srcs = fullfile(td, srcs);
88-
exes = fullfile(td, exes);
92+
srcs = fullfile(test_root, srcs);
93+
exes = fullfile(test_root, exes);
8994

9095
plan("exe") = matlab.buildtool.Task(Inputs=srcs, Outputs=exes, Actions=@build_exe, ...
9196
Description="build test exe's for test subprocess");
9297

9398
if ~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");
96102
end
97103

98104
%% MexTask
99-
bindir = fullfile(plan.RootFolder, pkg_name);
100105
[compiler_opt, linker_opt] = get_compiler_options();
101106

102107
use_legacy_mex = isMATLABReleaseOlderThan("R2024b");
@@ -115,12 +120,12 @@
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

0 commit comments

Comments
 (0)