]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/compile_blocks.m
doc: Update documentation of external mode and related stuff
[pes-rpp/rpp-simulink.git] / rpp / blocks / compile_blocks.m
1 % Copyright (C) 2013-2014 Czech Technical University in Prague
2 %
3 % Authors:
4 %     - Carlos Jenkins <carlos@jenkins.co.cr>
5 %
6 % This document contains proprietary information belonging to Czech
7 % Technical University in Prague. Passing on and copying of this
8 % document, and communication of its contents is not permitted
9 % without prior written authorization.
10 %
11 % File : compile_blocks.m
12 % Abstract:
13 %     Compile all the C-MEX S-Function in current folder.
14 %
15 % References:
16 %     http://www.mathworks.com/help/matlab/ref/mex.html
17 %     http://www.mathworks.com/help/matlab/matlab_external/custom-building-mex-files.html
18
19
20 function compile_blocks()
21
22     % Options:
23     % -g        Create a binary MEX-file containing additional symbolic
24     %           information for use in debugging. This option disables the mex
25     %           default behavior of optimizing built object code
26     %           (see the -O option).
27     % -v        Verbose mode. Print the values for important internal variables
28     %           after the options file is processed and all command-line
29     %           arguments are considered. Prints each compile step and final
30     %           link step fully evaluated.
31     % options = '-v -g';
32     options = '';
33     matlabRootPath=strcat('"',matlabroot(),'"');
34     mex = fullfile(matlabRootPath, 'bin', 'mex');
35
36     sources = dir('sfunction_*.c');
37
38     for i = sources'
39         local_opts = options;
40         if strcmp(i.name, 'sfunction_canreceive.c') || ...
41            strcmp(i.name, 'sfunction_cantransmit.c'),
42             local_opts = [local_opts ' ' ...
43                 '-I' matlabRootPath '/toolbox/shared/can/src/scanutil ' ...
44                 '-I' matlabRootPath '/toolbox/rtw/targets/common/can/datatypes ' ...
45                 matlabRootPath '/toolbox/rtw/targets/common/can/datatypes/sfun_can_util.c '...
46                 matlabRootPath '/toolbox/rtw/targets/common/can/datatypes/can_msg.c'];
47         end
48         command = [mex ' ' i.name ' ' local_opts];
49         disp(command);
50         [status, result] = system(command);
51         if status ~= 0,
52             disp(result)
53             throw(MException('rpp:compile_block_failure', [i.name, ' failed to compile']))
54         end
55     end
56
57 end