Skip to content

Commit d0bdfdb

Browse files
committed
buildtool mex works for R2022b and later
1 parent f299b47 commit d0bdfdb

File tree

3 files changed

+25
-41
lines changed

3 files changed

+25
-41
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,15 @@ runs:
1313
startup-options: ${{ matrix.startup-options }}
1414
tasks: check
1515

16-
- name: Legacy Mex Test
17-
if: ${{ matrix.release >= 'R2022b' && matrix.release < 'R2024b' }}
18-
uses: matlab-actions/run-build@v2
19-
with:
20-
startup-options: ${{ matrix.startup-options }}
21-
tasks: legacyMex test
22-
2316
- name: Non-Mex Test
2417
if: ${{ matrix.release >= 'R2024b' || startsWith(matrix.release, 'latest') }}
2518
uses: matlab-actions/run-build@v2
2619
with:
2720
startup-options: ${{ matrix.startup-options }}
2821
tasks: test
2922

30-
- name: Mex Group Test
31-
if: ${{ matrix.release >= 'R2024b' || startsWith(matrix.release, 'latest') }}
23+
- name: Mex Test
24+
if: ${{ matrix.release >= 'R2022b' || startsWith(matrix.release, 'latest') }}
3225
uses: matlab-actions/run-build@v2
3326
with:
3427
startup-options: ${{ matrix.startup-options }}

Readme.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ Functions requiring or optionally benefiting from MEX are indicated in the
2727

2828
To build the optional high-performance
2929
[MEX](https://www.mathworks.com/help/matlab/cpp-mex-file-applications.html)
30-
functions:
30+
functions from the Matlab prompt:
3131

3232
```matlab
3333
buildtool mex
3434
```
3535

36-
or for older Matlab:
37-
38-
```matlab
39-
legacy_mex_build()
40-
```
36+
For Matlab R2022a and older, instead do: `legacy_mex_build()`
4137

4238
If just building MEX functions for the first time, to ensure the MEX functions are used instead of the plain Matlab script, one-time do a `clear all` in Matlab.
4339

buildfile.m

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55

66
pkg_name = "+stdlib";
77

8-
if ~isMATLABReleaseOlderThan("R2023b")
8+
addpath(plan.RootFolder)
9+
10+
if isMATLABReleaseOlderThan("R2023b")
11+
plan("test") = matlab.buildtool.Task(Actions=@legacyTestTask);
12+
else
913
plan("check") = matlab.buildtool.tasks.CodeIssuesTask(pkg_name, IncludeSubfolders=true);
14+
plan("test") = matlab.buildtool.tasks.TestTask("test", Strict=true);
1015
end
1116

12-
if ~isMATLABReleaseOlderThan("R2024b")
1317

18+
if isMATLABReleaseOlderThan("R2024b")
19+
plan("mex") = matlab.buildtool.Task(Actions=@legacyMexTask);
20+
else
1421
plan("clean") = matlab.buildtool.tasks.CleanTask;
1522

1623
[compiler_id, compiler_opt] = get_compiler_options();
@@ -33,41 +40,29 @@
3340

3441

3542
function legacyMexTask(context)
36-
37-
pkg_name = "+stdlib";
38-
39-
legacy_mex_build(context.Plan.RootFolder, fullfile(context.Plan.RootFolder, pkg_name))
40-
43+
legacy_mex_build(context.Plan.RootFolder, fullfile(context.Plan.RootFolder, "+stdlib"))
4144
end
4245

4346

44-
function testTask(context)
47+
function legacyTestTask(context)
48+
r = runtests(fullfile(context.Plan.RootFolder, "test"), Strict=true);
49+
% Parallel Computing Toolbox takes more time to startup than is worth it for this task
4550

46-
addpath(context.Plan.RootFolder)
47-
48-
r = runtests("test", ...
49-
IncludeSubfolders=true, ...
50-
strict=true, ...
51-
UseParallel=false);
52-
% Parallel Computing Toolbox takes more time to startup than is worth it for this task
53-
54-
assert(~isempty(r), "No tests were run")
55-
assertSuccess(r)
51+
assert(~isempty(r), "No tests were run")
52+
assertSuccess(r)
5653
end
5754

5855

5956
function coverageTask(context)
60-
61-
coverage_run("stdlib", fullfile(context.Plan.RootFolder, "test"))
57+
coverage_run("stdlib", fullfile(context.Plan.RootFolder, "test"))
6258
end
6359

6460

6561
function publishTask(context)
62+
outdir = fullfile(context.Plan.RootFolder, "docs");
6663

67-
outdir = fullfile(context.Plan.RootFolder, "docs");
68-
69-
publish_gen_index_html("stdlib", ...
70-
"A standard library of functions for Matlab.", ...
71-
"https://github.com/geospace-code/matlab-stdlib", ...
72-
outdir)
64+
publish_gen_index_html("stdlib", ...
65+
"A standard library of functions for Matlab.", ...
66+
"https://github.com/geospace-code/matlab-stdlib", ...
67+
outdir)
7368
end

0 commit comments

Comments
 (0)