-
Notifications
You must be signed in to change notification settings - Fork 12
/
meson.build
216 lines (183 loc) · 6.49 KB
/
meson.build
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
project(
'phosphor-fan-presence',
'cpp',
default_options: [
'warning_level=3',
'werror=true',
'cpp_std=c++23',
'buildtype=debugoptimized',
'prefix=/usr'
],
license: 'Apache-2.0',
version: '1.0',
meson_version: '>=1.1.1',
)
python_prog = find_program('python3', native: true)
cpp = meson.get_compiler('cpp')
cli11_dep = dependency('cli11', required: false)
if not cpp.has_header_symbol(
'CLI/CLI.hpp',
'CLI::App',
dependencies: cli11_dep,
required: false)
cli11_proj = subproject('cli11', required:false)
assert(cli11_proj.found(), 'CLI11 is required')
cli11_dep = cli11_proj.get_variable('CLI11_dep')
endif
cereal_dep = dependency('cereal', required: false)
has_cereal = cpp.has_header_symbol(
'cereal/cereal.hpp',
'cereal::specialize',
dependencies: cereal_dep,
required: false)
if not has_cereal
cereal_opts = import('cmake').subproject_options()
cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
cereal_proj = import('cmake').subproject(
'cereal',
options: cereal_opts,
required: false)
assert(cereal_proj.found(), 'cereal is required')
cereal_dep = cereal_proj.dependency('cereal')
endif
nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
phosphor_logging_dep = dependency('phosphor-logging')
sdbusplus_dep = dependency('sdbusplus')
sdeventplus_dep = dependency('sdeventplus')
stdplus_dep = dependency('stdplus')
systemd_dep = dependency('systemd')
if(get_option('tests').allowed())
gmock_dep = dependency('gmock', disabler: true, required: false)
gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
if not gtest_dep.found() or not gmock_dep.found()
gtest_proj = import('cmake').subproject('googletest', required: false)
if gtest_proj.found()
gtest_dep = declare_dependency(
dependencies: [
dependency('threads'),
gtest_proj.dependency('gtest'),
gtest_proj.dependency('gtest_main'),
]
)
gmock_dep = gtest_proj.dependency('gmock')
else
assert(
not get_option('tests').allowed(),
'Googletest is required if tests are enabled'
)
endif
endif
subdir('test')
endif
servicedir = systemd_dep.get_variable('systemdsystemunitdir')
usr_share_dir = '/usr/share/phosphor-fan-presence'
conf = configuration_data()
# Control
conf.set_quoted(
'CONTROL_PERSIST_ROOT_PATH', get_option('control-persist-root-path'))
conf.set_quoted(
'CONTROL_PERSIST_ROOT_PATH', get_option('control-persist-root-path'))
conf.set_quoted(
'FAN_DEF_YAML_FILE', get_option('fan-def-yaml-file'))
conf.set_quoted(
'FAN_ZONE_YAML_FILE', get_option('fan-zone-yaml-file'))
conf.set_quoted(
'ZONE_EVENTS_YAML_FILE', get_option('zone-events-yaml-file'))
conf.set_quoted(
'ZONE_CONDITIONS_YAML_FILE', get_option('zone-conditions-yaml-file'))
# Fan control can be in YAML mode when everything else is in JSON mode
control_conf_type = 'yaml'
if get_option('json-config').allowed() and get_option('json-control').allowed()
control_conf_type = 'json'
endif
# Monitor
conf.set(
'NUM_MONITOR_LOG_ENTRIES', get_option('num-monitor-log-entries'))
conf.set_quoted(
'FAN_MONITOR_YAML_FILE', get_option('fan-monitor-yaml-file'))
conf.set('DELAY_HOST_CONTROL', get_option('delay-host-control'))
if get_option('monitor-use-host-state').allowed()
conf.set('MONITOR_USE_HOST_STATE', '')
endif
# JSON-or-YAML (all programs)
if get_option('json-config').allowed()
conf.set('PRESENCE_USE_JSON', '')
if control_conf_type == 'json'
conf.set('CONTROL_USE_JSON', '')
endif
conf.set('MONITOR_USE_JSON', '')
conf_type = 'json'
else
conf_type = 'yaml'
endif
# Sensor Monitor
conf.set_quoted('SENSOR_MONITOR_PERSIST_ROOT_PATH',
get_option('sensor-monitor-persist-root-path'))
if get_option('use-host-power-state').allowed()
conf.set('ENABLE_HOST_STATE', '')
endif
if get_option('skip-power-checking').allowed()
conf.set('SKIP_POWER_CHECKING', '')
endif
conf.set(
'SHUTDOWN_ALARM_HARD_SHUTDOWN_DELAY_MS', get_option('sensor-monitor-hard-shutdown-delay'))
conf.set(
'SHUTDOWN_ALARM_SOFT_SHUTDOWN_DELAY_MS', get_option('sensor-monitor-soft-shutdown-delay'))
# Presence
conf.set(
'NUM_PRESENCE_LOG_ENTRIES', get_option('num-presence-log-entries'))
conf.set_quoted(
'PRESENCE_YAML_FILE', get_option('presence-config'))
configure_file(output: 'config.h', configuration: conf)
# Service: [name,[svcfiles]]
services = []
if get_option('control-service').allowed()
subdir('control')
service_files = ['[email protected]']
if control_conf_type == 'yaml'
service_files += '[email protected]'
endif
services += [['control', service_files]]
endif
if get_option('monitor-service').allowed()
subdir('monitor')
service_files = ['[email protected]']
if not get_option('json-config').allowed()
service_files += '[email protected]'
endif
services += [['monitor', service_files]]
endif
if get_option('cooling-type-service').allowed()
libevdev_dep = dependency('libevdev')
subdir('cooling-type')
endif
if get_option('presence-service').allowed()
libevdev_dep = dependency('libevdev')
subdir('presence')
services += [['presence', ['[email protected]']]]
endif
if get_option('sensor-monitor-service').allowed()
subdir('sensor-monitor')
install_data('sensor-monitor/service_files/sensor-monitor.service',
install_dir: servicedir)
endif
foreach service : services
this_conf_type = conf_type
if service[0] == 'control'
this_conf_type = control_conf_type
endif
foreach service_file : service[1]
install_data(service[0] / 'service_files' / this_conf_type / service_file,
install_dir: servicedir)
endforeach
if this_conf_type == 'json'
fs = import('fs')
dir = meson.current_source_dir() / service[0] / 'config_files' / get_option('machine-name')
if fs.is_dir(dir)
install_subdir(service[0] / 'config_files' / get_option('machine-name'),
install_dir: usr_share_dir / service[0],
strip_directory: true)
endif
endif
endforeach