]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/rpp/rpp_setup.m
Improved C-Mex S-Functions for LOUT.
[pes-rpp/rpp-simulink.git] / rpp / rpp / rpp_setup.m
1 % Copyright (C) 2013 Czech Technical University in Prague
2 %
3 % Authors:
4 %     - Carlos Jenkins <carlos@jenkins.co.cr>
5 %
6 % This program is free software; you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation; either version 2 of the License, or
9 % (at your option) any later version.
10 %
11 % This program is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 %
19 % File : rpp_setup.m
20 % Abstract:
21 %     This file script adds paths for RPP target to the MATLAB path.
22 %     IMPORTANT: This script _MUST_ be run by user after installing before
23 %     using the target. To do so:
24 %         1. Extract target package.
25 %         2. Change directory (cd) to this file folder.
26 %         3. Execute rpp_setup();
27 %
28 % References:
29 %     rtw_ug.pdf p. 1137
30
31
32 function rpp_setup()
33
34     % Get current target path in user's filesystem
35     currentPath = pwd();
36     targetPath = currentPath(1:end-length('/rpp'));
37
38     % Add target system folders to Matlab path
39     addpath(fullfile(targetPath, 'rpp'));
40     addpath(fullfile(targetPath, 'demos'));
41     addpath(fullfile(targetPath, 'blocks'));
42     %addpath(fullfile(targetPath, 'help'));
43     savepath();
44
45     % Ask user setup variables
46     possiblePath = '/usr/local/ti/ccsv5/tools/compiler/arm_5.0.1';
47
48     CompilerRoot = fix_slash(uigetdir(possiblePath, ...
49         'CCS Compiler root directory: (<ccs_root>/tools/compiler/arm_5.X.X)'));
50     CCSRoot      = fileparts(fileparts(fileparts(CompilerRoot)));
51     TargetRoot   = fix_slash(currentPath);
52     RppLibRoot   = fullfile(fileparts(TargetRoot), 'lib');
53
54     % Save preferences
55     if ispref('rpp')
56         rmpref('rpp');
57     end
58     addpref('rpp', 'CompilerRoot', CompilerRoot);
59     addpref('rpp', 'CCSRoot'     , CCSRoot);
60     addpref('rpp', 'TargetRoot'  , TargetRoot);
61     addpref('rpp', 'RppLibRoot'  , RppLibRoot);
62
63
64     % Generate blocks
65     cd('../blocks');
66     compile_blocks();
67     cd(currentPath);
68
69     % Generate help
70     % FIXME: Write and generate help
71     %cd('../help/source');
72     %genenerate_help();
73     %cd(currentPath);
74
75     % Apply changes and finish
76     sl_refresh_customizations();
77     disp('<strong>RPP</strong> Target setup is complete!');
78     disp('    Current configuration:');
79     disp(['        CompilerRoot : ', CompilerRoot]);
80     disp(['        CCSRoot      : ', CCSRoot]);
81     disp(['        TargetRoot   : ', TargetRoot]);
82     disp(['        RppLibRoot   : ', RppLibRoot]);
83     disp('Explore <a href="matlab:cd([getpref(''rpp'',''TargetRoot''),''/../demos''])">demos</a> directory.');
84     %disp('Explore <a href="matlab:cd([getpref(''rpp'',''TargetRoot''),''/../demos''])">demos</a> directory and access <a href="matlab:doc -classic">documentation</a>');
85 end
86
87
88 function path = fix_slash(path0)
89     path = path0;
90     if ispc
91         path(path=='\')='/';
92     end
93 end