blob: 55d25b093106600fb41a1be4de2816b55f57ef13 [file] [log] [blame]
Willy Tuc710b972021-08-11 16:33:43 -07001project(
George Liu1a2e1502022-07-08 12:20:19 +08002 'phosphor-host-ipmid',
Willy Tuc710b972021-08-11 16:33:43 -07003 'cpp',
4 version: '0.1',
5 meson_version: '>=0.57.0',
6 default_options: [
7 'werror=true',
8 'warning_level=3',
9 'cpp_std=c++20',
10 ])
11
12# Setting up config data
13conf_data = configuration_data()
14
15# The name of the callout's forward association
16conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout')
17conf_data.set_quoted('BOARD_SENSOR', get_option('board-sensor'))
18conf_data.set_quoted('SYSTEM_SENSOR', get_option('system-sensor'))
19
20# Soft Power off related.
21if not get_option('softoff').disabled()
22 conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname'))
23 conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath'))
24 conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs'))
25 conf_data.set('IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS', get_option('ipmi-host-shutdown-complete-timeout-secs'))
26 conf_data.set_quoted('HOST_INBAND_REQUEST_DIR', get_option('host-inband-request-dir'))
27 conf_data.set_quoted('HOST_INBAND_REQUEST_FILE', get_option('host-inband-request-file'))
28endif
29
30conf_data.set_quoted('CONTROL_HOST_BUSNAME', get_option('control-host-busname'))
31conf_data.set_quoted('CONTROL_HOST_OBJ_MGR', get_option('control-host-obj-mgr'))
32conf_data.set_quoted('HOST_NAME', get_option('host-name'))
33conf_data.set_quoted('POWER_READING_SENSOR', get_option('power-reading-sensor'))
34conf_data.set_quoted('HOST_IPMI_LIB_PATH', get_option('host-ipmi-lib-path'))
Potin Lai5d214202023-01-16 18:11:49 +080035conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex'))
Willy Tuc710b972021-08-11 16:33:43 -070036
37conf_h = configure_file(
38 output: 'config.h',
39 configuration: conf_data)
40
41root = meson.current_source_dir()
42root_inc = include_directories('.', 'include')
43
44# Project Arguments
45cpp = meson.get_compiler('cpp')
46add_project_arguments(
47 cpp.get_supported_arguments([
48 '-DBOOST_ERROR_CODE_HEADER_ONLY',
49 '-DBOOST_SYSTEM_NO_DEPRECATED',
50 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
51 '-DBOOST_ASIO_DISABLE_THREADS',
52 '-DBOOST_ALL_NO_LIB',
53 ]),
54 language : 'cpp')
55
Willy Tub78184e2022-10-27 22:57:38 +000056if not get_option('get-dbus-active-software').disabled()
57 add_project_arguments(
58 cpp.get_supported_arguments([
59 '-DGET_DBUS_ACTIVE_SOFTWARE',
60 ]),
61 language : 'cpp')
62endif
63
Willy Tuc710b972021-08-11 16:33:43 -070064feature_map = {
65 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
66 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
67 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
68 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
69 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
70 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
71 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
72 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
73}
74
75foreach option_key, option_value : feature_map
76 if(get_option(option_key).enabled())
77 summary(option_key,option_value, section : 'Enabled Features')
78 add_project_arguments(option_value,language:'cpp')
79 endif
80endforeach
81
82add_project_arguments(
83 cpp.get_supported_arguments([
84 '-flto',
85 '-Wno-psabi',
86 '-Wno-missing-field-initializers',
87 '-Wno-pedantic',
88 '-Wno-non-virtual-dtor'
89 ]),
90 language: 'cpp')
91
92# Dependencies
93phosphor_logging_dep = dependency('phosphor-logging')
94phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
95sdeventplus_dep = dependency('sdeventplus')
96systemd = dependency('systemd')
97crypto = dependency('libcrypto', version : '>=1.0.2g')
98pam = cpp.find_library('pam', required: true)
Patrick Williams6b4cf432022-06-16 11:31:57 -050099mapper = dependency('libmapper')
Willy Tuc710b972021-08-11 16:33:43 -0700100boost_coroutine = cpp.find_library('boost_coroutine', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -0500101sdbusplus_dep = dependency('sdbusplus')
Willy Tuc710b972021-08-11 16:33:43 -0700102
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500103if cpp.has_header_symbol(
104 'nlohmann/json.hpp',
105 'nlohmann::json::string_t',
106 required:false)
107 nlohmann_json_dep = declare_dependency()
108else
109 nlohmann_json_dep = dependency('nlohmann-json')
110endif
111
Patrick Williamsb69b2062022-07-25 09:40:49 -0500112generated_src = []
113
Willy Tuc710b972021-08-11 16:33:43 -0700114# Subfolders
115subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700116subdir('include')
117subdir('user_channel')
118subdir('scripts')
119
120if not get_option('softoff').disabled()
121 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
122 subdir('softoff')
123endif
124
125# whitelist
126if not get_option('ipmi-whitelist').disabled()
127 generate_whitelist_script = files('generate_whitelist_create.sh')
128
129 whitelist_conf = get_option('whitelist-conf')
130 ipmiwhitelist = run_command( \
131 'bash', \
132 generate_whitelist_script, \
133 whitelist_conf)
134
135 whitelist_pre = declare_dependency(
136 include_directories: root_inc,
137 dependencies: [
Willy Tuc710b972021-08-11 16:33:43 -0700138 crypto,
139 ipmid_dep,
140 phosphor_dbus_interfaces_dep,
141 phosphor_logging_dep,
142 sdbusplus_dep,
143 ],
144 )
145
Willy Tuba9bbb62022-06-01 03:41:15 -0700146 whitelist_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700147 'whitelist',
148 'whitelist-filter.cpp',
149 'ipmiwhitelist.cpp',
150 implicit_include_directories: false,
151 dependencies: whitelist_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700152 version: meson.project_version(),
153 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700154 install: true,
155 install_dir: get_option('libdir') / 'ipmid-providers')
156endif
157
Willy Tuc710b972021-08-11 16:33:43 -0700158# libsysintfcmds
159sysintfcmds_pre = declare_dependency(
160 include_directories: root_inc,
161 dependencies: [
162 channellayer_dep,
163 crypto,
164 mapper,
165 phosphor_dbus_interfaces_dep,
166 phosphor_logging_dep,
167 sdbusplus_dep,
168 ipmid_dep,
169 ])
170
Willy Tuba9bbb62022-06-01 03:41:15 -0700171sysintfcmds_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700172 'sysintfcmds',
173 'systemintfcmds.cpp',
174 'host-interface.cpp',
175 implicit_include_directories: false,
176 dependencies: sysintfcmds_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700177 version: meson.project_version(),
178 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700179 install: true,
180 install_dir: get_option('libdir') / 'ipmid-providers')
181
Willy Tuc710b972021-08-11 16:33:43 -0700182# ipmid
183ipmid_pre = [
184 sdbusplus_dep,
185 phosphor_logging_dep,
186 phosphor_dbus_interfaces_dep,
187 boost_coroutine,
188 crypto,
189 ipmid_dep,
190 channellayer_dep,
191 mapper,
Willy Tuc710b972021-08-11 16:33:43 -0700192]
193
Willy Tuc710b972021-08-11 16:33:43 -0700194transportoem_src = []
195if not get_option('transport-oem').disabled()
196 transportoem_src = ['transporthandler_oem.cpp']
197endif
198
199entity_map_json_lib = static_library(
200 'entity_map_json',
201 'entity_map_json.cpp',
202 include_directories: root_inc,
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500203 dependencies: [ipmid_dep, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700204 implicit_include_directories: false)
205
206entity_map_json_dep = declare_dependency(link_with: entity_map_json_lib)
207
208libipmi20_src = [
209 'app/channel.cpp',
210 'app/watchdog.cpp',
211 'app/watchdog_service.cpp',
212 'apphandler.cpp',
213 'sys_info_param.cpp',
214 'sensorhandler.cpp',
215 'storagehandler.cpp',
216 'chassishandler.cpp',
217 'dcmihandler.cpp',
218 'ipmisensor.cpp',
219 'storageaddsel.cpp',
220 'transporthandler.cpp',
221 'globalhandler.cpp',
222 'groupext.cpp',
223 'selutility.cpp',
224 'ipmi_fru_info_area.cpp',
225 'read_fru_data.cpp',
226 'sensordatahandler.cpp',
Jian Zhangff1b4bf2022-06-28 16:08:26 +0800227 'user_channel/channelcommands.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700228 generated_src,
229 transportoem_src,
230 conf_h,
231]
232
233ipmi20_lib = library(
234 'ipmi20',
235 libipmi20_src,
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500236 dependencies: [ipmid_pre, entity_map_json_dep, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700237 include_directories: root_inc,
238 install: true,
239 install_dir: get_option('libdir') / 'ipmid-providers',
Willy Tuba9bbb62022-06-01 03:41:15 -0700240 version: meson.project_version(),
Willy Tuc710b972021-08-11 16:33:43 -0700241 override_options: ['b_lundef=false'])
242
243libipmi20_dep = declare_dependency(
244 dependencies: ipmid_pre,
245 include_directories: root_inc,
246 link_with: ipmi20_lib)
247
248# ipmid binary
249executable(
250 'ipmid',
251 'ipmid-new.cpp',
252 'host-cmd-manager.cpp',
253 'settings.cpp',
254 implicit_include_directories: false,
255 dependencies: [libipmi20_dep],
256 include_directories: root_inc,
257 export_dynamic: true,
258 install: true,
259 install_dir: get_option('bindir'))
260
261# Dynamic Sensor Stack
262subdir('dbus-sdr')
263
Willy Tu0679e4b2022-11-11 14:34:33 -0800264if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled()
Willy Tu6eab4202022-06-09 11:34:52 -0700265 library(
266 'dynamiccmds',
267 dbus_sdr_src,
268 implicit_include_directories: false,
269 dependencies: dbus_sdr_pre,
270 version: meson.project_version(),
271 override_options: ['b_lundef=false'],
272 install: true,
273 install_dir: get_option('libdir') / 'ipmid-providers')
274endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700275
Willy Tuc710b972021-08-11 16:33:43 -0700276if not get_option('tests').disabled()
277 subdir('test')
278endif
279
280install_subdir(
281 'user_channel',
282 install_dir: get_option('includedir'),
283 strip_directory: false,
284 exclude_files: '*.cpp')