1project(
2  'phosphor-host-ipmid',
3  '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'))
35
36conf_h = configure_file(
37  output: 'config.h',
38  configuration: conf_data)
39
40root = meson.current_source_dir()
41root_inc = include_directories('.', 'include')
42
43# Project Arguments
44cpp = meson.get_compiler('cpp')
45add_project_arguments(
46  cpp.get_supported_arguments([
47    '-DBOOST_ERROR_CODE_HEADER_ONLY',
48    '-DBOOST_SYSTEM_NO_DEPRECATED',
49    '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
50    '-DBOOST_ASIO_DISABLE_THREADS',
51    '-DBOOST_ALL_NO_LIB',
52  ]),
53  language : 'cpp')
54
55if not get_option('get-dbus-active-software').disabled()
56  add_project_arguments(
57    cpp.get_supported_arguments([
58      '-DGET_DBUS_ACTIVE_SOFTWARE',
59    ]),
60    language : 'cpp')
61endif
62
63feature_map = {
64  'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
65  'i2c-whitelist-check'        : '-DENABLE_I2C_WHITELIST_CHECK',
66  'update-functional-on-fail'  : '-DUPDATE_FUNCTIONAL_ON_FAIL',
67  'dynamic-sensors'            : '-DFEATURE_DYNAMIC_SENSORS',
68  'dynamic-sensors-write'      : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
69  'hybrid-sensors'             : '-DFEATURE_HYBRID_SENSORS',
70  'sensors-cache'              : '-DFEATURE_SENSORS_CACHE',
71  'sel-logger-clears-sel'      : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
72}
73
74foreach option_key, option_value : feature_map
75  if(get_option(option_key).enabled())
76    summary(option_key,option_value, section : 'Enabled Features')
77    add_project_arguments(option_value,language:'cpp')
78  endif
79endforeach
80
81add_project_arguments(
82  cpp.get_supported_arguments([
83    '-flto',
84    '-Wno-psabi',
85    '-Wno-missing-field-initializers',
86    '-Wno-pedantic',
87    '-Wno-non-virtual-dtor'
88  ]),
89  language: 'cpp')
90
91# Dependencies
92phosphor_logging_dep = dependency('phosphor-logging')
93phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
94sdeventplus_dep = dependency('sdeventplus')
95systemd = dependency('systemd')
96crypto = dependency('libcrypto', version : '>=1.0.2g')
97pam = cpp.find_library('pam', required: true)
98mapper = dependency('libmapper')
99boost_coroutine = cpp.find_library('boost_coroutine', required: true)
100sdbusplus_dep = dependency('sdbusplus')
101
102if cpp.has_header_symbol(
103        'nlohmann/json.hpp',
104        'nlohmann::json::string_t',
105        required:false)
106    nlohmann_json_dep = declare_dependency()
107else
108    nlohmann_json_dep = dependency('nlohmann-json')
109endif
110
111generated_src = []
112
113# Subfolders
114subdir('libipmid')
115subdir('include')
116subdir('user_channel')
117subdir('scripts')
118
119if not get_option('softoff').disabled()
120  subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
121  subdir('softoff')
122endif
123
124# whitelist
125if not get_option('ipmi-whitelist').disabled()
126  generate_whitelist_script = files('generate_whitelist_create.sh')
127
128  whitelist_conf = get_option('whitelist-conf')
129  ipmiwhitelist = run_command( \
130    'bash', \
131    generate_whitelist_script, \
132    whitelist_conf)
133
134  whitelist_pre = declare_dependency(
135    include_directories: root_inc,
136    dependencies: [
137      crypto,
138      ipmid_dep,
139      phosphor_dbus_interfaces_dep,
140      phosphor_logging_dep,
141      sdbusplus_dep,
142    ],
143  )
144
145  whitelist_lib = library(
146    'whitelist',
147    'whitelist-filter.cpp',
148    'ipmiwhitelist.cpp',
149    implicit_include_directories: false,
150    dependencies: whitelist_pre,
151    version: meson.project_version(),
152    override_options: ['b_lundef=false'],
153    install: true,
154    install_dir: get_option('libdir') / 'ipmid-providers')
155endif
156
157# libsysintfcmds
158sysintfcmds_pre = declare_dependency(
159  include_directories: root_inc,
160  dependencies: [
161    channellayer_dep,
162    crypto,
163    mapper,
164    phosphor_dbus_interfaces_dep,
165    phosphor_logging_dep,
166    sdbusplus_dep,
167    ipmid_dep,
168  ])
169
170sysintfcmds_lib = library(
171  'sysintfcmds',
172  'systemintfcmds.cpp',
173  'host-interface.cpp',
174  implicit_include_directories: false,
175  dependencies: sysintfcmds_pre,
176  version: meson.project_version(),
177  override_options: ['b_lundef=false'],
178  install: true,
179  install_dir: get_option('libdir') / 'ipmid-providers')
180
181# ipmid
182ipmid_pre = [
183  sdbusplus_dep,
184  phosphor_logging_dep,
185  phosphor_dbus_interfaces_dep,
186  boost_coroutine,
187  crypto,
188  ipmid_dep,
189  channellayer_dep,
190  mapper,
191]
192
193transportoem_src = []
194if not get_option('transport-oem').disabled()
195  transportoem_src = ['transporthandler_oem.cpp']
196endif
197
198entity_map_json_lib = static_library(
199  'entity_map_json',
200  'entity_map_json.cpp',
201  include_directories: root_inc,
202  dependencies: [ipmid_dep, nlohmann_json_dep],
203  implicit_include_directories: false)
204
205entity_map_json_dep = declare_dependency(link_with: entity_map_json_lib)
206
207libipmi20_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',
226  'user_channel/channelcommands.cpp',
227  generated_src,
228  transportoem_src,
229  conf_h,
230]
231
232ipmi20_lib = library(
233  'ipmi20',
234  libipmi20_src,
235  dependencies: [ipmid_pre, entity_map_json_dep, nlohmann_json_dep],
236  include_directories: root_inc,
237  install: true,
238  install_dir: get_option('libdir') / 'ipmid-providers',
239  version: meson.project_version(),
240  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
263if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled()
264  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
274
275if 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')
284