|
44 | 44 | % Then check the sister liblsl/build/install/bin folder. |
45 | 45 | % Finally, check other platform-dependent locations. |
46 | 46 | lsl_fname = fullfile(binarypath, so_fname); |
47 | | -if ~exist(lsl_fname, 'file') |
| 47 | +lsl_include_dir = fullfile(binarypath, 'include'); |
| 48 | +if ~exist(lsl_fname, 'file') || ~exist(lsl_include_dir, 'dir') |
48 | 49 | if exist(fullfile(script_dir, '..', 'liblsl', 'build', 'install', 'bin', so_fname), 'file') |
49 | 50 | lsl_fname = fullfile(script_dir, '..', 'liblsl', 'build', 'install', 'bin', so_fname); |
50 | 51 | lsl_include_dir = fullfile(script_dir, '..', 'liblsl', 'build', 'install', 'include'); |
|
59 | 60 | end |
60 | 61 | end %if |
61 | 62 |
|
62 | | -if ~exist(lsl_fname,'file') |
| 63 | +% If liblsl (with headers) could not be found in the default paths, |
| 64 | +% then attempt to download it. On Unix, this will have to be installed |
| 65 | +% manually. On PC and Mac, this will be extracted then cleaned up. |
| 66 | +if ~exist(lsl_fname,'file') || ~exist(lsl_include_dir, 'dir') |
63 | 67 | disp(['Could not locate the file "' so_fname '" on your computer. Attempting to download...']); |
64 | 68 | LIBLSL_TAG = 'v1.14.0'; |
65 | 69 | LIBLSL_VER = '1.14.0'; |
|
98 | 102 | copyfile(fullfile(binarypath, 'liblsl_archive', 'bin', 'lsl.dll'), lsl_fname); |
99 | 103 | copyfile(fullfile(binarypath, 'liblsl_archive', 'lib', 'lsl.lib'),... |
100 | 104 | fullfile(binarypath, 'lsl.lib')); |
101 | | - lsl_include_dir = fullfile(binarypath, 'include'); |
102 | | - copyfile(fullfile(binarypath, 'liblsl_archive', 'include'), lsl_include_dir); |
103 | | - rmdir(fullfile(binarypath, 'liblsl_archive')); |
104 | 105 | elseif ismac |
105 | 106 | % Use system tar because Matlab untar does not preserve symlinks. |
106 | 107 | mkdir(fullfile(binarypath, 'liblsl_archive')); |
|
109 | 110 | dylib_list = dir(fullfile(binarypath, '*.dylib')); |
110 | 111 | [~, lib_ix] = min(cellfun(@length, {dylib_list.name})); |
111 | 112 | lsl_fname = fullfile(dylib_list(lib_ix).folder, dylib_list(lib_ix).name); |
112 | | - lsl_include_dir = fullfile(binarypath, 'include'); |
113 | | - copyfile(fullfile(binarypath, 'liblsl_archive', 'include'), lsl_include_dir); |
114 | | - rmdir(fullfile(binarypath, 'liblsl_archive')); |
115 | 113 | elseif isunix |
116 | 114 | error(['Reattempt build after manual installation of liblsl debian package:', ... |
117 | 115 | ' sudo dpkg -i ' fullfile(binarypath, liblsl_url_fname)]); |
118 | 116 | end |
| 117 | + % Grab include_dir and Cleanup no-longer-needed downloaded files. |
| 118 | + if ispc || ismac |
| 119 | + copyfile(fullfile(binarypath, 'liblsl_archive', 'include'), lsl_include_dir); |
| 120 | + rmdir(fullfile(binarypath, 'liblsl_archive'), 's'); |
| 121 | + delete(fullfile(binarypath, liblsl_url_fname)); |
| 122 | + end |
119 | 123 | end |
0 commit comments