Skip to content

Commit

Permalink
Merge pull request #104 from ImperialCollegeLondon/task/package
Browse files Browse the repository at this point in the history
task: Replace `toolbox-template.xml` with `matlab.addons.toolbox.ToolboxOptions`
  • Loading branch information
mfacchinelli authored Feb 7, 2025
2 parents 5920900 + 9290dec commit f796845
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 189 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up MATLAB
uses: matlab-actions/[email protected]
with:
release: R2023b
release: R2024a
- name: Load Environment Variables
uses: aarcangeli/[email protected]
- name: Validate version with tag
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Run MATLAB Tests
strategy:
matrix:
release: ["R2023b", "R2024a", "R2024b"]
release: ["R2024a", "R2024b"]
runs-on: ubuntu-latest
steps:
- name: Check out repository
Expand Down Expand Up @@ -57,7 +57,9 @@ jobs:
reporter: java-junit
- name: Report coverage
uses: 5monkeys/cobertura-action@master
if: matrix.release == 'R2024b'
with:
path: 'artifacts/coverage.xml'
minimum_coverage: 80
skip_covered: false
report_name: Coverage Report (${{ matrix.release }})
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![MATLAB Toolbox](https://github.com/ImperialCollegeLondon/MAG-Data-Visualization-Toolbox/actions/workflows/package.yml/badge.svg)](https://github.com/ImperialCollegeLondon/MAG-Data-Visualization-Toolbox/actions/workflows/package.yml)
[![View MAG Data Visualization Toolbox on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/169568)

This repository contains utilities for processing and visualizing MAG science and HK data. The supported MATLAB releases are MATLAB R2023b and later. The following MATLAB toolboxes are required to use the toolbox:
This repository contains utilities for processing and visualizing MAG science and HK data. The supported MATLAB releases are MATLAB R2024a and later. The following MATLAB toolboxes are required to use the toolbox:

* MATLAB
* Signal Processing Toolbox
Expand Down
2 changes: 1 addition & 1 deletion buildfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

% Add the "package" task to create toolbox.
plan("package") = mag.buildtool.task.PackageTask(Description = "Package code into toolbox", ...
ToolboxTemplate = fullfile("resources/toolbox-template.xml"), ...
ProjectRoot = project.RootFolder, ...
ToolboxPath = fullfile("artifacts/MAG Data Visualization.mltbx"));

% Add the "clean" task to delete output of all tasks.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 4 additions & 1 deletion resources/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> [!WARNING]
> Starting v7.2.0, MATLAB R2023b is no longer supported.
## App

- Add option to set breakpoint for error identifier (as well as error source)
Expand All @@ -13,7 +16,7 @@

## Build

- Use of `matlab.addons.toolbox.ToolboxOptions` to replace toolbox template
- Use `matlab.addons.toolbox.ToolboxOptions` to replace toolbox template

## CI

Expand Down
133 changes: 0 additions & 133 deletions resources/toolbox-template.xml

This file was deleted.

48 changes: 28 additions & 20 deletions src/utility/+mag/+buildtool/+task/PackageTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
% PACKAGETASK Package code into toolbox.

properties (Constant, Access = private)
ToolboxProject_ (1, 1) string = "MAGDataVisualizationToolbox.prj"
ToolboxUUID (1, 1) string = "69962df8-e93e-47cd-a1d6-766ad3e9da8a"
end

properties (TaskInput)
% TOOLBOXTEMPLATE Toolbox configuration project template.
ToolboxTemplate string {mustBeScalarOrEmpty, mustBeFile}
% PROJECTROOT Project root folder.
ProjectRoot (1, 1) string {mustBeFolder} = pwd()
% TOOLBOXVERSION Toolbox configuration project template.
ToolboxVersion (1, 1) string = mag.version()
% TOOLBOXPATH Full path to toolbox to package into.
ToolboxPath string {mustBeScalarOrEmpty}
end

properties (Dependent, Hidden, TaskOutput, SetAccess = private)
% TOOLBOXPROJECT Toolbox configuration project generated by task.
ToolboxProject matlab.buildtool.io.File {mustBeScalarOrEmpty}
% TOOLBOXARTIFACT Toolbox packaged by task.
ToolboxArtifact matlab.buildtool.io.File {mustBeScalarOrEmpty}
end
Expand All @@ -34,10 +32,6 @@
end
end

function value = get.ToolboxProject(task)
value = matlab.buildtool.io.File(task.ToolboxProject_);
end

function value = get.ToolboxArtifact(task)
value = matlab.buildtool.io.File(task.ToolboxPath);
end
Expand All @@ -54,20 +48,34 @@ function packageToolbox(task, ~, version)
version (1, 1) string = task.ToolboxVersion
end

% Read template and set version number.
[~, fileName] = fileparts(task.ToolboxProject_);

template = fileread(task.ToolboxTemplate);
template = compose(template, task.ToolboxProject_, fileName, version, task.ToolboxProject_);
toolboxOptions = matlab.addons.toolbox.ToolboxOptions(task.ProjectRoot, task.ToolboxUUID, ...
ToolboxName = "MAG Data Visualization", ...
ToolboxVersion = version, ...
Description = "Source code for MAG Data Visualization toolbox.", ...
AuthorName = "Michele Facchinelli", ...
AuthorCompany = "Imperial College London", ...
ToolboxFiles = fullfile(task.ProjectRoot, ["app", "src"]), ...
ToolboxMatlabPath = task.getMATLABPath(), ...
OutputFile = task.ToolboxPath, ...
MinimumMATLABRelease = "R2024a");

toolboxOptions.SupportedPlatforms.Win64 = true;
toolboxOptions.SupportedPlatforms.Maci64 = true;
toolboxOptions.SupportedPlatforms.Glnxa64 = true;
toolboxOptions.SupportedPlatforms.MatlabOnline = false;

matlab.addons.toolbox.packageToolbox(toolboxOptions);
end
end

% Create project file.
fileId = fopen(task.ToolboxProject_, "w");
closeFile = onCleanup(@() fclose(fileId));
methods (Static, Access = private)

fprintf(fileId, "%s", template{1});
function matlabPath = getMATLABPath()

% Package toolbox.
matlab.addons.toolbox.packageToolbox(task.ToolboxProject_, task.ToolboxPath);
matlabPath = string(split(path(), pathsep()));

locMAG = contains(matlabPath, "MAG-Data-Visualization") & contains(matlabPath, ["app", "src"]);
matlabPath = matlabPath(locMAG);
end
end
end
9 changes: 2 additions & 7 deletions tests/system/package/tToolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
% TTOOLBOX Tests for installation of MAG Data Visualization toolbox.

properties (Constant, Access = private)
ProjectRoot (1, 1) string = fullfile(fileparts(mfilename("fullpath")), "../../../")
ProjectRoot (1, 1) string = fullfile(fileparts(mfilename("fullpath")), "..", "..", "..")
end

properties (TestParameter)
Expand All @@ -22,7 +22,6 @@ function packageToolbox(testCase, Version)
testCase.addTeardown(@() testCase.cleanUpToolbox(task));

% Verify.
testCase.verifyTrue(isfile(task.ToolboxProject.Path), "Project should be generated.");
testCase.verifyTrue(isfile(task.ToolboxArtifact.Path), "Toolbox should be generated.");
end

Expand Down Expand Up @@ -54,7 +53,7 @@ function installToolbox(testCase)
function task = createPackageTask(testCase)

task = mag.buildtool.task.PackageTask(Description = "Package code into toolbox", ...
ToolboxTemplate = fullfile(testCase.ProjectRoot, "resources", "toolbox-template.xml"), ...
ProjectRoot = testCase.ProjectRoot, ...
ToolboxPath = fullfile(testCase.ProjectRoot, "artifacts", "MAG Data Visualization.mltbx"));
end
end
Expand All @@ -63,10 +62,6 @@ function installToolbox(testCase)

function cleanUpToolbox(task)

if isfile(task.ToolboxProject.Path)
delete(task.ToolboxProject.Path);
end

if isfile(task.ToolboxArtifact.Path)
delete(task.ToolboxArtifact.Path);
end
Expand Down

0 comments on commit f796845

Please sign in to comment.