-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuildfile.m
More file actions
63 lines (52 loc) · 2.2 KB
/
Copy pathbuildfile.m
File metadata and controls
63 lines (52 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function plan = buildfile
% Create a plan from the task functions
plan = buildplan(localfunctions);
% Define the "clean" Task
plan("clean") = matlab.buildtool.tasks.CleanTask;
% Output folder for MEX functions
mexOutputFolder = fullfile("toolbox","derived");
% Compile Cpp source code within cpp/*Mex into MEX functions
foldersToMex = plan.files(fullfile("cpp", "*Mex")).select(@isfolder);
for folder = foldersToMex.paths
[~, folderName] = fileparts(folder);
plan("mex:"+folderName) = matlab.buildtool.tasks.MexTask(fullfile(folder, "**/*.cpp"), ...
mexOutputFolder, ...
Filename=folderName);
end
plan("mex").Description = "Build MEX functions";
% Define the "check" task
sourceFolder = files(plan, "toolbox");
plan("check") = matlab.buildtool.tasks.CodeIssuesTask(sourceFolder,...
IncludeSubfolders = true);
% Define the "test" task
testsFolder = files(plan, "tests");
plan("test") = matlab.buildtool.tasks.TestTask(testsFolder,...
IncludeSubfolders = true, OutputDetail = "terse");
% Make the "test" task the default task in the plan
plan.DefaultTasks = ["mex" "test"];
% Make the "release" task dependent on the "check" and "test" tasks
plan("release").Dependencies = ["mex" "check" "test"];
plan("release").Outputs = "release\Arithmetic_Toolbox.mltbx";
end
function releaseTask(~)
% Create an MLTBX package
releaseFolderName = "release";
if isMATLABReleaseOlderThan("R2025a")
% Toolbox packaging metadata migrated from packaging prj to project prj
% in 25a.
opts = matlab.addons.toolbox.ToolboxOptions("toolboxPackaging.prj");
else
% Create a release and put it in the release directory
opts = matlab.addons.toolbox.ToolboxOptions("arithmetic.prj");
end
% By default, the packaging GUI restricts the name of the getting started guide, so we fix that here.
opts.ToolboxGettingStartedGuide = fullfile("toolbox", "gettingStarted.mlx");
% GitHub releases don't allow spaces, so replace spaces with underscores
mltbxFileName = strrep(opts.ToolboxName," ","_") + ".mltbx";
opts.OutputFile = fullfile(releaseFolderName,mltbxFileName);
% Create the release directory, if needed
if ~exist(releaseFolderName,"dir")
mkdir(releaseFolderName)
end
matlab.addons.toolbox.packageToolbox(opts);
end