Be the first to rate this file! 12 Downloads (last 30 days) File Size: 6.46 KB File ID: #40595
image thumbnail

Deploy pcoded Matlab Files

by

 

01 Mar 2013 (Updated )

Creates recursively p-coded files and the associated help text, works also for classes and packages

| Watch this File

File Information
Description

Sometimes it’s necessary to obscure the content of MATLAB source code that was developed. While the MATLAB function “pcode” encrypts the M-file, the help of the file gets lost. A way to fix this, is to create a second file, with the same name as the encrypted P-file, but with the M-file extension. Furthermore it’s necessary to add the function signature to the top.
If there are a lot of files to keep up to date, this can produce a lot of work.
In addition the supporting help M-file must always be created before the P-file, otherwise MATLAB complains.
This function creates P-files and the associated help M-files for a given folder and stores it to a given destination folder.
It works fully recursively and also can handle MATLAB Classes, Class-Folders (@Directories) as well as MATLAB Package-Folders (+Directories)

  DEPLOY creates p-coded files and the associated help text of a given
  source to a given destination folder. Works recursive on folder trees,
  including Package folders (+Package) and classes as well as class folders
  (@Class). For classes no help is created for the private functions in the
  private folder, but help is also created for all public get / constant
  properties.
 
  Syntax: deploy( source, destination, varargin)
 
  Inputs:
    -source: Can be a single M-file or a folder, also works for
                    packages and Classes
    -destination: Has to be an empty folder
    -varargin: The folowing options can be added:
                    'excludes' - the files to exclude, always excluded
                    is this file itself
                    'includes' - the additional files to deploy, e.g.
                    {'*.pdf', '*.png'}
                    'recursive' - default is true, can be set to false.
                    Packages and Class directories are
                    always included and cannot be
                    excluded
                    'includeDLL' - Dll's are by default included. To
                    exclude Dll's set this option to false
                    'includeMex' - Mex files are by default included, To
                    exclude Mex files, set this option to
                    false
                    'includeHiddenDirs - by default . presceded folders
                    and files are excluded by default,
                    set this option to true to
                    include . preceded folders,
                    e.g. .svn or .git
                    'purgeDestination' - ATTENTION, if this option is
                    set to true, the destination
                    will be deleted and all its
                    subdirectories without further
                    warning.
 
  Outputs:
    -none
  Example:
    deploy( 'myfun.m', 'for_public' ); % where myfun.m is a function and
                    for_public a folder
    deploy( 'myproject', 'for_public' ); % where myproject is a folder
                    and for_public a folder
    deploy('myproject', 'project_v1.0', 'recursive', true, ...
            'includeHiddenDirs', true, 'purgeDestination', true, ...
            'includes', {'*.pdf', '*.png'});
 
  Other m-files required:
    None
 
  Other files required:
    MATLAB
 
  See also: pcode

Acknowledgements

Deploypcode Recursively Pcode Files With Help Attached inspired this file.

MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
02 Mar 2013 Eydrian

Hi Sven, thanks for the reply. I'm new to file exchange and still not sure how to really use it or whats really helpful to add.

Your submission was very nice, but a bit of an overkill for my projects. So I basically simplified it for my purpose and uploaded it again.

I removed the copy right in the file as it not belongs there anyway.

About the feval, one of the cases I use it, is when I need just one field of a structure and discard the rest. You know of a better solution.

The other submission - my first submission - came out actually pretty nice ;) In the end it does actually more or less the same thing, except that it handles quite all Maltab classes and in addition it uses just a few lines for a similar output.

I'm glad for any advice on how I can produce more useful code.

01 Mar 2013 Sven

Just a question Eydrian... is there anything your submission does in addition to the file it is based on? All I can tell so far is that there's some different error checking, recursive ability (and most options) have been removed, and a rather prominent copyright section has been added with your own name on it.

I only ask because your other submission seems to follow the exact same pattern...

Anyway, as for the code itself, the error checking is nice but I would steer clear of all usage of feval()...

Updates
04 Mar 2013

removed the prominent copyright as it not belongs there. I'm new to matlab central and I didn't really see where it has to go ;)

19 Jun 2013

added support for full recursion
added support for Matlab Classes
added support for Matlab ClassFolders (@Directories)
added support for Matlab PackageFolders (+Folders)

20 Jun 2013

Updated summary

24 Jun 2013

Updated the description.
Remove the license from the mfile as it not belongs there.

27 Jun 2013

destination was created even if no files to process
single files couldn't be processed
when deploying @class as direct source, the @class folder structure wasn't kept.
when deploying +package as direct source, the +package structure wasn't kept

Contact us