]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/rpp_generate_lib.m
Fix rpp_update_doc to update the documentation in split libraries
[pes-rpp/rpp-simulink.git] / rpp / blocks / rpp_generate_lib.m
1 % RPP_GENERATE_LIB  Generates rpp_lib.slx library for the current target.
2
3 % Copyright (C) 2013-2015 Czech Technical University in Prague
4 %
5 % Authors:
6 %     - Michal Horn <hornmich@fel.cvut.cz>
7 %
8 % This document contains proprietary information belonging to Czech
9 % Technical University in Prague. Passing on and copying of this
10 % document, and communication of its contents is not permitted
11 % without prior written authorization.
12 %
13 % File : rpp_generate_lib.m
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 function rpp_generate_lib()
20     blocks = rpp_get_blcoks()
21         d = fullfile(getpref('rpp', 'TargetRoot'), '..', 'blocks');
22         cd(d)
23
24     try,
25         load_system('rpp_lib.slx');
26     catch ME
27         new_system('rpp_lib', 'Library');
28     end
29         set_param('rpp_lib', 'Lock', 'off');
30         oldBlocks = find_system('rpp_lib', 'Type', 'block');
31         disp('Removing old blocks:');
32         for j=1:length(oldBlocks),
33                 disp(['    ', oldBlocks{j}]);
34                 delete_block(oldBlocks{j});
35         end
36         disp('Adding new blocks:');
37         for j=1:length(blocks),
38                 blockFilePath=[blocks{j}, '.slx'];
39                 disp(['    from: ', blockFilePath, ':']);
40                 load_system(blockFilePath)
41                 newBlocks = find_system(blocks{j}, 'Type', 'block');
42                 for k=1:length(newBlocks),
43                         [tok, blockName] = strtok(newBlocks{k}, '/');
44                         blockName = ['rpp_lib', blockName];
45                         disp(['        ', newBlocks{k}, ' as ', blockName]);
46                         add_block(newBlocks{k}, blockName);
47                 end
48                 close_system(blockFilePath, 0);
49         end
50         disp(['Closing and saving file ', 'rpp_lib.slx']);
51         set_param('rpp_lib', 'Lock', 'on');
52         close_system('rpp_lib.slx', 1);
53 end