-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_matlab.m
50 lines (50 loc) · 1.68 KB
/
build_matlab.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
function build_matlab(action)
path = pwd;
bin_path = fullfile(path, 'bin');
build_path = fullfile(path, 'build');
% add current folder to search path for include
IFLAG = '-I.';
if nargin > 0 && action == "clean"
delete("build/*.o");
delete("bin/*.mex*");
disp("Done clean.");
elseif nargin > 0 && action == "mex"
% cpp files for mex
cpp_files = dir('mex/**/*.cpp');
% object files from source
obj_files = fullfile('build', {dir('build/*.o').name});
% build mex files
for i = 1:length(cpp_files)
src_file = fullfile(cpp_files(i).folder, cpp_files(i).name);
mex('-v', '-O', '-largeArrayDims', IFLAG, '-outdir', bin_path, src_file, obj_files{:});
end
addpath(bin_path);
disp("Done build.")
elseif nargin > 0 && action == "obj"
%% build objective files
src_files = dir('src/**/*.cpp');
for i = 1:length(src_files)
src_file = fullfile(src_files(i).folder, src_files(i).name);
mex('-c', IFLAG, '-outdir', build_path, src_file);
end
else
%% build objective files
src_files = dir('src/**/*.cpp');
for i = 1:length(src_files)
src_file = fullfile(src_files(i).folder, src_files(i).name);
mex('-c', IFLAG, '-outdir', build_path, src_file);
end
%% build mex files
% cpp files for mex
cpp_files = dir('mex/**/*.cpp');
% object files from source
obj_files = fullfile('build', {dir('build/*.o').name});
% build mex files
for i = 1:length(cpp_files)
src_file = fullfile(cpp_files(i).folder, cpp_files(i).name);
mex('-v', '-O', '-largeArrayDims', IFLAG, '-outdir', bin_path, src_file, obj_files{:});
end
addpath(bin_path);
disp("Done build.")
end
end