|
1 | | -% |
| 1 | +% |
2 | 2 | % 1 - Check if version requirements |
3 | | -% are satisfied and the packages are |
| 3 | +% are satisfied and the packages are |
4 | 4 | % are installed/loaded: |
5 | | -% Octave > 4 |
6 | | -% - image |
7 | | -% - optim |
8 | | -% - struct |
9 | | -% - statistics |
| 5 | +% Octave > 4 |
| 6 | +% - image |
| 7 | +% - optim |
| 8 | +% - struct |
| 9 | +% - statistics |
10 | 10 | % |
11 | | -% MATLAB > R2017a |
| 11 | +% MATLAB > R2017a |
12 | 12 | % |
13 | 13 | % 2 - Add project to the O/M path |
14 | 14 |
|
15 | 15 | function initEnv |
16 | | - |
| 16 | + |
17 | 17 | octaveVersion = '4.0.3'; |
18 | 18 | matlabVersion = '9.2.0'; |
19 | 19 |
|
20 | | -if isOctave |
| 20 | + if isOctave |
21 | 21 |
|
22 | | -% Exit if min version is not satisfied |
23 | | -if ~compare_versions(OCTAVE_VERSION,octaveVersion,'>=') |
24 | | - error('Minimum required Octave version: %s', octaveVersion); |
25 | | -end |
| 22 | + % Exit if min version is not satisfied |
| 23 | + if ~compare_versions(OCTAVE_VERSION, octaveVersion, '>=') |
| 24 | + error('Minimum required Octave version: %s', octaveVersion); |
| 25 | + end |
26 | 26 |
|
27 | | -installlist = {'statistics'}; |
28 | | -for ii=1:length(installlist) |
29 | | - try |
30 | | - % Try loading Octave packages |
31 | | - disp(['loading ' installlist{ii}]) |
32 | | - pkg('load',installlist{ii}) |
33 | | - |
34 | | - catch |
35 | | - errorcount = 1; |
36 | | - while errorcount % Attempt twice in case installation fails |
37 | | - try |
38 | | - pkg('install','-forge',installlist{ii}) |
39 | | - pkg('load',installlist{ii}) |
40 | | - errorcount = 0; |
41 | | - catch err |
42 | | - errorcount = errorcount+1; |
43 | | - if errorcount>2 |
44 | | - error(err.message) |
| 27 | + installlist = {'statistics'}; |
| 28 | + for ii = 1:length(installlist) |
| 29 | + try |
| 30 | + % Try loading Octave packages |
| 31 | + disp(['loading ' installlist{ii}]); |
| 32 | + pkg('load', installlist{ii}); |
| 33 | + |
| 34 | + catch |
| 35 | + errorcount = 1; |
| 36 | + while errorcount % Attempt twice in case installation fails |
| 37 | + try |
| 38 | + pkg('install', '-forge', installlist{ii}); |
| 39 | + pkg('load', installlist{ii}); |
| 40 | + errorcount = 0; |
| 41 | + catch err |
| 42 | + errorcount = errorcount + 1; |
| 43 | + if errorcount > 2 |
| 44 | + error(err.message); |
| 45 | + end |
45 | 46 | end |
46 | 47 | end |
47 | 48 | end |
48 | 49 | end |
49 | | -end |
50 | | - |
51 | 50 |
|
| 51 | + else % MATLAB ---------------------------- |
52 | 52 |
|
53 | | -else % MATLAB ---------------------------- |
54 | | - |
55 | | -if verLessThan('matlab', matlabVersion) |
56 | | - error('Sorry, minimum required version is R2017b. :('); |
57 | | -end |
| 53 | + if verLessThan('matlab', matlabVersion) |
| 54 | + error('Sorry, minimum required version is R2017b. :('); |
| 55 | + end |
58 | 56 |
|
59 | | -end |
| 57 | + end |
60 | 58 |
|
61 | | -% If external dir is empty throw an exception |
62 | | -% and ask user to update submodules. |
63 | | -if numel(dir('lib')) <= 2 % Means that the external is empty |
64 | | - error(['Git submodules are not cloned! \n' ... |
65 | | - 'try this in your terminal: \n ...' |
66 | | - 'git submodule update --recursive ']); |
67 | | -else |
68 | | - addDependencies(); |
69 | | -end |
| 59 | + % If external dir is empty throw an exception |
| 60 | + % and ask user to update submodules. |
| 61 | + if numel(dir('lib')) <= 2 % Means that the external is empty |
| 62 | + error(['Git submodules are not cloned! \n' ... |
| 63 | + 'try this in your terminal: \n ...' |
| 64 | + 'git submodule update --recursive ']); |
| 65 | + else |
| 66 | + addDependencies(); |
| 67 | + end |
70 | 68 |
|
71 | | -disp('Correct matlab/octave verions and added to the path!'); |
| 69 | + disp('Correct matlab/octave verions and added to the path!'); |
72 | 70 |
|
73 | 71 | end |
74 | 72 |
|
75 | 73 | %% |
76 | 74 | %% Return: true if the environment is Octave. |
77 | 75 | %% |
78 | 76 | function retval = isOctave |
79 | | - persistent cacheval; % speeds up repeated calls |
| 77 | + persistent cacheval % speeds up repeated calls |
80 | 78 |
|
81 | | - if isempty (cacheval) |
82 | | - cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0); |
83 | | - end |
| 79 | + if isempty (cacheval) |
| 80 | + cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0); |
| 81 | + end |
84 | 82 |
|
85 | | - retval = cacheval; |
| 83 | + retval = cacheval; |
86 | 84 | end |
87 | 85 |
|
88 | 86 | function addDependencies() |
|
0 commit comments