How to deploy a matlab project with references
Show older comments
Hi everybody,
I have a project (let's call it "MainProject") with some files, folders and everything in it. It also refere to others projects (i.e. "child project 1", "child project 2",...). In "MainProject" I have this file ("mainGUI") that is the one that do all the magic and allow the access to all the functionalities I need.
The source code is working great and thanks to the "Dependency Analyzer" tool I knwo I don't have any broken or misspelled calls anywhere. This is true till I load on my path everything included in any referenced project.
Now I have to produce a stand alone executable starting with my projects, an ideally it should behave live the source code. Usually I do so using the "Application compiler" app, selecting the file to run at startup ("mainGUI" in this case), set some other options (like output folders and author details) and the app do everything else.
One thing that this mathworks app is doing but not so great is to find the dependencies from the "mainGUI" file. I hoped to help it using the projects, but there seems to be any way to make these two features (projects and application compiler app) to work togheter.
Am I missing something? Is there any workaround? Do you know if Mathworks staff is working on something to integrate these two features?
Thanks in advance,
Jacopo
5 Comments
Rik
on 17 Dec 2021
This is why I rolled my own system.
I have a large folder with all my functions, and I have marked every dependency when I call another function. Then my builder function goes through the entry function and recursively builds a list of all functions to be included. These are then concatenated in one big m-file that can span several thousand lines of code.
Jacopo Remondina
on 17 Dec 2021
Rik
on 17 Dec 2021
I can't, but subfolders shouldn't be too hard to implement if you write something yourself. Packages will be tricky.
Because the code was never intended to be used by anyone other than me, it is a huge mess (some code changes are not documented etc). It is really terrible and I should probably rewrite it from scratch anyway.
The main principle is that I write my code like this:
function data=ThisIsAnExample(filename)
opts.print_to_fid=fopen('log.txt','w');% redirect error messages to log file
%#dependencies{readfile}
str=readfile(filename);
try ME=[]; %#ok<NASGU>
data=str2double(str);
catch ME;if isempty(ME),ME=lasterror;end %#ok<LERR>
%#dependencies{warning_}
warning_(opts,ME)
data=[];
end
fclose(fid);
end
My builder then looks for a line starting with '%#dependencies{' and includes the function name(s) in the list of dependencies. When writing the final function it will skip those lines.
Jacopo Remondina
on 17 Dec 2021
Rik
on 17 Dec 2021
It works for me, I never meant to claim it would work for someone else.
Although I think with enough care it should be possible to create something relatively robust. Even if that might turn out to replicate projects.
The whole point of my way is to have a single m-file for each project. That means you don't actually have any dependencies to worry about (at least not m-files).
Answers (0)
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!