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
55feature_map = {
56  'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
57  'i2c-whitelist-check'        : '-DENABLE_I2C_WHITELIST_CHECK',
58  'update-functional-on-fail'  : '-DUPDATE_FUNCTIONAL_ON_FAIL',
59  'dynamic-sensors'            : '-DFEATURE_DYNAMIC_SENSORS',
60  'dynamic-sensors-write'      : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
61  'hybrid-sensors'             : '-DFEATURE_HYBRID_SENSORS',
62  'sensors-cache'              : '-DFEATURE_SENSORS_CACHE',
63  'sel-logger-clears-sel'      : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
64}
65
66foreach option_key, option_value : feature_map
67  if(get_option(option_key).enabled())
68    summary(option_key,option_value, section : 'Enabled Features')
69    add_project_arguments(option_value,language:'cpp')
70  endif
71endforeach
72
73add_project_arguments(
74  cpp.get_supported_arguments([
75    '-flto',
76    '-Wno-psabi',
77    '-Wno-missing-field-initializers',
78    '-Wno-pedantic',
79    '-Wno-non-virtual-dtor'
80  ]),
81  language: 'cpp')
82
83# Dependencies
84phosphor_logging_dep = dependency('phosphor-logging')
85phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
86sdeventplus_dep = dependency('sdeventplus')
87systemd = dependency('systemd')
88crypto = dependency('libcrypto', version : '>=1.0.2g')
89pam = cpp.find_library('pam', required: true)
90mapper = dependency('libmapper')
91boost_coroutine = cpp.find_library('boost_coroutine', required: true)
92sdbusplus_dep = dependency('sdbusplus')
93
94if cpp.has_header_symbol(
95        'nlohmann/json.hpp',
96        'nlohmann::json::string_t',
97        required:false)
98    nlohmann_json_dep = declare_dependency()
99else
100    nlohmann_json_dep = dependency('nlohmann-json')
101endif
102
103generated_src = []
104
105# Subfolders
106subdir('libipmid')
107subdir('libipmid-host')
108subdir('include')
109subdir('user_channel')
110subdir('scripts')
111
112if not get_option('softoff').disabled()
113  subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
114  subdir('softoff')
115endif
116
117# whitelist
118if not get_option('ipmi-whitelist').disabled()
119  generate_whitelist_script = files('generate_whitelist_create.sh')
120
121  whitelist_conf = get_option('whitelist-conf')
122  ipmiwhitelist = run_command( \
123    'bash', \
124    generate_whitelist_script, \
125    whitelist_conf)
126
127  whitelist_pre = declare_dependency(
128    include_directories: root_inc,
129    dependencies: [
130      crypto,
131      ipmid_dep,
132      phosphor_dbus_interfaces_dep,
133      phosphor_logging_dep,
134      sdbusplus_dep,
135    ],
136  )
137
138  whitelist_lib = library(
139    'whitelist',
140    'whitelist-filter.cpp',
141    'ipmiwhitelist.cpp',
142    implicit_include_directories: false,
143    dependencies: whitelist_pre,
144    version: meson.project_version(),
145    override_options: ['b_lundef=false'],
146    install: true,
147    install_dir: get_option('libdir') / 'ipmid-providers')
148endif
149
150# libsysintfcmds
151sysintfcmds_pre = declare_dependency(
152  include_directories: root_inc,
153  dependencies: [
154    channellayer_dep,
155    crypto,
156    mapper,
157    phosphor_dbus_interfaces_dep,
158    phosphor_logging_dep,
159    sdbusplus_dep,
160    ipmid_dep,
161  ])
162
163sysintfcmds_lib = library(
164  'sysintfcmds',
165  'systemintfcmds.cpp',
166  'host-interface.cpp',
167  implicit_include_directories: false,
168  dependencies: sysintfcmds_pre,
169  version: meson.project_version(),
170  override_options: ['b_lundef=false'],
171  install: true,
172  install_dir: get_option('libdir') / 'ipmid-providers')
173
174# ipmid
175ipmid_pre = [
176  sdbusplus_dep,
177  phosphor_logging_dep,
178  phosphor_dbus_interfaces_dep,
179  boost_coroutine,
180  crypto,
181  ipmid_dep,
182  channellayer_dep,
183  mapper,
184]
185
186transportoem_src = []
187if not get_option('transport-oem').disabled()
188  transportoem_src = ['transporthandler_oem.cpp']
189endif
190
191entity_map_json_lib = static_library(
192  'entity_map_json',
193  'entity_map_json.cpp',
194  include_directories: root_inc,
195  dependencies: [ipmid_dep, nlohmann_json_dep],
196  implicit_include_directories: false)
197
198entity_map_json_dep = declare_dependency(link_with: entity_map_json_lib)
199
200libipmi20_src = [
201  'app/channel.cpp',
202  'app/watchdog.cpp',
203  'app/watchdog_service.cpp',
204  'apphandler.cpp',
205  'sys_info_param.cpp',
206  'sensorhandler.cpp',
207  'storagehandler.cpp',
208  'chassishandler.cpp',
209  'dcmihandler.cpp',
210  'ipmisensor.cpp',
211  'storageaddsel.cpp',
212  'transporthandler.cpp',
213  'globalhandler.cpp',
214  'groupext.cpp',
215  'selutility.cpp',
216  'ipmi_fru_info_area.cpp',
217  'read_fru_data.cpp',
218  'sensordatahandler.cpp',
219  'user_channel/channelcommands.cpp',
220  generated_src,
221  transportoem_src,
222  conf_h,
223]
224
225ipmi20_lib = library(
226  'ipmi20',
227  libipmi20_src,
228  dependencies: [ipmid_pre, entity_map_json_dep, nlohmann_json_dep],
229  include_directories: root_inc,
230  install: true,
231  install_dir: get_option('libdir') / 'ipmid-providers',
232  version: meson.project_version(),
233  override_options: ['b_lundef=false'])
234
235libipmi20_dep = declare_dependency(
236  dependencies: ipmid_pre,
237  include_directories: root_inc,
238  link_with: ipmi20_lib)
239
240# ipmid binary
241executable(
242  'ipmid',
243  'ipmid-new.cpp',
244  'host-cmd-manager.cpp',
245  'settings.cpp',
246  implicit_include_directories: false,
247  dependencies: [libipmi20_dep],
248  include_directories: root_inc,
249  export_dynamic: true,
250  install: true,
251  install_dir: get_option('bindir'))
252
253# Dynamic Sensor Stack
254subdir('dbus-sdr')
255
256if not get_option('dynamic-sensors').disabled()
257  library(
258    'dynamiccmds',
259    dbus_sdr_src,
260    implicit_include_directories: false,
261    dependencies: dbus_sdr_pre,
262    version: meson.project_version(),
263    override_options: ['b_lundef=false'],
264    install: true,
265    install_dir: get_option('libdir') / 'ipmid-providers')
266endif
267
268if not get_option('tests').disabled()
269  subdir('test')
270endif
271
272install_subdir(
273  'user_channel',
274  install_dir: get_option('includedir'),
275  strip_directory: false,
276  exclude_files: '*.cpp')
277