-
Notifications
You must be signed in to change notification settings - Fork 222
Expand file tree
/
Copy pathbuildfile.m
More file actions
72 lines (57 loc) · 2.12 KB
/
Copy pathbuildfile.m
File metadata and controls
72 lines (57 loc) · 2.12 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
64
65
66
67
68
69
70
71
72
function plan = buildfile
import matlab.buildtool.tasks.*
import matlab.buildtool.Task
plan = buildplan(localfunctions);
plan("clean") = CleanTask;
plan("check") = CodeIssuesTask(Results="issues.mat");
reportFormat = matlab.unittest.plugins.codecoverage.CoverageReport('coverage-report');
covPlugin = matlab.unittest.plugins.CodeCoveragePlugin.forFolder("gramm","Producing", reportFormat);
plan("runExample") = ExampleDrivenTesterTask("gramm/examples", CodeCoveragePlugin = covPlugin);
plan("publish").Inputs = "gramm/examples/*.m";
plan("publish").Outputs = "gramm/examples/html/**";
plan("package").Dependencies = ["check" "runExample"];
plan.DefaultTasks = ["check" "runExample"];
end
function packageTask(~)
% Create MLTBX package
prjFile = "gramm.prj";
packagingData = matlab.addons.toolbox.ToolboxOptions(prjFile);
tagVersion = getenv("CI_COMMIT_TAG");
if ~isempty(tagVersion)
if startsWith(tagVersion, 'v')
tagVersion = erase(tagVersion, 'v');
end
packagingData.ToolboxVersion = tagVersion;
end
outputFileName = packagingData.ToolboxName + "_" + packagingData.ToolboxVersion + ".mltbx";
packagingData.OutputFile = outputFileName;
matlab.addons.toolbox.packageToolbox(packagingData);
fprintf("Created %s.\n", outputFileName);
end
function publishTask(~)
% Create HTML pages from examples
examplesDir = fullfile("gramm", "examples");
htmlDir = fullfile(examplesDir, "html");
if ~isfolder(htmlDir)
mkdir(htmlDir);
end
mFiles = dir(fullfile(examplesDir, "example_*.m"));
if isempty(mFiles)
error("buildfile:publishTask", "No example_*.m files found in %s.", examplesDir);
end
opts.format = 'html';
opts.outputDir = htmlDir;
opts.showCode = true;
opts.figureSnapMethod = 'print';
fprintf("Publishing %d examples to HTML...\n", numel(mFiles));
for i = 1:numel(mFiles)
srcFile = fullfile(examplesDir, mFiles(i).name);
fprintf(" %s\n", mFiles(i).name);
publish(srcFile, opts);
end
indexOpts.format = 'html';
indexOpts.outputDir = htmlDir;
indexOpts.showCode = false;
publish(fullfile(examplesDir, "index.m"), indexOpts);
fprintf("Published index.html\n");
end