-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildfile.m
82 lines (64 loc) · 1.97 KB
/
buildfile.m
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function plan = buildfile
plan = buildplan(localfunctions);
% Open project if it is not open
if isempty(matlab.project.rootProject)
openProject(plan.RootFolder);
end
% Set default task
plan.DefaultTasks = "test";
% Create shorthand for files/folders
codeFiles = fullfile("PokerHandsToolbox","*");
testFiles = fullfile("tests","*");
tbxPackagingFiles = fullfile("Example_ToolboxOptionsObject","*");
tbxOutputFile = pokerHandToolboxDefinition().OutputFile;
% Configure tasks
plan("test").Inputs = [codeFiles,testFiles];
% plan("test").Dependencies = "check";
plan("toolbox").Inputs = [codeFiles,tbxPackagingFiles];
plan("toolbox").Outputs = tbxOutputFile;
plan("toolbox").Dependencies = "test";
% plan("toolbox").Dependencies = ["check","test"];
% Have the clean task try to clean the outputs of the toolbox task, if it exists
plan("clean").Inputs = matlab.buildtool.io.Glob(tbxOutputFile);
end
%% Tasks
function testTask(context)
% Run all tests
testFolder = fullfile(context.Plan.RootFolder, "tests");
results = runtests(testFolder, ...
IncludeSubfolders = true, ...
OutputDetail = "terse");
results.assertSuccess;
end
function toolboxTask(~)
% Package toolbox
packageMyToolbox();
end
function cleanTask(context)
% Remove auto-generated files
filesToClean = context.Task.Inputs.paths;
for ii = 1:numel(filesToClean)
if isfile(filesToClean(ii))
delete(filesToClean(ii));
relPath = erase(filesToClean(ii),context.Plan.RootFolder+filesep);
disp("Deleted: " + relPath);
end
end
end
% function checkTask(context)
% % Identify code issues
% codeResults = codeIssues(context.Plan.RootFolder);
%
% errInd = codeResults.Issues.Severity == "error";
% if any(errInd)
% disp(" ");
% disp("FAILED! Found critical errors in your code:");
% disp(codeResults.Issues(errInd,:));
% disp(" ");
%
% errMsg = "Code Analyzer found critical errors in your code." + newline + ...
% "Please see diagnostics above.";
% error(errMsg);
% end
%
% end