blob: 1fd2b6beab284cad63e8215ac36189aef1184625 [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',
Patrick Williams6fb31492023-07-12 11:15:11 -05005 meson_version: '>=1.1.1',
Willy Tuc710b972021-08-11 16:33:43 -07006 default_options: [
7 'werror=true',
8 'warning_level=3',
Patrick Williams6fb31492023-07-12 11:15:11 -05009 'cpp_std=c++23',
Willy Tuc710b972021-08-11 16:33:43 -070010 ])
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'))
Lei YU127a24b2023-06-27 17:45:53 +080019conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs'))
Willy Tuc710b972021-08-11 16:33:43 -070020
21# Soft Power off related.
22if not get_option('softoff').disabled()
23 conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname'))
24 conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath'))
Willy Tuc710b972021-08-11 16:33:43 -070025 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
Potin Laic7c55922023-02-16 10:33:55 +080037matches_map = get_option('matches-map')
38conf_data.set('MAJOR_MATCH_INDEX', matches_map[0])
39conf_data.set('MINOR_MATCH_INDEX', matches_map[1])
40conf_data.set('AUX_0_MATCH_INDEX', matches_map[2])
41conf_data.set('AUX_1_MATCH_INDEX', matches_map[3])
42conf_data.set('AUX_2_MATCH_INDEX', matches_map[4])
43conf_data.set('AUX_3_MATCH_INDEX', matches_map[5])
44
Willy Tuc710b972021-08-11 16:33:43 -070045conf_h = configure_file(
46 output: 'config.h',
47 configuration: conf_data)
48
49root = meson.current_source_dir()
50root_inc = include_directories('.', 'include')
51
52# Project Arguments
53cpp = meson.get_compiler('cpp')
54add_project_arguments(
55 cpp.get_supported_arguments([
56 '-DBOOST_ERROR_CODE_HEADER_ONLY',
57 '-DBOOST_SYSTEM_NO_DEPRECATED',
58 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
59 '-DBOOST_ASIO_DISABLE_THREADS',
60 '-DBOOST_ALL_NO_LIB',
61 ]),
62 language : 'cpp')
63
Willy Tub78184e2022-10-27 22:57:38 +000064if not get_option('get-dbus-active-software').disabled()
65 add_project_arguments(
66 cpp.get_supported_arguments([
67 '-DGET_DBUS_ACTIVE_SOFTWARE',
68 ]),
69 language : 'cpp')
70endif
71
Willy Tuc710b972021-08-11 16:33:43 -070072feature_map = {
73 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
74 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
75 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
76 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
77 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
Johnathan Mantey23a722c2023-05-12 08:18:54 -070078 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS',
Willy Tuc710b972021-08-11 16:33:43 -070079 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
80 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
81 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
82}
83
84foreach option_key, option_value : feature_map
85 if(get_option(option_key).enabled())
86 summary(option_key,option_value, section : 'Enabled Features')
87 add_project_arguments(option_value,language:'cpp')
88 endif
89endforeach
90
91add_project_arguments(
92 cpp.get_supported_arguments([
Willy Tuc710b972021-08-11 16:33:43 -070093 '-Wno-psabi',
94 '-Wno-missing-field-initializers',
95 '-Wno-pedantic',
96 '-Wno-non-virtual-dtor'
97 ]),
98 language: 'cpp')
99
100# Dependencies
101phosphor_logging_dep = dependency('phosphor-logging')
102phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
103sdeventplus_dep = dependency('sdeventplus')
104systemd = dependency('systemd')
105crypto = dependency('libcrypto', version : '>=1.0.2g')
106pam = cpp.find_library('pam', required: true)
Patrick Williams6b4cf432022-06-16 11:31:57 -0500107mapper = dependency('libmapper')
Willy Tuc710b972021-08-11 16:33:43 -0700108boost_coroutine = cpp.find_library('boost_coroutine', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -0500109sdbusplus_dep = dependency('sdbusplus')
Willy Tuc710b972021-08-11 16:33:43 -0700110
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500111if cpp.has_header_symbol(
112 'nlohmann/json.hpp',
113 'nlohmann::json::string_t',
114 required:false)
115 nlohmann_json_dep = declare_dependency()
116else
117 nlohmann_json_dep = dependency('nlohmann-json')
118endif
119
Patrick Williamsb69b2062022-07-25 09:40:49 -0500120generated_src = []
121
Willy Tuc710b972021-08-11 16:33:43 -0700122# Subfolders
123subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700124subdir('include')
125subdir('user_channel')
126subdir('scripts')
127
128if not get_option('softoff').disabled()
129 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
130 subdir('softoff')
131endif
132
133# whitelist
134if not get_option('ipmi-whitelist').disabled()
135 generate_whitelist_script = files('generate_whitelist_create.sh')
136
137 whitelist_conf = get_option('whitelist-conf')
138 ipmiwhitelist = run_command( \
139 'bash', \
140 generate_whitelist_script, \
141 whitelist_conf)
142
143 whitelist_pre = declare_dependency(
144 include_directories: root_inc,
145 dependencies: [
Willy Tuc710b972021-08-11 16:33:43 -0700146 crypto,
147 ipmid_dep,
148 phosphor_dbus_interfaces_dep,
149 phosphor_logging_dep,
150 sdbusplus_dep,
151 ],
152 )
153
Willy Tuba9bbb62022-06-01 03:41:15 -0700154 whitelist_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700155 'whitelist',
156 'whitelist-filter.cpp',
157 'ipmiwhitelist.cpp',
158 implicit_include_directories: false,
159 dependencies: whitelist_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700160 version: meson.project_version(),
161 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700162 install: true,
163 install_dir: get_option('libdir') / 'ipmid-providers')
164endif
165
Willy Tuc710b972021-08-11 16:33:43 -0700166# libsysintfcmds
167sysintfcmds_pre = declare_dependency(
168 include_directories: root_inc,
169 dependencies: [
170 channellayer_dep,
171 crypto,
172 mapper,
173 phosphor_dbus_interfaces_dep,
174 phosphor_logging_dep,
175 sdbusplus_dep,
176 ipmid_dep,
177 ])
178
Willy Tuba9bbb62022-06-01 03:41:15 -0700179sysintfcmds_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700180 'sysintfcmds',
181 'systemintfcmds.cpp',
182 'host-interface.cpp',
183 implicit_include_directories: false,
184 dependencies: sysintfcmds_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700185 version: meson.project_version(),
186 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700187 install: true,
188 install_dir: get_option('libdir') / 'ipmid-providers')
189
Willy Tuc710b972021-08-11 16:33:43 -0700190# ipmid
191ipmid_pre = [
192 sdbusplus_dep,
193 phosphor_logging_dep,
194 phosphor_dbus_interfaces_dep,
195 boost_coroutine,
196 crypto,
197 ipmid_dep,
198 channellayer_dep,
199 mapper,
Willy Tuc710b972021-08-11 16:33:43 -0700200]
201
Willy Tuc710b972021-08-11 16:33:43 -0700202transportoem_src = []
203if not get_option('transport-oem').disabled()
204 transportoem_src = ['transporthandler_oem.cpp']
205endif
206
Willy Tuc710b972021-08-11 16:33:43 -0700207libipmi20_src = [
208 'app/channel.cpp',
209 'app/watchdog.cpp',
210 'app/watchdog_service.cpp',
211 'apphandler.cpp',
212 'sys_info_param.cpp',
213 'sensorhandler.cpp',
214 'storagehandler.cpp',
215 'chassishandler.cpp',
216 'dcmihandler.cpp',
217 'ipmisensor.cpp',
218 'storageaddsel.cpp',
219 'transporthandler.cpp',
220 'globalhandler.cpp',
221 'groupext.cpp',
222 'selutility.cpp',
223 'ipmi_fru_info_area.cpp',
224 'read_fru_data.cpp',
225 'sensordatahandler.cpp',
Jian Zhangff1b4bf2022-06-28 16:08:26 +0800226 'user_channel/channelcommands.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700227 generated_src,
228 transportoem_src,
229 conf_h,
230]
231
232ipmi20_lib = library(
233 'ipmi20',
234 libipmi20_src,
Vernon Mauery9cf08382023-04-28 14:00:11 -0700235 dependencies: [ipmid_pre, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700236 include_directories: root_inc,
237 install: true,
238 install_dir: get_option('libdir') / 'ipmid-providers',
Willy Tuba9bbb62022-06-01 03:41:15 -0700239 version: meson.project_version(),
Willy Tuc710b972021-08-11 16:33:43 -0700240 override_options: ['b_lundef=false'])
241
242libipmi20_dep = declare_dependency(
243 dependencies: ipmid_pre,
244 include_directories: root_inc,
245 link_with: ipmi20_lib)
246
247# ipmid binary
248executable(
249 'ipmid',
250 'ipmid-new.cpp',
251 'host-cmd-manager.cpp',
252 'settings.cpp',
253 implicit_include_directories: false,
254 dependencies: [libipmi20_dep],
255 include_directories: root_inc,
256 export_dynamic: true,
257 install: true,
258 install_dir: get_option('bindir'))
259
260# Dynamic Sensor Stack
261subdir('dbus-sdr')
262
Willy Tu0679e4b2022-11-11 14:34:33 -0800263if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled()
Willy Tu6eab4202022-06-09 11:34:52 -0700264 library(
265 'dynamiccmds',
266 dbus_sdr_src,
267 implicit_include_directories: false,
268 dependencies: dbus_sdr_pre,
269 version: meson.project_version(),
270 override_options: ['b_lundef=false'],
271 install: true,
272 install_dir: get_option('libdir') / 'ipmid-providers')
273endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700274
Willy Tuc710b972021-08-11 16:33:43 -0700275if not get_option('tests').disabled()
276 subdir('test')
277endif
278
279install_subdir(
280 'user_channel',
281 install_dir: get_option('includedir'),
282 strip_directory: false,
283 exclude_files: '*.cpp')