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', include_type: 'system') 38 39sdbusplus = dependency('sdbusplus', required: false) 40if not sdbusplus.found() 41 sdbusplus_proj = subproject('sdbusplus', required: true) 42 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') 43 sdbusplus = sdbusplus.as_system('system') 44endif 45systemd = dependency('systemd') 46systemd_system_unit_dir = systemd.get_variable( 47 'systemdsystemunitdir', 48 pkgconfig_define: ['prefix', get_option('prefix')]) 49packagedir = join_paths( 50 get_option('prefix'), 51 get_option('datadir'), 52 meson.project_name(), 53) 54sysconfdir = join_paths( 55 get_option('prefix'), 56 get_option('sysconfdir'), 57 meson.project_name(), 58) 59threads = dependency('threads') 60if cpp.has_header('valijson/validator.hpp') 61 valijson = declare_dependency() 62else 63 subproject('valijson', required: false) 64 valijson = declare_dependency( 65 include_directories: 'subprojects/valijson/include' 66 ) 67 valijson = valijson.as_system('system') 68endif 69 70install_data('blacklist.json') 71 72configs = [ 73 '1ux16_riser.json', 74 '2ux8_riser.json', 75 '3ypower_vast2112_psu.json', 76 '8x25_hsbp.json', 77 'a2ul16riser.json', 78 'a2ux8x4riser.json', 79 'acbell_rica_psu.json', 80 'acbel_r1ca2122a_psu.json', 81 'asrock_e3c246d4i.json', 82 'asrock_e3c256d4i.json', 83 'asrock_m3_small_x86.json', 84 'asrock_n3_xlarge_x86.json', 85 'asrock_romed8hm3.json', 86 'asrock_spc621d8hm3.json', 87 'bletchley_baseboard.json', 88 'bletchley_chassis.json', 89 'bletchley_frontpanel.json', 90 'blyth.json', 91 'ahw1um2riser.json', 92 'aspower_u1a-d10550_psu.json', 93 'aspower_u1a-d10800_psu.json', 94 'aspower_u1a-d11200_psu.json', 95 'aspower_u1a-d11600_psu.json', 96 'aspower_u1d-d10800_psu.json', 97 'axx1p100hssi_aic.json', 98 'axx2prthdhd.json', 99 'bmc_storage_module.json', 100 'bnp_baseboard.json', 101 'bellavista.json', 102 'bonnell.json', 103 'delta_awf2dc3200w_psu.json', 104 'delta_dps-750xb_psu.json', 105 'delta_dps-1600ab_psu.json', 106 'delta_dps-2000ab_psu.json', 107 'supermicro-pws-920p-sq_psu.json', 108 'everest.json', 109 'f1u12x25_hsbp.json', 110 'f1u4x25_hsbp.json', 111 'f2u12x35_hsbp.json', 112 'f2u8x25_hsbp.json', 113 'fbtp.json', 114 'fbyv2.json', 115 'fbyv35.json', 116 'fbyv35_nic_mellanox.json', 117 'flextronics_s-1100adu00-201_psu.json', 118 'genesis3_psu.json', 119 'genesis3_baseboard.json', 120 'genesis3_chassis.json', 121 'gospower_g1136-1300wna_psu.json', 122 'greatlakes.json', 123 'greatlakes_nic_mellanox.json', 124 'harma_bsm.json', 125 'harma_fanboard.json', 126 'harma_mb.json', 127 'harma_nic.json', 128 'harma_scm.json', 129 'ibm_tacoma_rack_controller.json', 130 'ingraham.json', 131 'intel_front_panel.json', 132 'kudo_bmc.json', 133 'kudo_motherboard.json', 134 'micron_7450.json', 135 'minerva_cmm.json', 136 'minerva_cmm_bsm.json', 137 'minerva_cmm_scm.json', 138 'minerva_fanboard.json', 139 'minerva_pdb.json', 140 'minerva_pttv.json', 141 'minerva_sitv.json', 142 'mori_bmc.json', 143 'mori_motherboard.json', 144 'mtjade.json', 145 'mtmitchell_bmc.json', 146 'mtmitchell_mb.json', 147 'mudflap.json', 148 'nisqually.json', 149 'nvme_p4000.json', 150 'pcie_ssd_retimer.json', 151 'pennybacker.json', 152 'pssf132202a.json', 153 'pssf162205a.json', 154 'pssf212201a.json', 155 'pssf222201a.json', 156 'rainier_2u_chassis.json', 157 'rainier_4u_chassis.json', 158 'rainier_1s4u_chassis.json', 159 'r1000_chassis.json', 160 'r2000_chassis.json', 161 'sas_module.json', 162 'sbp1_baseboard.json', 163 'sbp1_chassis.json', 164 'sbp1_nvme.json', 165 'sbp1_psu.json', 166 'sbp1_rssd.json', 167 'system1_baseboard.json', 168 'system1_chassis.json', 169 'solum_pssf162202_psu.json', 170 'storm_king.json', 171 'stp_baseboard.json', 172 'stp_p4000_chassis.json', 173 'tola.json', 174 'twinlake.json', 175 'tyan_s7106_baseboard.json', 176 'tyan_s8036_baseboard.json', 177 'vegman_n110_baseboard.json', 178 'vegman_rx20_baseboard.json', 179 'vegman_sx20_baseboard.json', 180 'wft_baseboard.json', 181 'yosemite4_fanboard.json', 182 'yosemite4_sentineldome.json', 183 'yosemite4_floatingfalls.json', 184 'yosemite4_wailuafalls.json', 185 'yosemite4.json', 186 'yosemite4_medusaboard.json', 187 'yosemite4_spiderboard.json', 188] 189filepaths = [] 190foreach c : configs 191 file = join_paths('configurations', c) 192 install_data( 193 file, 194 install_dir: join_paths( 195 packagedir, 196 'configurations', 197 ) 198 ) 199 filepaths += [file] 200endforeach 201 202validate_script = files('scripts/validate_configs.py') 203autojson = custom_target( 204 'check_syntax', 205 command: [ 206 validate_script, 207 '-v', 208 '-k', 209 ], 210 depend_files: files(filepaths), 211 build_by_default: true, 212 capture: true, 213 output: 'validate_configs.log', 214) 215 216schemas = [ 217 'global.json', 218 'legacy.json', 219 'openbmc-dbus.json', 220 'ibm.json', 221 'intel.json', 222 'pid.json', 223 'pid_zone.json', 224 'stepwise.json', 225 'virtual_sensor.json', 226 'satellite_controller.json', 227] 228 229foreach s : schemas 230 install_data( 231 join_paths('schemas', s), 232 install_dir: join_paths( 233 packagedir, 234 'configurations', 235 'schemas', 236 ) 237 ) 238endforeach 239 240subdir('service_files') 241subdir('src') 242 243if not build_tests.disabled() 244 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 245 gtest = dependency('gtest', main: true, disabler: true, required: false) 246 gmock = dependency('gmock', disabler: true, required: false) 247 if not (gtest.found() and gmock.found()) and build_tests.enabled() 248 cmake = import('cmake') 249 gtest_subproject = cmake.subproject('gtest') 250 cm_gtest = gtest_subproject.dependency('gtest') 251 cm_gtest_main = gtest_subproject.dependency('gtest_main') 252 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 253 gmock = gtest_subproject.dependency('gmock') 254 255 endif 256 257 test( 258 'test_entity_manager', 259 executable( 260 'test_entity_manager', 261 'test/test_entity-manager.cpp', 262 'src/expression.cpp', 263 'src/utils.cpp', 264 cpp_args: test_boost_args, 265 dependencies: [ 266 boost, 267 gtest, 268 nlohmann_json_dep, 269 sdbusplus, 270 valijson, 271 ], 272 include_directories: 'src', 273 ) 274 ) 275 276 test( 277 'test_fru_utils', 278 executable( 279 'test_fru_utils', 280 'test/test_fru-utils.cpp', 281 'src/fru_utils.cpp', 282 'src/fru_reader.cpp', 283 cpp_args: test_boost_args, 284 dependencies: [ 285 boost, 286 gtest, 287 sdbusplus, 288 ], 289 include_directories: 'src', 290 ) 291 ) 292 293 test( 294 'test_topology', 295 executable( 296 'test_topology', 297 'test/test_topology.cpp', 298 'src/topology.cpp', 299 cpp_args: test_boost_args, 300 dependencies: [ 301 gtest, 302 gmock, 303 nlohmann_json_dep, 304 ], 305 include_directories: 'src', 306 ) 307 ) 308endif 309