|
| 1 | +% (C) Copyright 2020 CPP_BIDS developers |
| 2 | + |
| 3 | +function checkCppBidsDependencies(cfg) |
| 4 | + % |
| 5 | + % Adds dependencies to the Matlab / Octave path and make sure we got all of them. |
| 6 | + % |
| 7 | + % USAGE:: |
| 8 | + % |
| 9 | + % checkCppBidsDependencies(cfg) |
| 10 | + % |
| 11 | + % :param cfg: Configuration. See ``checkCFG()``. |
| 12 | + % :type cfg: structure |
| 13 | + |
| 14 | + if nargin < 1 |
| 15 | + cfg.verbose = 2; |
| 16 | + end |
| 17 | + |
| 18 | + global CPP_BIDS_INITIALIZED |
| 19 | + |
| 20 | + if isempty(CPP_BIDS_INITIALIZED) |
| 21 | + |
| 22 | + GITHUB_WORKSPACE = getenv('GITHUB_WORKSPACE'); |
| 23 | + |
| 24 | + if strcmp(GITHUB_WORKSPACE, '/github/workspace') |
| 25 | + |
| 26 | + pth = GITHUB_WORKSPACE; |
| 27 | + addpath(genpath(fullfile(pth, 'lib'))); |
| 28 | + |
| 29 | + elseif isempty(GITHUB_WORKSPACE) % local |
| 30 | + |
| 31 | + pth = fullfile(fileparts(mfilename('fullpath'))); |
| 32 | + |
| 33 | + addpath(pth); |
| 34 | + |
| 35 | + addpath(fullfile(pth, 'lib', 'utils')); |
| 36 | + |
| 37 | + checkSubmodule(fullfile(pth, 'lib', 'JSONio')); |
| 38 | + checkSubmodule(fullfile(pth, 'lib', 'bids-matlab')); |
| 39 | + |
| 40 | + addpath(genpath(fullfile(pth, 'src'))); |
| 41 | + |
| 42 | + end |
| 43 | + |
| 44 | + printCreditsCppBids(cfg); |
| 45 | + |
| 46 | + CPP_BIDS_INITIALIZED = true(); |
| 47 | + |
| 48 | + else |
| 49 | + fprintf(1, '\n\nCPP_BIDS already initialized\n\n'); |
| 50 | + |
| 51 | + end |
| 52 | + |
| 53 | +end |
| 54 | + |
| 55 | +function checkSubmodule(pth) |
| 56 | + % If external dir is empty throw an exception |
| 57 | + % and ask user to update submodules. |
| 58 | + if numel(dir(pth)) <= 2 % Means that the external is empty |
| 59 | + error(['Git submodules are not cloned!', ... |
| 60 | + 'Try this in your terminal:', ... |
| 61 | + ' git submodule update --recursive ']); |
| 62 | + else |
| 63 | + addpath(pth); |
| 64 | + end |
| 65 | +end |
0 commit comments