-
Notifications
You must be signed in to change notification settings - Fork 20
/
InstallBreach.m
171 lines (140 loc) · 6.07 KB
/
InstallBreach.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
function InstallBreach(varargin)
%INSTALLBREACH compiles C/C++ mex functions used by Breach. Needs only to
% be called once after an update of Breach
InitBreach
global BreachGlobOpt;
options.verbose = 0;
options.linear_interp = 0;
options = varargin2struct_breach(options, varargin{:});
if options.verbose ==0
silent = 1;
end
if options.linear_interp ==0
BreachGlobOpt.disable_robust_linear_interpolation=1;
else
BreachGlobOpt.disable_robust_linear_interpolation=0;
end
% Johan fix
silent = 0;
MEX = 'mex ';
FLAGS = ' ';
if silent
FLAGS = [FLAGS ' -silent '];
end
cdr = pwd;
dr = which('InstallBreach');
% setup directories of interest
breach_dir = dr(1:end-16);
breach_src_dir = [breach_dir filesep 'Core' filesep 'src'];
stl_src_dir = [breach_dir filesep '@STL_Formula' filesep 'private' filesep 'src'];
% compile STL mex functions
fprintf('\nCompiling legacy STL monitoring functions...\n')
cd(stl_src_dir);
legacy_functions = { ' lemire_engine.c', ...
' lemire_nd_engine.c', ...
' lemire_nd_maxengine.c', ...
' lemire_nd_minengine.c', ...
' until_inf.c', ...
' lim_inf.c', ...
' lim_inf_inv.c', ...
' lim_inf_indx.c', ...
};
for ilf = 1:numel(legacy_functions)
cmd = [MEX FLAGS '-outdir ..' legacy_functions{ilf}];
eval(cmd);
end
legacy_functions_time_robustness= {
' ltr.c',...
' rtr.c',...
};
for ilf = 1:numel(legacy_functions_time_robustness)
cmd = [MEX FLAGS '-outdir ../../../Core/m_src ' legacy_functions_time_robustness{ilf}];
eval(cmd)
end
cd robusthom;
fprintf('Compiling offline STL monitoring functions...\n')
CompileRobusthom;
% compiles cvodes common stuff
sundials_dir = [breach_dir filesep 'Ext' filesep 'Toolboxes' filesep 'sundials'];
sundials_inc_dir = [sundials_dir filesep 'include'];
sundials_src_dir = [sundials_dir filesep 'src' filesep 'sundials'];
sundials_cvodes_src_dir = [sundials_dir filesep 'src' filesep 'cvodes'];
sundials_nvm_src_dir = [sundials_dir filesep 'sundialsTB' filesep 'nvector' filesep 'src'];
cvodesTB_src_dir = [breach_dir filesep 'Core' filesep 'cvodesTB++' filesep 'src'];
sundials_inc_flags = [' -I' qwrap(breach_src_dir) ...
' -I' qwrap(sundials_inc_dir) ...
' -I' qwrap(sundials_cvodes_src_dir) ...
' -I' qwrap(cvodesTB_src_dir) ...
' -I' qwrap(sundials_nvm_src_dir) ...
];
sundials_src_files = [
qwrap([sundials_nvm_src_dir filesep 'nvm_serial.c']) ...
qwrap([sundials_nvm_src_dir filesep 'nvm_ops.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_band.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_bandpre.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_bbdpre.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_dense.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_diag.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodea.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_io.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodea_io.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_spils.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_spbcgs.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_spgmr.c']) ...
qwrap([sundials_cvodes_src_dir filesep 'cvodes_sptfqmr.c']) ...
qwrap([sundials_src_dir filesep 'sundials_band.c']) ...
qwrap([sundials_src_dir filesep 'sundials_dense.c']) ...
qwrap([sundials_src_dir filesep 'sundials_iterative.c']) ...
qwrap([sundials_src_dir filesep 'sundials_nvector.c']) ...
qwrap([sundials_src_dir filesep 'sundials_smalldense.c']) ...
qwrap([sundials_src_dir filesep 'sundials_spbcgs.c']) ...
qwrap([sundials_src_dir filesep 'sundials_spgmr.c']) ...
qwrap([sundials_src_dir filesep 'sundials_sptfqmr.c']) ...
qwrap([sundials_src_dir filesep 'sundials_math.c']) ...
qwrap([sundials_dir filesep 'src' filesep 'nvec_ser' filesep 'nvector_serial.c' ])...
];
out_dir = qwrap([breach_src_dir filesep 'cv_obj']);
% Compose and execute compilation command for CVodes common files.
compile_cvodes = [MEX FLAGS '-c -outdir ' out_dir ' ' sundials_inc_flags ' ' sundials_src_files ];
%fprintf(regexprep(compile_cvodes,'\','\\\\'));
fprintf('Compiling some more legacy functions...\n');
eval(compile_cvodes);
% Compile blitz library
blitz_dir = [breach_dir filesep 'Ext' filesep 'Toolboxes' filesep 'blitz'];
cd(blitz_dir);
try
CompileBlitzLib;
end
fprintf('Compiling online monitoring functions...\n')
try
compile_stl_mex
catch
fprintf(['FAILED: try to run the script compile_stl_mex to get ' ...
'error information. If you are using Mingw, note ' ...
'that it is not supported yet. Try installing Visual ' ...
'C++. Note that this error only affects online monitoring.' ...
'Most Breach features will work nonetheless.']);
addpath(breach_dir);
savepath;
% cd back and clean variable
cd(cdr);
fprintf('\n');
disp('-------------------------------------------------------------------');
disp('- Install mostly successful. --')
disp('-------------------------------------------------------------------');
return;
end
addpath(breach_dir);
savepath;
% cd back and clean variable
cd(cdr);
fprintf('\n');
disp('-------------------------------------------------------------------');
disp('- Install successful. --')
disp('-------------------------------------------------------------------');
end
function qst = qwrap(st)
% necessary for dealing with £¨% spaces in dirnames...
qst = ['''' st ''' '];
end