|
12 | 12 | % lsl_fname : the filename of the library |
13 | 13 |
|
14 | 14 | if ~exist('binarypath','var') || isempty(binarypath) |
15 | | - binarypath = [fileparts(mfilename('fullpath')) filesep 'bin']; |
| 15 | + binarypath = fullfile(fileparts(mfilename('fullpath')), 'bin'); |
16 | 16 | end |
17 | 17 | if ~exist('debugging','var') || isempty(debugging) |
18 | 18 | debugging = false; |
|
28 | 28 | error('Your operating system is not supported by this version of the lab streaming layer API.'); |
29 | 29 | end |
30 | 30 |
|
31 | | -if strfind(computer,'64') |
| 31 | +if contains(computer,'64') |
32 | 32 | bitness = '64'; |
33 | 33 | else |
34 | 34 | bitness = '32'; |
|
40 | 40 | debug = ''; |
41 | 41 | end |
42 | 42 |
|
43 | | -dll_fname = sprintf('liblsl%s%s%s', bitness, debug, ext); |
44 | | -lsl_fname = fullfile(binarypath, dll_fname); |
| 43 | +so_fname = sprintf('liblsl%s%s%s', bitness, debug, ext); |
| 44 | +lsl_fname = fullfile(binarypath, so_fname); |
45 | 45 |
|
46 | | -if ~exist(lsl_fname, 'file') && ~ispc |
47 | | - new_dllpath = fullfile('/usr/lib/', dll_fname); |
48 | | - if exist(new_dllpath, 'file') |
49 | | - lsl_fname = new_dllpath; |
| 46 | +if ~exist(lsl_fname, 'file') |
| 47 | + if ispc |
| 48 | + % On Windows, also try simply 'lsl.dll' |
| 49 | + new_sopath = fullfile(binarypath, 'lsl.dll'); |
| 50 | + else |
| 51 | + new_sopath = fullfile('/usr/lib/', so_fname); |
| 52 | + end |
| 53 | + if exist(new_sopath, 'file') |
| 54 | + lsl_fname = new_sopath; |
50 | 55 | end %if |
51 | 56 | end %if |
52 | 57 |
|
53 | 58 | if ~exist(lsl_fname,'file') |
54 | | - error(['Apparently the file "' dllpath '" is missing on your computer. Cannot load the lab streaming layer.']); |
| 59 | + disp(['Could not locate the file "' so_fname '" on your computer. Attempting to download...']); |
| 60 | + LIBLSL_TAG = 'v1.14.0b1'; |
| 61 | + LIBLSL_VER = '1.14.0'; |
| 62 | + liblsl_url = ['https://github.com/sccn/liblsl/releases/download/' LIBLSL_TAG '/']; |
| 63 | + if ispc |
| 64 | + liblsl_url_fname = ['liblsl-' LIBLSL_VER '-Win' bitness '.zip']; |
| 65 | + elseif ismac |
| 66 | + liblsl_url_fname = ['liblsl-' LIBLSL_VER '-OSX64.tar.bz2']; |
| 67 | + |
| 68 | + elseif isunix |
| 69 | + liblsl_url_fname = ['liblsl-' LIBLSL_VER '-Linux64-bionic.deb']; |
| 70 | + end |
| 71 | + try |
| 72 | + websave(fullfile(binarypath, liblsl_url_fname),... |
| 73 | + [liblsl_url liblsl_url_fname]); |
| 74 | + catch ME |
| 75 | + disp(['Unable to download ' liblsl_url]); |
| 76 | + rethrow(ME); |
| 77 | + end |
| 78 | + if ispc |
| 79 | + unzip(fullfile(binarypath, liblsl_url_fname),... |
| 80 | + fullfile(binarypath, 'liblsl_archive')); |
| 81 | + lsl_fname = fullfile(binarypath, 'lsl.dll'); |
| 82 | + copyfile(fullfile(binarypath, 'liblsl_archive', 'bin', 'lsl.dll'), lsl_fname); |
| 83 | + copyfile(fullfile(binarypath, 'liblsl_archive', 'lib', 'lsl.lib'),... |
| 84 | + fullfile(binarypath, 'lsl.lib')); |
| 85 | + elseif ismac |
| 86 | + untar(fullfile(binarypath, liblsl_url_fname),... |
| 87 | + fullfile(binarypath, 'liblsl_archive')); |
| 88 | + error('TODO: copyfile from liblsl_archive to lsl_fname on mac.'); |
| 89 | + elseif isunix |
| 90 | + error(['Automatic extraction of debian package not yet supported.', ... |
| 91 | + ' Please install manually: ' fullfile(binarypath, liblsl_url_fname)]); |
| 92 | + end |
55 | 93 | end |
56 | 94 |
|
57 | 95 | end |
|
0 commit comments