source: trunk/src/compile.m @ 787

Last change on this file since 787 was 747, checked in by sommeria, 10 years ago

adpatations to 3D fields

File size: 1.5 KB
Line 
1%'compile': compile a Matlab function, create a binary in a subdirectory /bin
2%--------------------------------------------------------------------
3% compile (FctName)
4%
5%INPUT:
6%FctName: name of the Matlab fct to compile (without .m extension)
7%
8function compile (FctName,SubfctPath)
9if isempty(which('mcc'))
10    msgbox_uvmat('ERROR','no Matlab compiler toolbox mcc installed')
11    return
12else
13    hh=msgbox_uvmat('WAITING...',['compilation of ' FctName ' in progress...']);
14end
15disp(['compiling ' FctName ' ...'])
16% commands to compile civ_matlab and eventually other functions
17if ~exist('bin','dir')
18    [success,errormsg]=mkdir('bin');
19    if success~=1
20        display(errormsg)
21    end
22end
23if ~isempty(SubfctPath)
24    SubfctPath=['-I ' SubfctPath];%string indicating the option of including the path SubfctPath
25end
26disp(['mcc -m -R -nojvm -R -nodisplay ' SubfctPath ' ' FctName '.m'])
27try
28    eval(['mcc -m -R -nojvm -R -nodisplay ' SubfctPath ' ' FctName '.m'])% compile the source file [FctName .m], which produces a binary file FctName and a cmd file [run_' FctName '.sh]
29    system(['mv -f ' FctName ' bin/']);%move the binary file FctName to the subdir /bin
30    system(['sed -e ''''s#/' FctName '#/bin/' FctName '#'''' run_' FctName '.sh > ' FctName '.sh']);%modify the cmd file and copy it to [FctName '.sh']
31    system(['rm run_' FctName '.sh']);% remove the initial cmd file [run_' FctName '.sh]
32    system(['chmod +x ' FctName '.sh']); % set the cmd file to 'executable'
33catch ME
34    msgbox_uvmat('ERROR',ME.message);
35end
36display('** END **')
37delete(hh)
38
39
40
Note: See TracBrowser for help on using the repository browser.