]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blobdiff - rpp/rpp/rpp_setup.m
Change license to MIT
[pes-rpp/rpp-simulink.git] / rpp / rpp / rpp_setup.m
index 92b5f045ba2ecfd0d6d59d34c6bea1e8c5e1bc98..5045a7378a8a9fd5a22dffce8de6217ce3b2d49c 100644 (file)
@@ -1,28 +1,44 @@
-% RPP_SETUP  RPP Target install script
-%   RPP_SETUP asks for the path to the Code Composer Studio's compiler.
-%   RPP_SETUP(PATH) uses the PATH argument as the path to the
-%   compiler.
-%
-% This script configures RPP target for use. It stores the location of
-% armcl compiler and other location of other directories needed for
-% proper function of the target. Finally, it compiles S-Function
-% for RPP target blocks.
-
-
-% Copyright (C) 2013, 2014 Czech Technical University in Prague
+% Copyright (C) 2013, 2014, 2015 Czech Technical University in Prague
 %
 % Authors:
 %     - Carlos Jenkins <carlos@jenkins.co.cr>
 %
-% This document contains proprietary information belonging to Czech
-% Technical University in Prague. Passing on and copying of this
-% document, and communication of its contents is not permitted
-% without prior written authorization.
+% Permission is hereby granted, free of charge, to any person
+% obtaining a copy of this software and associated documentation
+% files (the "Software"), to deal in the Software without
+% restriction, including without limitation the rights to use,
+% copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the
+% Software is furnished to do so, subject to the following
+% conditions:
+
+% The above copyright notice and this permission notice shall be
+% included in all copies or substantial portions of the Software.
+
+% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+% OTHER DEALINGS IN THE SOFTWARE.
 %
 % File : rpp_setup.m
 % Abstract:
 %     RPP Target install script.
 %
+%        This script configures RPP target for use. It stores the location of
+%        armcl compiler and other location of other directories needed for
+%        proper function of the target. Finally, it compiles S-Function
+%        for RPP target blocks.
+%
+%        RPP_SETUP  RPP Target install script
+%        RPP_SETUP asks for the path to the Code Composer Studio's compiler.
+%        RPP_SETUP(PATH) uses the PATH argument as the path to the
+%        compiler.
+%
+%
 %     IMPORTANT: This script _MUST_ be run by user after extracting the target
 %                package and before using the target. To execute:
 %
 % References:
 %     rtw_ug.pdf p. 1137
 
-
 function rpp_setup(varargin)
     % Get current target path in user's filesystem
     currentPath = pwd();
     targetPath = currentPath(1:end-length('/rpp'));
 
-    % Add target system folders to Matlab path
-    addpath(fullfile(targetPath, 'rpp'));
-    addpath(fullfile(targetPath, 'demos'));
-    addpath(fullfile(targetPath, 'blocks'));
-    %addpath(fullfile(targetPath, 'help'));
-    savepath();
+    if ~exist(fullfile(targetPath, 'rpp', 'rpp_setup.m'), 'file'),
+        error('rpp:wrong_setup_dir', ['rpp_setup called from directory ' ...
+                            'other than .../rpp/rpp']);
+    end
 
     if nargin == 0,
         % Ask user setup variables
@@ -72,19 +85,32 @@ function rpp_setup(varargin)
         return;
     end
 
-    % Save preferences
+    % Remove old paths and preferences (if any)
     if ispref('rpp')
+        oldTargetPath = getpref('rpp', 'TargetRoot');
+        rmpath(fullfile(oldTargetPath, '..', 'rpp'));
+        rmpath(fullfile(oldTargetPath, '..', 'demos'));
+        rmpath(fullfile(oldTargetPath, '..', 'blocks'));
         rmpref('rpp');
     end
+
+    % Add target system folders to Matlab path
+    addpath(fullfile(targetPath, 'rpp'));
+    addpath(fullfile(targetPath, 'demos'));
+    addpath(fullfile(targetPath, 'blocks'));
+    savepath();
+
+    % Save preferences
     addpref('rpp', 'CompilerRoot', CompilerRoot);
     addpref('rpp', 'CCSRoot'     , CCSRoot);
     addpref('rpp', 'TargetRoot'  , TargetRoot);
     addpref('rpp', 'RppLibRoot'  , RppLibRoot);
 
 
-    % Generate blocks
+    % Generate blocks and library
     cd('../blocks');
     compile_blocks();
+    rpp_generate_lib();
     cd(currentPath);
 
     % Generate help
@@ -101,6 +127,7 @@ function rpp_setup(varargin)
     disp(['        CCSRoot      : ', CCSRoot]);
     disp(['        TargetRoot   : ', TargetRoot]);
     disp(['        RppLibRoot   : ', RppLibRoot]);
+    disp(['        Hardware     : ', rpp_get_target]);
     disp('Explore <a href="matlab:cd([getpref(''rpp'',''TargetRoot''),''/../demos''])">demos</a> directory.');
     %disp('Explore <a href="matlab:cd([getpref(''rpp'',''TargetRoot''),''/../demos''])">demos</a> directory and access <a href="matlab:doc -classic">documentation</a>');
 end