forked from aleixpinardell/tudat-matlab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.m
70 lines (59 loc) · 1.83 KB
/
build.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
% Build the required targets for the Tudat-MATLAB interface.
% Build options
buildUnitTests = true;
runUnitTests = true;
concurrentJobs = 4;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Do not edit beyond this line %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tudat.load();
builddir = fullfile(fileparts(tudat.bundle),'build-tudatBundle-matlabInterface');
target = 'json_interface';
cmakebin = '';
% Default location on make if not installed to path
if ismac
cmakebin = '/Applications/CMake.app/Contents/bin/cmake';
end
sep = '';
if isunix || ismac
sep = ';';
% Try to get cmake from path (UNIX)
[status, response] = support.systemCommand('which cmake');
if status == 0
cmakebin = strtrim(response);
end
elseif ispc
sep = ' &';
% Try for Windows
[status, response] = support.systemCommand('where cmake');
if status == 0
cmakebin = strtrim(response);
end
end
if exist(cmakebin,'file') ~= 2
cmakebin = input('Specify the absolute path to the cmake binary: ','s');
end
if exist(builddir,'dir') ~= 7
mkdir(builddir);
end
command = [
sprintf('cd "%s"%s ',builddir,sep)...
sprintf('"%s" "%s"%s ',cmakebin,fullfile('..','tudatBundle'),sep)...
sprintf('"%s" --build . --target %s -- -j%i',cmakebin,target,concurrentJobs)
];
if buildUnitTests
testFiles = dir(fullfile(tudat.testsdir,'*.m'));
testNames = {testFiles.name};
for i = 1:length(testNames)
testBinName = strrep(strrep(testNames{i},'.m',''),'unitTest',tudat.testsBinariesPrefix);
command = sprintf('%s%s "%s" --build . --target %s -- -j%i',...
command,sep,cmakebin,testBinName,concurrentJobs);
end
end
status = support.systemCommand(command,'-echo');
if status ~= 0
error('There was a problem during compilation. Try to build the targets manually.');
end
if runUnitTests
tudat.test();
end