-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrtbCheckNativeDependencies.m
More file actions
100 lines (81 loc) · 3.07 KB
/
Copy pathrtbCheckNativeDependencies.m
File metadata and controls
100 lines (81 loc) · 3.07 KB
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
function [status, result, advice] = rtbCheckNativeDependencies()
% Check whether required native dependencies are installed.
%
% [status, result, advice] = rtbCheckNativeDependencies() checks the local
% system for native dependencies, like renderers and shared libraries.
% Returns a status code which is non-zero if some dependency was missing.
% Also returns a result, such as an error code about the missing
% dependency. Finally, returns a string with advice about how to obtain
% a missing dependency, if any.
%
% [status, result, advice] = rtbCheckNativeDependencies()
%
%%% RenderToolbox4 Copyright (c) 2012-2017 The RenderToolbox Team.
%%% About Us://github.com/RenderToolbox/RenderToolbox4/wiki/About-Us
%%% RenderToolbox4 is released under the MIT License. See LICENSE file.
%% Check for OpenEXR library, also known as IlmImf.
if ismac()
% assume homebrew
findLibCommand = 'brew list | grep openexr';
else
findLibCommand = 'ldconfig -p | grep libIlmImf';
end
openExr = checkSystem('OpenEXR', ...
findLibCommand, ...
'It looks like the OpenEXR library is not installed. Please visit http://www.openexr.com/. You might also try "sudo apt-get install openexr" or similar.');
%% OpenEXR is required.
if 0 ~= openExr.status
status = openExr.status;
result = openExr.result;
advice = openExr.advice;
return;
end
%% Check for Docker, the preferred way to obtain renderers.
docker = checkSystem('Docker', ...
'docker ps', ...
'It looks like Docker is not installed. Please visit https://github.com/RenderToolbox/RenderToolbox4/wiki/Docker.');
%% Docker can cover both renderers.
if 0 == docker.status
status = 0;
result = 'Local dependencies were found.';
advice = '';
return;
end
%% Check for a local installation of the Mitsuba renderer.
mitsuba = checkSystem('Mitsuba', ...
'which mitsuba', ...
'It looks like Mitsuba is not installed. Please visit https://www.mitsuba-renderer.org/. Or, consider installing Docker so that RenderToolbox can get Mitsuba for you.');
%% Check for a local installation of the PBRT renderer.
pbrt = checkSystem('PBRT', ...
'which pbrt', ...
'It looks like PBRT is not installed. Please visit https://github.com/scienstanford/pbrt-v2-spectral. Or, consider installing Docker so that RenderToolbox can get PBRT for you.');
%% Check for both renderers.
if 0 ~= mitsuba.status
status = mitsuba.status;
result = mitsuba.result;
advice = mitsuba.advice;
return;
end
if 0 ~= pbrt.status
status = pbrt.status;
result = pbrt.result;
advice = pbrt.advice;
return;
end
%% Looks good from here.
status = 0;
result = 'Local dependencies were found.';
advice = '';
%% Check whether something exists and print messages.
function info = checkSystem(name, command, advice)
fprintf('Checking for %s:\n', name);
fprintf(' %s\n', command);
info.name = name;
info.advice = advice;
[info.status, result] = system(command);
info.result = strtrim(result);
if 0 == info.status
fprintf(' OK.\n');
else
fprintf(' Not found. Status %d, result <%s>.\n', info.status, info.result);
end