]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blobdiff - rpp/rpp/rpp_setup.m
Remove old Matlab paths when calling rpp_setup again
[pes-rpp/rpp-simulink.git] / rpp / rpp / rpp_setup.m
index a5cc9708fe546794e0dbb9243dc9a5d8876c8417..65266502135e19cba8481365e789ac86fc28cfd6 100644 (file)
@@ -38,13 +38,6 @@ function rpp_setup(varargin)
     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 nargin == 0,
         % Ask user setup variables
         if ispref('rpp', 'CompilerRoot')
@@ -71,17 +64,29 @@ 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();