How can I know which files are being used by my compiled GUI?

Hello,
I've created a uitility via App Designer, and compiled an exe version for my colleagues to use it as well.
The utiliy composed of all sorts of files: *.m , *.jpg , *.xml
I'd like to prepare a "distribution" folder with only the necessary files. I mean the main exe file itself + (???)
How this can be done? Obviously if I open the exe and try to do a certain functionality, I may revieve an error if a certain file is missing. So that way I know for sure this file is required to be included in my "distribution folder". BUT, the GUI has a lot of options / functionalities / modes of operation... I don't want to go a check each and everyone of them, to see if it works in the compiled version.
So, either I simply share with everyone the FULL Project folder that contains everything, or is there a smart & easy way to do this selection?
THANK YOU.

9 Comments

The m files should be taken care of by the compiler (unless you're using things like eval, in which case it's on you).
I'm not aware of any automated tools to detect the use of other files.
thank you Rik. Even for the m-files. In my project folder I have many m-files, some of them are obsolete version which is not being used in the final version of the project.
Can I somehow identify them automatically?
Required source code files (not data files or such)
fLists = matlab.codetools.requiredFilesAndProducts('YourGUI.m')
fLists gives you the files which are required for creating the exe file, right? for compilation process.
How can I have a list of all the files that are need to be added to the already compiled exe file?
I mean, can I share with my co-workers only the exe file or do I need to create a distribution folder which included any addional files?
"How can I have a list of all the files that are need to be added to the already compiled exe file?"
How on earth MATLAB can know that? You the app designer you should know what files are needed.
It's quite easy actually. All MATLAB has to do is to scan my code for lines like:
"imread" , "load" , etc...
and provide a list of all the files which are being called in during the App functionality.
Suppose I have created a GUI with hundredrs of different files it rely on? Mat files, JPEG files, xml files, you name it...
They're stored in dozen of different folders. Now, can't MATLAB really tell me which files needs to be added to the compilation folders? which files need to be shared along with the exe distribution folder?
How on Earth you got to LEVEL 8 MVP without seeing this clearly?!
Suppose your app calls uigetfile to let the user select a data file to import. Let's say that call tells MATLAB to allow the user to select an XML file that contains configuration data for a particular type of problem. [It doesn't hard-code the name of a specific XML file.] Should the Compiler then look for all XML files on your computer and "figure out" which of those "look like" a configuration file? Or should it depend on you to tell it which configuration files it should include in your application?
Suppose I have created a GUI with hundredrs of different files it rely on? Mat files, JPEG files, xml files, you name it...
Then for your own sake and the sake of developers who may be working on this GUI in the future you should probably have those files organized in some way that makes it easy to distinguish what is needed for what parts of your GUI's functionality. Look at MATLAB itself -- there are hundreds or thousands of MATLAB functions but they're organized into directories that (more or less) all relate to a particular type of capability.
  • The graph and network algorithms functions are in the graphfun directory.
  • The sparse matrix functions are more or less all in the sparfun directory.
  • The string processing functions live in the strfun directory.
When I want to look at one of those functions, knowing generally what "category" it belongs to gives me a good idea where I need to go to look at it. If you have your files organized, you should be able to more easily determine if a category of files need to be included.
The Projects functionality in MATLAB can help with organizing your files, as could using a source control management system..
Now, can't MATLAB really tell me which files needs to be added to the compilation folders? which files need to be shared along with the exe distribution folder?
Not necessarily just from static analysis, no.
Thank you Steven.
Of cource my files are organised and I do use Project for that.
Your "uigetfile" example is not a good. If I allow user to import a file into the system, then most likely I'll do some kind of an analysis with it, so, it's not the use case I'm talking about.
Obviosuly, in the end, I'm doing the manual process, trying to include all the file needed for the GUI to run.
I was looking for a more systematic-bulit-proof process, that can provide me a garantee, that all the files required for the APP to run, would be within reach.
The point of the already compiled file is that it should already include all m files. Therefore asking for identification of all other files doesn't make sense, for reasons Steven pointed out.
I personally use my own system of flags in comments when I call one of my own functions. Not bulletproof, but it works reasonably well. I use it to compose a single large m file, but gathering files for a compilation to exe should also be possible.

Sign in to comment.

 Accepted Answer

You can get a list of all functions that could possibly be run by your program using the attached function. When you compile the main app, these dependent m-files will automatically be included in the compiled executable so there is nothing you need to do to enable that. However if you want to ship your source code somewhere, like upload it to the File Exchange or make a "Source Code" subfolder on your target computer, that would be useful for locating all the m-files that you need to ship.
If there are run-time files of yours that are needed, such as Excel template files, MAT files, sound files, splash images, other data files, etc. you just have to find those. Usually I know what files my app will open. Just to be sure I use the search function to search my code for all extensions that I know I use, such as search for .xlsx, .png, .txt, .wav, .mat, etc.
Of course if there are some that your user specifies as input data while running your function, you can't possibly know what your user will pick. Those are their own files.

More Answers (0)

Categories

Products

Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!