diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac3e8f350f1bd94aecd17267dda029078aba114c..7c178f148078da5297830014708ae806eaa711cb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,6 +142,20 @@ pkg_macOS_arm64: expire_in: 3 days needs: [ "build_doc" ] +pkg_matlab_online: + stage: pkg + script: + - meson rewrite kwargs set project / version "$VERSION" + - cd scripts/matlab-online && ./packageDynare.sh + tags: + - matlab-online + artifacts: + paths: + - scripts/matlab-online/*.mltbx + expire_in: 3 days + needs: [] + when: manual + test_matlab: stage: test script: diff --git a/scripts/matlab-online/packageDynare.m b/scripts/matlab-online/packageDynare.m index 055cf1ab46e34bebd714e6528683d39d5b7f26e5..68e90ec6c70801bbc69948b7383881e79247476a 100644 --- a/scripts/matlab-online/packageDynare.m +++ b/scripts/matlab-online/packageDynare.m @@ -1,4 +1,4 @@ -function packageDynare(zipfile, version, logo) +function packageDynare(zipfile, version, version_sanitized, logo) tfolder = tempname; mkdir(tfolder) @@ -10,7 +10,7 @@ unzip(zipfile,dynarefld) % create tbx options opts = matlab.addons.toolbox.ToolboxOptions(dynarefld, "dynare", ... ToolboxName = "Dynare", ... - ToolboxVersion = version, ... + ToolboxVersion = version_sanitized, ... Summary = "Solves, simulates and estimates a wide class of economic models", ... AuthorName = "Dynare Team", ... ToolboxImageFile = logo, ... diff --git a/scripts/matlab-online/packageDynare.sh b/scripts/matlab-online/packageDynare.sh index 9e9bc1e78b0a5eaa5657a33140de4b0536a9f7ad..c659163466fd522fb3f177646702f40941a2faa5 100755 --- a/scripts/matlab-online/packageDynare.sh +++ b/scripts/matlab-online/packageDynare.sh @@ -1,11 +1,15 @@ #!/bin/bash set -exo pipefail -# Creates a dynare-X.Y.mltbx in the current repository, using the settings below. -# Needs to be run from Ubuntu 24.04 LTS, with the needed packages installed. +# Creates a dynare-X.Y.mltbx in the current repository, using the settings +# below. Needs to be run from Ubuntu, with the needed packages installed. +# The required Ubuntu version can be obtained by running “!lsb_release -a” in +# MATLAB Online. X13ASVER=1-1-b61 -MATLABPATH=/opt/MATLAB/R2024b +MATLABVER=R2024b + +MATLABPATH=/opt/MATLAB/${MATLABVER} # TODO: change size and put white background for better rendering in MATLAB Add-Ons browser DYNARE_PNG_LOGO=../../preprocessor/doc/logos/dlogo.png @@ -18,13 +22,23 @@ cleanup () trap cleanup EXIT pushd ../.. -meson setup -Dmatlab_path="$MATLABPATH" -Dbuildtype=release -Dprefer_static=true "$tmpdir"/build-matlab-online +meson setup -Dbuild_for=matlab -Dmatlab_path="$MATLABPATH" -Dbuildtype=release -Dprefer_static=true "$tmpdir"/build-matlab-online cd "$tmpdir"/build-matlab-online -meson compile +meson compile -v meson install --destdir "$tmpdir" DYNAREVER=$(meson introspect --projectinfo | jq -r '.version') +# Sanitize the version number so that is corresponds to MATLAB toolbox +# requirements: the version must be a scalar string or character vector of the +# form Major.Minor.Bug.Build, where Bug and Build are optional. +# Hence remove any character which is not a number or a dot, and ensure that we +# have at least a minor version number. +DYNAREVER_SANITIZED=${DYNAREVER//[^0-9.]/} +if [[ ${DYNAREVER_SANITIZED} != *.* ]]; then + DYNAREVER_SANITIZED=${DYNAREVER_SANITIZED}.0 +fi + cd .. strip usr/local/bin/dynare-preprocessor strip usr/local/lib/dynare/mex/matlab/*.mexa64 @@ -45,4 +59,4 @@ zip -q -r "$tmpdir"/dynare.zip * # make toolbox popd -"$MATLABPATH/bin/matlab" -batch "packageDynare('$tmpdir/dynare.zip', '$DYNAREVER', '$DYNARE_PNG_LOGO')" +"$MATLABPATH/bin/matlab" -batch "packageDynare('$tmpdir/dynare.zip', '$DYNAREVER', '$DYNAREVER_SANITIZED', '$DYNARE_PNG_LOGO')"