1project( 2 'entity-manager', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++20' 8 ], 9 license: 'Apache-2.0', 10 version: '0.1', 11 meson_version: '>=0.58.0', 12) 13add_project_arguments('-Wno-psabi', language: 'cpp') 14 15boost_args = [ 16 '-DBOOST_SYSTEM_NO_DEPRECATED', 17 '-DBOOST_ERROR_CODE_HEADER_ONLY', 18 '-DBOOST_NO_RTTI', 19 '-DBOOST_NO_TYPEID', 20 '-DBOOST_ALL_NO_LIB', 21 '-DBOOST_ALLOW_DEPRECATED_HEADERS' 22] 23build_tests = get_option('tests') 24cpp = meson.get_compiler('cpp') 25boost = dependency('boost', required: false) 26if not boost.found() 27 subproject('boost', required: false) 28 boost = declare_dependency( 29 include_directories: 'subprojects/boost_1_71_0', 30 ) 31 boost = boost.as_system('system') 32endif 33if get_option('fru-device') 34 i2c = cpp.find_library('i2c') 35endif 36 37nlohmann_json_dep = dependency('nlohmann_json', 38 fallback: [ 'nlohmann_json', 'nlohmann_json_dep']) 39 40sdbusplus = dependency('sdbusplus', required: false) 41if not sdbusplus.found() 42 sdbusplus_proj = subproject('sdbusplus', required: true) 43 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') 44 sdbusplus = sdbusplus.as_system('system') 45endif 46systemd = dependency('systemd') 47systemd_system_unit_dir = systemd.get_variable( 48 'systemdsystemunitdir', 49 pkgconfig_define: ['prefix', get_option('prefix')]) 50packagedir = join_paths( 51 get_option('prefix'), 52 get_option('datadir'), 53 meson.project_name(), 54) 55sysconfdir = join_paths( 56 get_option('prefix'), 57 get_option('sysconfdir'), 58 meson.project_name(), 59) 60threads = dependency('threads') 61if cpp.has_header('valijson/validator.hpp') 62 valijson = declare_dependency() 63else 64 subproject('valijson', required: false) 65 valijson = declare_dependency( 66 include_directories: 'subprojects/valijson/include' 67 ) 68 valijson = valijson.as_system('system') 69endif 70 71install_data('blacklist.json') 72 73configs = [ 74 '1ux16_riser.json', 75 '2ux8_riser.json', 76 '3ypower_vast2112_psu.json', 77 '8x25_hsbp.json', 78 'a2ul16riser.json', 79 'a2ux8x4riser.json', 80 'acbell_rica_psu.json', 81 'asrock_e3c246d4i.json', 82 'asrock_romed8hm3.json', 83 'bletchley_baseboard.json', 84 'bletchley_chassis.json', 85 'bletchley_frontpanel.json', 86 'blyth.json', 87 'ahw1um2riser.json', 88 'aspower_u1a-d10550_psu.json', 89 'aspower_u1a-d10800_psu.json', 90 'aspower_u1a-d11200_psu.json', 91 'aspower_u1a-d11600_psu.json', 92 'aspower_u1d-d10800_psu.json', 93 'axx1p100hssi_aic.json', 94 'axx2prthdhd.json', 95 'bnp_baseboard.json', 96 'bellavista.json', 97 'bonnell.json', 98 'delta_awf2dc3200w_psu.json', 99 'delta_dps-750xb_psu.json', 100 'delta_dps-1600ab_psu.json', 101 'delta_dps-2000ab_psu.json', 102 'everest.json', 103 'f1u12x25_hsbp.json', 104 'f1u4x25_hsbp.json', 105 'f2u12x35_hsbp.json', 106 'f2u8x25_hsbp.json', 107 'fbtp.json', 108 'fbyv2.json', 109 'fbyv35.json', 110 'fbyv35_nic_mellanox.json', 111 'flextronics_s-1100adu00-201_psu.json', 112 'greatlakes.json', 113 'greatlakes_nic_mellanox.json', 114 'ibm_1000w_cffps.json', 115 'ibm_1400w_cffps.json', 116 'ibm_1600w_cffps.json', 117 'ibm_2000w_cffps.json', 118 'ibm_2300w_cffps.json', 119 'ibm_tacoma_rack_controller.json', 120 'intel_front_panel.json', 121 'kudo_bmc.json', 122 'kudo_motherboard.json', 123 'mt_jade.json', 124 'nisqually.json', 125 'nvme_p4000.json', 126 'pcie_ssd_retimer.json', 127 'pennybacker.json', 128 'pssf132202a.json', 129 'pssf162205a.json', 130 'pssf212201a.json', 131 'pssf222201a.json', 132 'rainier_2u_chassis.json', 133 'rainier_4u_chassis.json', 134 'rainier_1s4u_chassis.json', 135 'r1000_chassis.json', 136 'r2000_chassis.json', 137 'sas_module.json', 138 'solum_pssf162202_psu.json', 139 'storm_king.json', 140 'stp_baseboard.json', 141 'stp_p4000_chassis.json', 142 'twinlake.json', 143 'tyan_s7106_baseboard.json', 144 'tyan_s8036_baseboard.json', 145 'vegman_n110_baseboard.json', 146 'vegman_rx20_baseboard.json', 147 'vegman_sx20_baseboard.json', 148 'wft_baseboard.json', 149] 150filepaths = [] 151foreach c : configs 152 file = join_paths('configurations', c) 153 install_data( 154 file, 155 install_dir: join_paths( 156 packagedir, 157 'configurations', 158 ) 159 ) 160 filepaths += [file] 161endforeach 162 163validate_script = files('scripts/validate_configs.py') 164autojson = custom_target( 165 'check_syntax', 166 command: [ 167 validate_script, 168 '-v', 169 '-k', 170 ], 171 depend_files: files(filepaths), 172 build_by_default: true, 173 capture: true, 174 output: 'validate_configs.log', 175) 176 177schemas = [ 178 'global.json', 179 'legacy.json', 180 'openbmc-dbus.json', 181 'ibm.json', 182 'intel.json', 183 'pid.json', 184 'pid_zone.json', 185 'stepwise.json', 186 'virtual_sensor.json', 187 'satellite_controller.json', 188] 189 190foreach s : schemas 191 install_data( 192 join_paths('schemas', s), 193 install_dir: join_paths( 194 packagedir, 195 'configurations', 196 'schemas', 197 ) 198 ) 199endforeach 200 201subdir('service_files') 202subdir('src') 203 204if not build_tests.disabled() 205 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 206 gtest = dependency('gtest', main: true, disabler: true, required: false) 207 gmock = dependency('gmock', disabler: true, required: false) 208 if not (gtest.found() and gmock.found()) and build_tests.enabled() 209 cmake = import('cmake') 210 gtest_subproject = cmake.subproject('gtest') 211 cm_gtest = gtest_subproject.dependency('gtest') 212 cm_gtest_main = gtest_subproject.dependency('gtest_main') 213 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 214 gmock = gtest_subproject.dependency('gmock') 215 216 endif 217 218 test( 219 'test_entity_manager', 220 executable( 221 'test_entity_manager', 222 'test/test_entity-manager.cpp', 223 'src/expression.cpp', 224 'src/utils.cpp', 225 cpp_args: test_boost_args, 226 dependencies: [ 227 boost, 228 gtest, 229 nlohmann_json_dep, 230 sdbusplus, 231 valijson, 232 ], 233 include_directories: 'src', 234 ) 235 ) 236 237 test( 238 'test_fru_utils', 239 executable( 240 'test_fru_utils', 241 'test/test_fru-utils.cpp', 242 'src/fru_utils.cpp', 243 'src/fru_reader.cpp', 244 cpp_args: test_boost_args, 245 dependencies: [ 246 boost, 247 gtest, 248 sdbusplus, 249 ], 250 include_directories: 'src', 251 ) 252 ) 253 254 test( 255 'test_topology', 256 executable( 257 'test_topology', 258 'test/test_topology.cpp', 259 'src/topology.cpp', 260 cpp_args: test_boost_args, 261 dependencies: [ 262 gtest, 263 gmock, 264 nlohmann_json_dep, 265 ], 266 include_directories: 'src', 267 ) 268 ) 269endif 270