0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % INSTALLEXTENSIONSFORDIR installs the toolbox extensions found under the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % given directory.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % CALL: utils.helper.installExtensionsForDir(dir)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % M Hewitson 29-10-10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % $Id: installExtensionsForDir.m,v 1.8 2011/03/25 15:14:42 mauro Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 function res = installExtensionsForDir(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 extdir = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 if ~ischar(extdir)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 error('input a path to a directory of LTPDA extensions');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 fprintf('* installing extensions under %s ...\n', extdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % toolbox path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 aopath = fileparts(which('ao'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 parts = regexp(aopath, '@', 'split');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 classpath = parts{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % for each user class, look for a corresponding directory and copy any
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % extension methods in.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % copy <module>/classes/<user_class>/<methods> to the toolbox
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 userclasses = utils.helper.ltpda_userclasses;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 installedClassMethods = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 for ucl = userclasses
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 extsdir = fullfile(extdir, 'classes', ucl{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 if exist(extsdir, 'dir')==7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 fprintf(' * installing extensions for class %s ...\n', ucl{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 files = utils.prog.filescan(extsdir, '.m');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 dstdir = fullfile(classpath, ['@' ucl{1}]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 for kk = 1:numel(files)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 f = files{kk};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 [path,name,ext] = fileparts(f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 fprintf(' installing %s -> %s\n', name, ucl{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 [success, message, messageid] = copyfile(f, dstdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 if ~success
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 fprintf(stderr, 'Failed to copy file %s to %s : %s', f, dstdir, message);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 installedClassMethods = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 % Add subdirs to the MATLAB path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 addpath(extdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 % In order to include user-defined classes, we just need to add the <module>/classes folder
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 addpath(fullfile(extdir, 'classes'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % In order to include user-defined models, we need to add the <module>/models folder and subfolders
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 addpath(genpath(fullfile(extdir, 'models')));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 % In order to include user-defined functions, we need to add the <module>/functions folder and subfolders
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 addpath(genpath(fullfile(extdir, 'functions')));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 % In order to include user-defined tests, we need to add the <module>/tests folder and subfolders
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 addpath(genpath(fullfile(extdir, 'tests')));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % It might be useful to remove the 'CVS' and '.svn' folders, if any
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 utils.helper.remove_cvs_from_matlabpath();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 utils.helper.remove_svn_from_matlabpath();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 res = installedClassMethods;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 if installedClassMethods
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 fprintf('----------------------------------------------------------------\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 fprintf(' Additional class methods were installed. These will be \n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 fprintf(' available next time you run ''clear all'' or ''clear classes''.\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 fprintf('----------------------------------------------------------------\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77
|