-
Notifications
You must be signed in to change notification settings - Fork 1
/
helicsStartupOld.m
64 lines (54 loc) · 1.49 KB
/
helicsStartupOld.m
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
function success = helicsStartup(helicsLibPath)
% HELICSSTARTUP configures MATLAB for HELICS use
if nargin < 1
%If not specified use our location, which should have required lib once
%compiled/installed
helicsLibPath = fileparts(mfilename('fullpath'));
end
fprintf('Loading HELICS (from %s)...\n', helicsLibPath)
%% Extract HELICS library name in a cross-platform way
listing = dir(fullfile(helicsLibPath, '*helics.*'));
libraryName = '';
%TODO: vectorize (make MATLAB-esque)
for i=1:numel(listing)
[~, ~, ext]=fileparts(listing(i).name);
if isequal(ext, '.h')
continue;
end
if isequal(ext, '.lib')
continue;
end
if isequal(ext, '.a')
continue;
end
libraryName = listing(i).name;
end
%% Try some backups if not found
if isempty(libraryName)
%if we are empty try for a debug version
listing = dir(fullfile(helicsLibPath, '*helics.*'));
for i=1:numel(listing)
[~, ~, ext]=fileparts(listing(i).name);
if isequal(ext, '.h')
continue;
end
if isequal(ext, '.lib')
continue;
end
if isequal(ext, '.a')
continue;
end
libraryName = listing(i).name;
end
end
if (~isempty(libraryName))
[~,name]=fileparts(libraryName);
if ~libisloaded(name)
loadlibrary(GetFullPath(fullfile(helicsLibPath, libraryName)));
end
else
disp('Unable to find library for HELICS')
end
if nargout >1
success = ~isempty(libraryName);
end