|
3 | 3 |
|
4 | 4 | plan.DefaultTasks = "test"; |
5 | 5 |
|
| 6 | +if ~isMATLABReleaseOlderThan("R2023b") |
| 7 | + plan("check") = matlab.buildtool.tasks.CodeIssuesTask("+stdlib", IncludeSubfolders=true); |
| 8 | +end |
| 9 | + |
6 | 10 | if ~isMATLABReleaseOlderThan("R2024b") |
7 | 11 |
|
8 | 12 | cxx = mex.getCompilerConfigurations('c++'); |
| 13 | + flags = cxx.Details.CompilerFlags; |
| 14 | + |
| 15 | + msvc = startsWith(cxx.ShortName, "MSVCPP"); |
9 | 16 |
|
10 | 17 | % disp("Mex using: " + cxx.Name + " " + cxx.Version) |
11 | 18 |
|
12 | | - compiler_opt = "CXXFLAGS=$CXXFLAGS -std=c++17"; |
| 19 | + std = "-std=c++17"; |
| 20 | + compiler_id = ""; |
13 | 21 | % FIXME: Windows oneAPI |
14 | | - if startsWith(cxx.ShortName, "MSVCPP") |
15 | | - compiler_opt = "COMPFLAGS=$COMPFLAGS /std:c++17"; |
| 22 | + if msvc |
| 23 | + std = "/std:c++17"; |
16 | 24 | elseif ismac |
17 | | - compiler_opt = "CXXFLAGS=$CXXFLAGS -std=c++17"; |
| 25 | + % keep for if-logic |
18 | 26 | elseif isunix && cxx.ShortName == "g++" |
19 | | - compiler_opt = compiler_opt + " -fPIC"; |
20 | 27 | % FIXME: update when desired GCC != 10 for newer Matlab |
21 | 28 | if isMATLABReleaseOlderThan("R2025b") && ~startsWith(cxx.Version, "10") |
22 | 29 | % https://www.mathworks.com/help/matlab/matlab_external/choose-c-or-c-compilers.html |
23 | 30 | % https://www.mathworks.com/help/matlab/matlab_external/change-default-gcc-compiler-on-linux-system.html |
24 | 31 | [s, ~] = system("which g++-10"); |
25 | 32 | if s == 0 |
26 | | - compiler_opt = "CXX=g++-10 " + compiler_opt; |
| 33 | + compiler_id = "CXX=g++-10"; |
27 | 34 | else |
28 | 35 | warning("GCC 10 not found, using default, may fail on runtime") |
29 | 36 | end |
30 | 37 | end |
31 | 38 | end |
32 | 39 |
|
| 40 | + if msvc |
| 41 | + compiler_opt = "COMPFLAGS=" + flags + " " + std; |
| 42 | + else |
| 43 | + compiler_opt = compiler_id + " CXXFLAGS=" + flags + " " + std; |
| 44 | + end |
| 45 | + |
33 | 46 | root = plan.RootFolder; |
34 | 47 | bin = fullfile(root, "bin"); |
35 | 48 | if ~isfolder(bin), mkdir(bin), end |
|
46 | 59 | end |
47 | 60 |
|
48 | 61 |
|
49 | | -function checkTask(~) |
50 | | -% Identify code issues (recursively all Matlab .m files) |
51 | | -issues = codeIssues("+stdlib"); |
52 | | -assert(isempty(issues.Issues), formattedDisplayText(issues.Issues)) |
53 | | -end |
54 | | - |
55 | 62 | function testTask(~) |
56 | 63 | t = fileparts(mfilename("fullpath")); |
57 | 64 | addpath(t) |
58 | 65 |
|
59 | | - r = runtests(IncludeSubfolders=true, strict=true, UseParallel=true, OutputDetail="Concise"); |
| 66 | + r = runtests("test", ... |
| 67 | + IncludeSubfolders=true, ... |
| 68 | + strict=true, ... |
| 69 | + UseParallel=true, ... |
| 70 | + OutputDetail="Concise"); |
60 | 71 |
|
61 | 72 | assert(~isempty(r), "No tests were run") |
62 | 73 | assertSuccess(r) |
|
0 commit comments