Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions buildfile.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function plan = buildfile

% Create a plan from the task functions
plan = buildplan(localfunctions);

Expand All @@ -12,31 +13,38 @@
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"), ...
plan("build:mex:"+folderName) = matlab.buildtool.tasks.MexTask(fullfile(folder, "**/*.cpp"), ...
mexOutputFolder, ...
Filename=folderName);
end
plan("mex").Description = "Build MEX functions";
plan("build:mex").Description = "Build MEX functions";
plan("build").Description = "Build the toolbox";

% Define the "check" task
% Define the "check" task as a sub task of validate
sourceFolder = files(plan, "toolbox");
plan("check") = matlab.buildtool.tasks.CodeIssuesTask(sourceFolder,...
plan("validate:check") = matlab.buildtool.tasks.CodeIssuesTask(sourceFolder,...
IncludeSubfolders = true);

% Define the "test" task
% Define the "test" task as a sub task of validate
testsFolder = files(plan, "tests");
plan("test") = matlab.buildtool.tasks.TestTask(testsFolder,...
plan("validate: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";
plan("validate").Description = "Validate the toolbox";

% Make "build" task group the default task
plan.DefaultTasks = "build";

% Make the "validate" task dependent on "build" task group
plan("validate").Dependencies = "build";

% Make the "package" task dependent on "validate" task group
plan("package").Dependencies = "validate";
plan("package").Outputs = fullfile("release","Arithmetic_Toolbox.mltbx");
end

function releaseTask(~)
function packageTask(~)
% Create an MLTBX package
releaseFolderName = "release";
if isMATLABReleaseOlderThan("R2025a")
Expand All @@ -60,4 +68,4 @@ function releaseTask(~)
mkdir(releaseFolderName)
end
matlab.addons.toolbox.packageToolbox(opts);
end
end