source: trunk/src/compile.m @ 863

Last change on this file since 863 was 830, checked in by sommeria, 10 years ago
File size: 2.5 KB
RevLine 
[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%=======================================================================
9% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
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]26function compile (FctName,SubfctPath)
[830]27hh=[];% handles of message display window
[593]28if isempty(which('mcc'))
[746]29    msgbox_uvmat('ERROR','no Matlab compiler toolbox mcc installed')
[593]30    return
[746]31else
[747]32    hh=msgbox_uvmat('WAITING...',['compilation of ' FctName ' in progress...']);
[593]33end
[606]34disp(['compiling ' FctName ' ...'])
[593]35% commands to compile civ_matlab and eventually other functions
36if ~exist('bin','dir')
37    [success,errormsg]=mkdir('bin');
38    if success~=1
39        display(errormsg)
40    end
41end
[606]42if ~isempty(SubfctPath)
43    SubfctPath=['-I ' SubfctPath];%string indicating the option of including the path SubfctPath
44end
[830]45
[746]46try
[830]47    disp(['mcc -m -R -nojvm -R -nodisplay -R -singleCompThread ' SubfctPath ' ' FctName '.m'])
[800]48    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]
[746]49    system(['mv -f ' FctName ' bin/']);%move the binary file FctName to the subdir /bin
50    system(['sed -e ''''s#/' FctName '#/bin/' FctName '#'''' run_' FctName '.sh > ' FctName '.sh']);%modify the cmd file and copy it to [FctName '.sh']
51    system(['rm run_' FctName '.sh']);% remove the initial cmd file [run_' FctName '.sh]
52    system(['chmod +x ' FctName '.sh']); % set the cmd file to 'executable'
53catch ME
[830]54    hh=msgbox_uvmat('ERROR',ME.message);
[746]55end
[593]56display('** END **')
[830]57if ~isempty(hh)
[746]58delete(hh)
[830]59end
[593]60
61
Note: See TracBrowser for help on using the repository browser.