]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/rpp/rpp_setup.m
Change the license from GPL to proprietary
[pes-rpp/rpp-simulink.git] / rpp / rpp / rpp_setup.m
1 % RPP_SETUP  Setup RPP code generation target.
2 %   RPP_SETUP asks for the path to the Code Composer Studio's compiler.
3 %   RPP_SETUP(PATH) uses the PATH argument as the path to the compiler.
4
5 % Copyright (C) 2013 Czech Technical University in Prague
6 %
7 % Authors:
8 %     - Carlos Jenkins <carlos@jenkins.co.cr>
9 %
10 % This document contains proprietary information belonging to Czech
11 % Technical University in Prague. Passing on and copying of this
12 % document, and communication of its contents is not permitted
13 % without prior written authorization.
14 %
15 % File : rpp_setup.m
16 % Abstract:
17 %     RPP Target install script.
18 %
19 %     IMPORTANT: This script _MUST_ be run by user after extracting the target
20 %                package and before using the target. To execute:
21 %
22 %         1. Start Matlab.
23 %         2. Change directory (cd) to this file folder.
24 %         3. Execute rpp_setup on command window.
25 %
26 % References:
27 %     rtw_ug.pdf p. 1137
28
29
30 function rpp_setup(varargin)
31     % Get current target path in user's filesystem
32     currentPath = pwd();
33     targetPath = currentPath(1:end-length('/rpp'));
34
35     % Add target system folders to Matlab path
36     addpath(fullfile(targetPath, 'rpp'));
37     addpath(fullfile(targetPath, 'demos'));
38     addpath(fullfile(targetPath, 'blocks'));
39     %addpath(fullfile(targetPath, 'help'));
40     savepath();
41
42     if nargin == 0,
43         % Ask user setup variables
44         if ispref('rpp', 'CompilerRoot')
45             possiblePath = getpref('rpp', 'CompilerRoot');
46         else
47             possiblePath = '/usr/local/ti/ccsv5/tools/compiler/arm_5.0.1';
48         end
49
50         CompilerRoot = fix_slash(uigetdir(possiblePath, ...
51                                           ['CCS Compiler root ' ...
52                             'directory: (<ccs_root>/tools/compiler/arm_5.X.X)']));
53     else
54         CompilerRoot = fix_slash(varargin{1});
55     end
56     CCSRoot      = fileparts(fileparts(fileparts(CompilerRoot)));
57     TargetRoot   = fix_slash(currentPath);
58     RppLibRoot   = fullfile(fileparts(TargetRoot), 'lib');
59
60     armcl = fullfile(CompilerRoot, 'bin', 'armcl');
61     if ~exist(armcl),
62         disp(sprintf('Error: "%s" does not exist!', armcl));
63         return;
64     end
65
66     % Save preferences
67     if ispref('rpp')
68         rmpref('rpp');
69     end
70     addpref('rpp', 'CompilerRoot', CompilerRoot);
71     addpref('rpp', 'CCSRoot'     , CCSRoot);
72     addpref('rpp', 'TargetRoot'  , TargetRoot);
73     addpref('rpp', 'RppLibRoot'  , RppLibRoot);
74
75
76     % Generate blocks
77     cd('../blocks');
78     compile_blocks();
79     cd(currentPath);
80
81     % Generate help
82     % FIXME: Write and generate help
83     %cd('../help/source');
84     %genenerate_help();
85     %cd(currentPath);
86
87     % Apply changes and finish
88     sl_refresh_customizations();
89     disp('<strong>RPP</strong> Target setup is complete!');
90     disp('    Current configuration:');
91     disp(['        CompilerRoot : ', CompilerRoot]);
92     disp(['        CCSRoot      : ', CCSRoot]);
93     disp(['        TargetRoot   : ', TargetRoot]);
94     disp(['        RppLibRoot   : ', RppLibRoot]);
95     disp('Explore <a href="matlab:cd([getpref(''rpp'',''TargetRoot''),''/../demos''])">demos</a> directory.');
96     %disp('Explore <a href="matlab:cd([getpref(''rpp'',''TargetRoot''),''/../demos''])">demos</a> directory and access <a href="matlab:doc -classic">documentation</a>');
97 end
98
99
100 function path = fix_slash(path0)
101     path = path0;
102     if ispc
103         path(path=='\')='/';
104     end
105 end