-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmake.m
44 lines (36 loc) · 1.21 KB
/
make.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
function make(rebuild)
if nargin < 1
rebuild = false;
end
filePath = mfilename('fullpath');
projectDir = fileparts(filePath);
currentDir = pwd;
returnToDir = onCleanup(@()cd(currentDir));
cd(projectDir);
opts = '';
opts = [opts ' -I"' fullfile(projectDir, 'api') '"'];
opts = [opts ' -L"' fullfile(projectDir) '" -llcr'];
if ismac
opts = [opts ' LDFLAGS="\$LDFLAGS -Xlinker -rpath -Xlinker ."'];
opts = [opts ' CXXFLAGS="\$CXXFLAGS -std=c++11"'];
end
sourceFiles = dir(fullfile(projectDir, '*.cpp'));
for i = 1:length(sourceFiles)
source = sourceFiles(i);
[~, name] = fileparts(source.name);
mexname = [name '.' mexext];
mexfile = dir(mexname);
if rebuild || isempty(mexfile) || datenum(source.date) > datenum(mexfile.date)
command = sprintf('mex %s %s', opts, source.name);
disp(command);
try
eval(command);
catch x
disp(['Error compiling ''' source.name '''']);
disp(x.message);
end
else
disp([source.name ' is up to date']);
end
end
end