Skip to content

Commit bcaa0f0

Browse files
committed
buildtool works with Matlab >= R2022b
1 parent 8395dff commit bcaa0f0

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

.github/workflows/composite-nomex/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ runs:
1515

1616

1717
- name: Non-Mex Test (< R2024b)
18-
if: ${{ matrix.release >= 'R2023b' && matrix.release < 'R2024b' }}
18+
if: ${{ matrix.release >= 'R2022b' && matrix.release < 'R2024b' }}
1919
uses: matlab-actions/run-build@v2
2020
with:
2121
startup-options: ${{ matrix.startup-options }}
@@ -31,7 +31,7 @@ runs:
3131

3232

3333
- name: Java Test (< R2024b)
34-
if: ${{ !contains(matrix.startup-options, '-nojvm') && matrix.release >= 'R2023b' && matrix.release < 'R2024b' }}
34+
if: ${{ !contains(matrix.startup-options, '-nojvm') && matrix.release >= 'R2022b' && matrix.release < 'R2024b' }}
3535
uses: matlab-actions/run-build@v2
3636
with:
3737
startup-options: ${{ matrix.startup-options }}
@@ -40,8 +40,8 @@ runs:
4040

4141
# note: "source-folder" adds all subfolders to Matlab path
4242
# https://github.com/matlab-actions/run-tests?tab=readme-ov-file#run-matlab-tests
43-
- name: Non-mex tests (< R2023b)
44-
if: ${{ matrix.release < 'R2023b' }}
43+
- name: Non-buildtool tests (< R2022b)
44+
if: ${{ matrix.release < 'R2022b' }}
4545
uses: matlab-actions/run-command@v2
4646
with:
4747
command: run('test/test_nomex.m')

Readme.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,44 @@ and
1616
[mustBeTextScalar](https://www.mathworks.com/help/matlab/ref/mustbetextscalar.html)
1717
syntax.
1818
URLs (e.g. https://, s3:// and similar) are treated as not existing.
19+
20+
## Self-tests
21+
1922
The self-tests require at least Matlab R2020b and can be run from the matlab-stdlib/ directory.
2023

24+
Matlab R2024b and newer:
25+
2126
```matlab
22-
%% Matlab >= R2023a
2327
buildtool test
2428
```
2529

26-
or for older Matlab:
30+
Matlab R2023a..R2024a, inclusive:
31+
32+
```matlab
33+
buildtool test_nomex
34+
buildtool test_java
35+
buildtool test_exe
36+
buildtool test_mex
37+
```
38+
39+
Matlab R2022b:
40+
41+
```matlab
42+
buildtool test_nomex
43+
buildtool test_java
44+
```
45+
46+
Matlab older than R2022b:
2747

2848
```matlab
2949
run('test/test_nomex.m')
3050
```
3151

32-
Build the optional high-performance
52+
## MEX functions
53+
54+
With Matlab R2023a and newer, optionally build high-performance
3355
[MEX](https://www.mathworks.com/help/matlab/cpp-mex-file-applications.html)
34-
functions from the Matlab prompt in Matlab R2023a or newer:
56+
functions (the same functions are provided by default without MEX) from the Matlab prompt in Matlab R2023a or newer:
3557

3658
```matlab
3759
buildtool mex

buildfile.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
function plan = buildfile
22
import matlab.unittest.selectors.HasTag
3-
assert(~isMATLABReleaseOlderThan("R2023b"), "MATLAB R2023b or newer is required for this buildfile")
3+
assert(~isMATLABReleaseOlderThan("R2022b"), "MATLAB R2022b or newer is required for this buildfile")
44

55
plan = buildplan(localfunctions);
66

77
pkg_name = "+stdlib";
88

99
addpath(plan.RootFolder)
1010

11-
%% Self-test setup
12-
plan("clean") = matlab.buildtool.tasks.CleanTask;
13-
11+
if isMATLABReleaseOlderThan("R2023b")
12+
plan("clean") =matlab.buildtool.Task();
13+
else
14+
plan("clean") = matlab.buildtool.tasks.CleanTask;
15+
end
1416

1517
cnomex = ~HasTag("exe") & ~HasTag("mex") & ~HasTag("java");
1618
if ispc()
@@ -24,11 +26,15 @@
2426
cjava = cjava & ~HasTag("unix");
2527
end
2628

29+
if isMATLABReleaseOlderThan("R2023b")
30+
plan("test_exe") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, HasTag("exe")), Dependencies="exe");
31+
elseif isMATLABReleaseOlderThan("R2024b")
32+
plan("test_exe") = matlab.buildtool.tasks.TestTask("test", Tag="exe", Dependencies="exe");
33+
end
2734

2835
if isMATLABReleaseOlderThan("R2024b")
2936

3037
plan("test_java") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cjava));
31-
plan("test_exe") = matlab.buildtool.tasks.TestTask("test", Tag="exe", Dependencies="exe");
3238
plan("test_nomex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cnomex), Dependencies="clean");
3339
plan("test_mex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cmex), Dependencies="mex");
3440

@@ -60,6 +66,8 @@
6066
plan("clean_mex") = matlab.buildtool.Task(Actions=@clean_mex, Description="Clean only MEX files to enable incremental tests");
6167
end
6268

69+
if isMATLABReleaseOlderThan("R2023a"), return, end
70+
6371
td = fullfile(plan.RootFolder, 'test');
6472

6573
srcs = ["stdout_stderr_c.c", "stdin_cpp.cpp", "printenv.cpp", "sleep.cpp"];

0 commit comments

Comments
 (0)