Modifying the MATLAB » History » Version 12

Chris Cannam, 2014-03-13 11:14 AM

1 1 Chris Cannam
h1. Modifying the MATLAB
2 1 Chris Cannam
3 2 Chris Cannam
h2. Context
4 2 Chris Cannam
5 2 Chris Cannam
You want to change something in the MATLAB code and deploy the changed version.
6 2 Chris Cannam
7 2 Chris Cannam
h2. You will need
8 2 Chris Cannam
9 2 Chris Cannam
 * A computer with a licensed copy of MATLAB. This step uses the "mcc" compiler included in the MATLAB distribution.
10 2 Chris Cannam
 * The Java development kit (JDK) of whichever version your MATLAB installation expects. Current MATLAB seems to call for Java 7.
11 2 Chris Cannam
12 6 Chris Cannam
You do *not* need the separate MATLAB compiler runtime package at this stage.
13 1 Chris Cannam
14 6 Chris Cannam
The computer you run this build step on does *not* need to be the same kind (make, platform, architecture, operating system) as the server you intend to deploy the web app on. However, you do need to make sure you have the same version of MATLAB as the compiler runtime you will be using on the server.
15 6 Chris Cannam
16 11 Chris Cannam
The most likely "production" setup is to have a workstation or server with a licensed copy of MATLAB on it, and to use that for this step; and then to have a separate, different machine (such as a Linux server) without MATLAB installed but with the MCR, which is used for the subsequent web app build and deploy (see [[Modifying the webapp]]).
17 10 Chris Cannam
18 3 Chris Cannam
h2. What to change; limitations
19 3 Chris Cannam
20 3 Chris Cannam
The webapp repository includes the MATLAB code as a sub-repository, in a directory called @mcode@. Any MATLAB code in this directory can be called from the web app. The calling convention uses a MATLAB struct to pass the arguments, as you can see in the existing examples.
21 3 Chris Cannam
22 9 Chris Cannam
File access is a thorny subject. Compiled MATLAB is usually run in its own environment in which the current working directory is an unpredictable temporary location. It's safest to assume that the current working directory is unavailable or unknown, and to pass in a working or scratch directory as one of the MATLAB function arguments and then use paths relative to that.
23 3 Chris Cannam
24 3 Chris Cannam
h2. How to rebuild
25 4 Chris Cannam
26 12 Chris Cannam
In the main directory of the web app project (i.e. above the @mcode@ directory), either run the @mcc@ compiler directly or use the @build-isvr@ Ant file.
27 4 Chris Cannam
28 4 Chris Cannam
To run @mcc@ directly, you need a command like this (which is also documented in the INSTALL file)
29 4 Chris Cannam
30 4 Chris Cannam
<pre>
31 5 Chris Cannam
$ /Applications/MATLAB_R2013b.app/bin/mcc -W "java:uk.ac.soton.isvr,HumanEcho" \
32 5 Chris Cannam
    -d ./scratch -T "link:lib" -v "class{HumanEcho:./mcode/simulateBinauralSignals.m}"
33 4 Chris Cannam
</pre>
34 4 Chris Cannam
35 4 Chris Cannam
The paths will depend on your operating system and MATLAB version.
36 4 Chris Cannam
37 4 Chris Cannam
To use Ant, you just need to run
38 4 Chris Cannam
39 4 Chris Cannam
<pre>
40 4 Chris Cannam
$ ant -f build-isvr.xml
41 4 Chris Cannam
</pre>
42 4 Chris Cannam
43 1 Chris Cannam
However, the paths and suchlike are still system-dependent, so the Ant build file may have the wrong paths in it and may need fixing itself!
44 6 Chris Cannam
45 6 Chris Cannam
This should produce a file called @isvr.jar@ in the @scratch@ directory.
46 6 Chris Cannam
47 8 Chris Cannam
You will need to copy that file into the @WebContent/WEB-INF/lib/@ directory in the equivalent build tree on your server (or whatever machine you are going to rebuild the web app on -- see the rebuild section of [[Modifying the webapp]] -- that one *does* need to be at least the same kind of computer as your server).
48 6 Chris Cannam
49 6 Chris Cannam
One way to accomplish that might be to copy it to @WebContent/WEB-INF/lib/@ on this machine, then commit and push to version control, and then pull from the machine you are building the web app on.
50 7 Chris Cannam
51 7 Chris Cannam
Now proceed to the rebuild section of [[Modifying the webapp]].