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 | % |
---|
8 | function compile (FctName,SubfctPath) |
---|
9 | if isempty(which('mcc')) |
---|
10 | msgbox_uvmat('ERROR','no Matlab compiler toolbox mcc installed') |
---|
11 | return |
---|
12 | else |
---|
13 | hh=msgbox_uvmat('WAITING...',['compilation of ' FctName ' in progress...']); |
---|
14 | end |
---|
15 | disp(['compiling ' FctName ' ...']) |
---|
16 | % commands to compile civ_matlab and eventually other functions |
---|
17 | if ~exist('bin','dir') |
---|
18 | [success,errormsg]=mkdir('bin'); |
---|
19 | if success~=1 |
---|
20 | display(errormsg) |
---|
21 | end |
---|
22 | end |
---|
23 | if ~isempty(SubfctPath) |
---|
24 | SubfctPath=['-I ' SubfctPath];%string indicating the option of including the path SubfctPath |
---|
25 | end |
---|
26 | disp(['mcc -m -R -nojvm -R -nodisplay -R -singleCompThread ' SubfctPath ' ' FctName '.m']) |
---|
27 | try |
---|
28 | eval(['mcc -m -R -nojvm -R -nodisplay -R -singleCompThread ' 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' |
---|
33 | catch ME |
---|
34 | msgbox_uvmat('ERROR',ME.message); |
---|
35 | end |
---|
36 | display('** END **') |
---|
37 | delete(hh) |
---|
38 | |
---|
39 | |
---|
40 | |
---|
Note: See
TracBrowser
for help on using the repository browser.