[593] | 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) |
---|
[809] | 7 | |
---|
| 8 | %======================================================================= |
---|
[1027] | 9 | % Copyright 2008-2018, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[809] | 10 | % http://www.legi.grenoble-inp.fr |
---|
| 11 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
[593] | 12 | % |
---|
[809] | 13 | % This file is part of the toolbox UVMAT. |
---|
| 14 | % |
---|
| 15 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 16 | % it under the terms of the GNU General Public License as published |
---|
| 17 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 18 | % or (at your option) any later version. |
---|
| 19 | % |
---|
| 20 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 23 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 24 | %======================================================================= |
---|
| 25 | |
---|
[606] | 26 | function compile (FctName,SubfctPath) |
---|
[1034] | 27 | |
---|
[992] | 28 | hh=[]; % handles of message display window |
---|
[1034] | 29 | |
---|
[593] | 30 | if isempty(which('mcc')) |
---|
[746] | 31 | msgbox_uvmat('ERROR','no Matlab compiler toolbox mcc installed') |
---|
[593] | 32 | return |
---|
[746] | 33 | else |
---|
[747] | 34 | hh=msgbox_uvmat('WAITING...',['compilation of ' FctName ' in progress...']); |
---|
[593] | 35 | end |
---|
[1034] | 36 | |
---|
[606] | 37 | disp(['compiling ' FctName ' ...']) |
---|
[1034] | 38 | |
---|
[593] | 39 | % commands to compile civ_matlab and eventually other functions |
---|
| 40 | if ~exist('bin','dir') |
---|
| 41 | [success,errormsg]=mkdir('bin'); |
---|
| 42 | if success~=1 |
---|
| 43 | display(errormsg) |
---|
| 44 | end |
---|
| 45 | end |
---|
[1034] | 46 | |
---|
[606] | 47 | if ~isempty(SubfctPath) |
---|
[992] | 48 | SubfctPath=['-I ' SubfctPath]; % string indicating the option of including the path SubfctPath |
---|
[606] | 49 | end |
---|
[1034] | 50 | |
---|
[923] | 51 | [mcrmajor, mcrminor] = mcrversion; |
---|
| 52 | MCRROOT = ['MCRROOT',int2str(mcrmajor),int2str(mcrminor)]; |
---|
| 53 | FctNameVersion=[FctName,'_',MCRROOT]; |
---|
[1034] | 54 | |
---|
[746] | 55 | try |
---|
[830] | 56 | disp(['mcc -m -R -nojvm -R -nodisplay -R -singleCompThread ' SubfctPath ' ' FctName '.m']) |
---|
[800] | 57 | 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] |
---|
[992] | 58 | system(['mv -f ' FctName ' bin/']); % move the binary file FctName to the subdir /bin |
---|
| 59 | system(['sed -e ''''s#/' FctName '#/bin/' FctName '#'''' run_' FctName '.sh > ' FctNameVersion '.sh']); % modify the cmd file and copy it to [FctName '.sh'] |
---|
| 60 | system(['rm run_' FctName '.sh']); % remove the initial cmd file [run_' FctName '.sh] |
---|
[895] | 61 | system(['chmod +x ' FctNameVersion '.sh']); % set the cmd file to 'executable' |
---|
[746] | 62 | catch ME |
---|
[830] | 63 | hh=msgbox_uvmat('ERROR',ME.message); |
---|
[746] | 64 | end |
---|
[1034] | 65 | |
---|
[593] | 66 | display('** END **') |
---|
[1034] | 67 | |
---|
[830] | 68 | if ~isempty(hh) |
---|
[1034] | 69 | delete(hh) |
---|
[830] | 70 | end |
---|
[593] | 71 | |
---|
| 72 | |
---|