-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkCppBidsDependencies.m
65 lines (45 loc) · 1.54 KB
/
checkCppBidsDependencies.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
65
% (C) Copyright 2020 CPP_BIDS developers
function checkCppBidsDependencies(cfg)
%
% Adds dependencies to the Matlab / Octave path and make sure we got all of them.
%
% USAGE::
%
% checkCppBidsDependencies(cfg)
%
% :param cfg: Configuration. See ``checkCFG()``.
% :type cfg: structure
if nargin < 1
cfg.verbose = 2;
end
global CPP_BIDS_INITIALIZED
if isempty(CPP_BIDS_INITIALIZED)
GITHUB_WORKSPACE = getenv('GITHUB_WORKSPACE');
if strcmp(GITHUB_WORKSPACE, '/github/workspace')
pth = GITHUB_WORKSPACE;
addpath(genpath(fullfile(pth, 'lib')));
elseif isempty(GITHUB_WORKSPACE) % local
pth = fullfile(fileparts(mfilename('fullpath')));
addpath(pth);
addpath(fullfile(pth, 'lib', 'utils'));
checkSubmodule(fullfile(pth, 'lib', 'JSONio'));
checkSubmodule(fullfile(pth, 'lib', 'bids-matlab'));
addpath(genpath(fullfile(pth, 'src')));
end
printCreditsCppBids(cfg);
CPP_BIDS_INITIALIZED = true();
else
fprintf(1, '\n\nCPP_BIDS already initialized\n\n');
end
end
function checkSubmodule(pth)
% If external dir is empty throw an exception
% and ask user to update submodules.
if numel(dir(pth)) <= 2 % Means that the external is empty
error(['Git submodules are not cloned!', ...
'Try this in your terminal:', ...
' git submodule update --recursive ']);
else
addpath(pth);
end
end