-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdependencyCheck.m
More file actions
127 lines (94 loc) · 3.82 KB
/
dependencyCheck.m
File metadata and controls
127 lines (94 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function dependencyCheck()
% Check that all dependencies are licensed and installed
% Copyright 2020 National Technology & Engineering Solutions of Sandia,
% LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
% U.S. Government retains certain rights in this software.
%
% This file is part of WecOptTool.
%
% WecOptTool is free software: you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation, either version 3 of
% the License, or (at your option) any later version.
%
% WecOptTool is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public
% License along with WecOptTool. If not, see
% <https://www.gnu.org/licenses/>.
import WecOptTool.system.hasToolbox
allfoundflag = true;
fprintf('\nWecOptTool Dependency Checker\n');
fprintf('-------------------------------\n');
%% Required Products
fprintf('\n');
fprintf('Required\n');
fprintf('--------\n');
%% Optimisation Toolbox
[optimBoxFound, ...
optimBoxLicensed, ...
optimBoxInstalled] = hasToolbox("Optimization_Toolbox", ...
"Optimization Toolbox");
print_dependency("Optimization Toolbox", ...
optimBoxInstalled, ...
optimBoxLicensed);
allfoundflag = allfoundflag && optimBoxFound;
%% Nemoh
nemohExistFlag = WecOptTool.base.NEMOH.isNemohInPath();
print_dependency("NEMOH", nemohExistFlag);
%% Optional Products
fprintf('\n');
fprintf('Optional\n');
fprintf('--------\n');
%% Parallel Computing Toolbox
[~, ...
parallelBoxLicensed, ...
parallelBoxInstalled] = hasToolbox("Distrib_Computing_Toolbox", ...
"Parallel Computing Toolbox");
print_dependency("Parallel Toolbox", ...
parallelBoxInstalled, ...
parallelBoxLicensed);
%% Global Optimization Toolbox
[~, ...
globOptBoxLicensed, ...
globOptBoxInstalled] = hasToolbox("GADS_Toolbox", ...
"Global Optimization Toolbox");
print_dependency("Global Optimization Toolbox", ...
globOptBoxInstalled, ...
globOptBoxLicensed);
%% WAFO
wafoFunction = 'bretschneider';
wafoPath = fullfile('wafo', 'spec','bretschneider.m');
wafoCheck = lower(which(wafoFunction));
wafoInstalled = contains(wafoCheck, wafoPath) && ...
(exist(wafoCheck, 'file') == 2);
print_dependency("WAFO", wafoInstalled);
%% End matter
fprintf('\n')
% Warn if execution not possible
if ~allfoundflag
warning("Mandatory dependencies are missing!")
end
end
function print_dependency(name, installed, licensed, options)
arguments
name
installed
licensed = true
options.columns = 45
end
name = name + ":";
if licensed && installed
nChars = options.columns - 6;
fprintf('%-*s Found\n', nChars, name);
elseif ~licensed && installed
nChars = options.columns - 11;
fprintf('%-*s Unlicensed\n', nChars, name);
else
nChars = options.columns - 14;
fprintf('%-*s Not Installed\n', nChars, name);
end
end