-
Notifications
You must be signed in to change notification settings - Fork 1
/
startup.m
71 lines (50 loc) · 1.69 KB
/
startup.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
66
67
68
69
70
71
function startup ()
% Locate project root
root = fileparts (mfilename ('fullpath'));
% Add directories to the path
addpath (fullfile (root, 'testcases', 'volcano-case'));
addpath (fullfile (root, 'testcases', 'matlab'));
addpath (fullfile (root, 'misc'));
addpath (genpath (fullfile (root, 'scripts')));
% Download contrib-qsi (if needed)
contrib_qsi = fullfile (root, 'algorithms', 'stk-contrib-qsi');
if ~ exist (contrib_qsi, 'dir')
git_clone_dependency ('contrib-qsi', contrib_qsi, ...
'https://github.com/stk-kriging/contrib-qsi.git', 'qsi-paper-experiments');
end
% Add contrib-qsi to the path
% (this step also clones & initializes STK 2.8.1 if needed)
run (fullfile (contrib_qsi, 'startup.m'));
end % function
function git_clone_dependency (name, dst, url, sha1_or_tag)
if exist (dst, 'dir')
error (sprintf ('Directory already exists: %s\n', dst)); %#ok<SPERR>
end
fprintf ('Cloning %s... ', name);
try
gitcmd = sprintf ('git clone %s %s', url, dst);
evalc (sprintf ('[status, output] = system (''%s'')', gitcmd));
if status ~= 0
error ([ ...
'git-clone failed with the following ' ...
'error message:\n\n%s\n\n'], output);
end
here = pwd (); cd (dst);
gitcmd = sprintf ('git checkout %s', sha1_or_tag);
evalc (sprintf ('[status, output] = system (''%s'')', gitcmd));
if status ~= 0
error ([ ...
'git-checkout failed with the following ' ...
'error message:\n\n%s\n\n'], output);
end
cd (here);
catch e
cd (here);
% Remove partial/failed install
if exist (dst, 'dir')
rmdir (dst, 's');
end
rethrow (e);
end % try-catch
fprintf ('OK\n');
end % function