Code covered by the BSD License  

Highlights from
M-file dependency consolidator

3.75

3.8 | 4 ratings Rate this file 19 Downloads (last 30 days) File Size: 1.92 KB File ID: #31164

M-file dependency consolidator

by

 

22 Apr 2011 (Updated )

Will take a given m-file, or directory of such files, and consolidate any dependent m/mex files

| Watch this File

File Information
Description

This function will take a given m-file, or directory of such files, and copy all necessary related function files (m and mex) to the target directory, excluding any MatLab provided ones (e.g. toolboxes).

I often have to distribute my code to others who'd like run similar numerical models, (un)fortunately my software-engineer mindset means a lot of reused functions, scattered over a number of organized 'tool' folders in my matlab path.
This makes packaging everything needed to give to someone else a bit difficult.
MatLab provides a dependency report tool, but it isn't recursive, and does not provide the ability to even open the dependent files, let alone copy them.

My search for a solution turned up 2 promising functions in File Exchange, but neither worked for me - and when I tried to edit them, it was apparent that they were far more cluttered than needed to be.

So I wrote my own from scratch.
I hope it will be useful for others as well.

Known issues:
if the same dependent function is encountered in multiple source files (directory traversal), it is copied multiple times and will have multiple entries in output file list.
I'm not sure how to avoid this without complicating the recursion too much.

Acknowledgements

Package inspired this file.

MATLAB release MATLAB 7.11 (R2010b)
Other requirements uses only matlab function calls, so should be platform independent
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
20 Dec 2012 Paul

Friend, I owe you a drink. At the very least.

27 Feb 2012 Mike

This worked perfectly for me in R2009b.

26 Apr 2011 Jit

Thanks, I found the typo further down as well.
Odd, because it worked for me even with the typo...
Fixed.

I flip-flopped on how I wanted it to behave on the input, but I usually do something like:
../main_script.m
../dependencies/

Hence why I wouldn't want the src copied too.
I thought it might also be an issue for directory recursion, and also why I forced it to not drill down directories on SRC, but now I'm thinking I could just set it up to check for DEST paths in the source, and skip those.

Jedediah: Could you see if the new version works for you now? I'd like to make it work for earlier matlab releases as well, as long as it's not too much work - but no longer have access to the older releases myself.

26 Apr 2011 Gordon

There's a bug in the code (alluded to by Jedediah above). You need to check line 37.

"IS_recursvie = false;"

should be

"IS_recursive = false;"

Once I fixed that, this worked great on the file I threw at it. I actually like turning recursive on: if I'm copying all the dependencies to a directory, I probably want the source file in there too.

Sorry for the double post.

26 Apr 2011 Gordon

Oh yeah, I use 2010a

25 Apr 2011 Jit

Works fine for me.
Maybe if you actually used the same matlab version (R2010B), as clearly stated in the above file information.

25 Apr 2011 Jedediah Frey

Doesn't work. Fails immediately:
>> deppkg('print_problem2','test')
??? Input argument "IS_recursive" is undefined.

Error in ==> deppkg at 67
if IS_recursive
-
MATLAB Version 7.9.1.705 (R2009b) Service Pack 1

Updates
26 Apr 2011

Fixed typo identified by Gordon and Jedediah.

Also fixed an error in the file list output - it was including files that were skipped as well.

Contact us