1project( 2 'entity-manager', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++23' 8 ], 9 license: 'Apache-2.0', 10 version: '0.1', 11 meson_version: '>=1.1.1', 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_c3_medium_x86.json', 82 'asrock_e3c246d4i.json', 83 'asrock_e3c256d4i.json', 84 'asrock_m3_small_x86.json', 85 'asrock_n3_xlarge_x86.json', 86 'asrock_romed8hm3.json', 87 'asrock_spc621d8hm3.json', 88 'bletchley_baseboard.json', 89 'bletchley_chassis.json', 90 'bletchley_frontpanel.json', 91 'blyth.json', 92 'ahw1um2riser.json', 93 'aspower_u1a-d10550_psu.json', 94 'aspower_u1a-d10800_psu.json', 95 'aspower_u1a-d11200_psu.json', 96 'aspower_u1a-d11600_psu.json', 97 'aspower_u1d-d10800_psu.json', 98 'axx1p100hssi_aic.json', 99 'axx2prthdhd.json', 100 'bmc_storage_module.json', 101 'bnp_baseboard.json', 102 'bellavista.json', 103 'blueridge_1s4u_chassis.json', 104 'blueridge_2u_chassis.json', 105 'blueridge_4u_chassis.json', 106 'bonnell.json', 107 'brcm_100g_1p_ocp_mezz.json', 108 'brcm_200g_1p_ocp_mezz.json', 109 'cx7_ocp.json', 110 'delta_awf2dc3200w_psu.json', 111 'delta_dps-750xb_psu.json', 112 'delta_dps-1600ab_psu.json', 113 'delta_dps-2000ab_psu.json', 114 'supermicro-pws-920p-sq_psu.json', 115 'everest.json', 116 'f1u12x25_hsbp.json', 117 'f1u4x25_hsbp.json', 118 'f2u12x35_hsbp.json', 119 'f2u8x25_hsbp.json', 120 'fbtp.json', 121 'fbyv2.json', 122 'fbyv35.json', 123 'fbyv35_nic_mellanox.json', 124 'flextronics_s-1100adu00-201_psu.json', 125 'fp5280g3_chassis.json', 126 'fp5280g3_fanboard.json', 127 'fuji.json', 128 'genesis3_psu.json', 129 'genesis3_baseboard.json', 130 'genesis3_chassis.json', 131 'gospower_g1136-1300wna_psu.json', 132 'greatlakes.json', 133 'greatlakes_nic_mellanox.json', 134 'harma_bsm.json', 135 'harma_fanboard.json', 136 'harma_mb.json', 137 'harma_mb_vr_infineon.json', 138 'harma_scm.json', 139 'ibm_tacoma_rack_controller.json', 140 'ingraham.json', 141 'intel_front_panel.json', 142 'kudo_bmc.json', 143 'kudo_motherboard.json', 144 'micron_7450.json', 145 'minerva_cmm.json', 146 'minerva_cmm_hsc_infineon.json', 147 'minerva_cmm_bsm.json', 148 'minerva_cmm_scm.json', 149 'minerva_fanboard.json', 150 'minerva_pdb.json', 151 'minerva_pttv.json', 152 'minerva_sitv.json', 153 'mori_bmc.json', 154 'mori_motherboard.json', 155 'mtjade.json', 156 'mtmitchell_bmc.json', 157 'mtmitchell_mb.json', 158 'mudflap.json', 159 'nf5280m7_baseboard.json', 160 'nisqually.json', 161 'nuvoton_npcm8xx_evb.json', 162 'nvme_intel_p_series.json', 163 'nvme_p4500_p5500.json', 164 'pcie_ssd_retimer.json', 165 'pennybacker.json', 166 'pssf132202a.json', 167 'pssf162205a.json', 168 'pssf212201a.json', 169 'pssf222201a.json', 170 'rainier_2u_chassis.json', 171 'rainier_4u_chassis.json', 172 'rainier_1s4u_chassis.json', 173 'r1000_chassis.json', 174 'r2000_chassis.json', 175 'sas_module.json', 176 'sbp1_baseboard.json', 177 'sbp1_chassis.json', 178 'sbp1_nvme.json', 179 'sbp1_psu.json', 180 'sbp1_rssd.json', 181 'sbp1_hbm.json', 182 'system1_baseboard.json', 183 'system1_chassis.json', 184 'solum_pssf162202_psu.json', 185 'storm_king.json', 186 'stp_baseboard.json', 187 'stp_p4000_chassis.json', 188 'terminus_2x100g_nic_tsff.json', 189 'tola.json', 190 'twinlake.json', 191 'tyan_s7106_baseboard.json', 192 'tyan_s8036_baseboard.json', 193 'vegman_n110_baseboard.json', 194 'vegman_rx20_baseboard.json', 195 'vegman_sx20_baseboard.json', 196 'wft_baseboard.json', 197 'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_mps.json', 198 'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_max.json', 199 'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_mps.json', 200 'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_max.json', 201 'yosemite4_sentineldome_t1.json', 202 'yosemite4_sentineldome_t1_retimer.json', 203 'yosemite4_sentineldome_t2.json', 204 'yosemite4_sentineldome_t2_retimer.json', 205 'yosemite4_sentineldome_chassis.json', 206 'yosemite4_chassis.json', 207 'yosemite4_floatingfalls.json', 208 'yosemite4_wailuafalls.json', 209 'yosemite4.json', 210 'yosemite4n.json', 211 'yosemite4_medusaboard_adc_ti_hsc_adi.json', 212 'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_inf.json', 213 'yosemite4_medusaboard_adc_ti_12vhsc_adi_48vhsc_inf.json', 214 'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_adi.json', 215 'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_inf.json', 216 'yosemite4_medusaboard_adc_rns_hsc_adi.json', 217 'yosemite4_medusaboard_adc_rns_12vhsc_adi_48vhsc_inf.json', 218 'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_adi.json', 219 'yosemite4_spiderboard_adc_ti_pwr_ti.json', 220 'yosemite4_spiderboard_adc_max_pwr_ti.json', 221] 222filepaths = [] 223foreach c : configs 224 file = join_paths('configurations', c) 225 install_data( 226 file, 227 install_dir: join_paths( 228 packagedir, 229 'configurations', 230 ) 231 ) 232 filepaths += [file] 233endforeach 234 235if get_option('validate-json') 236 validate_script = files('scripts/validate_configs.py') 237 autojson = custom_target( 238 'check_syntax', 239 command: [ 240 validate_script, 241 '-v', 242 '-k', 243 ], 244 depend_files: files(filepaths), 245 build_by_default: true, 246 capture: true, 247 output: 'validate_configs.log', 248 ) 249endif 250 251schemas = [ 252 'global.json', 253 'legacy.json', 254 'openbmc-dbus.json', 255 'ibm.json', 256 'intel.json', 257 'pid.json', 258 'pid_zone.json', 259 'stepwise.json', 260 'virtual_sensor.json', 261 'satellite_controller.json', 262] 263 264foreach s : schemas 265 install_data( 266 join_paths('schemas', s), 267 install_dir: join_paths( 268 packagedir, 269 'configurations', 270 'schemas', 271 ) 272 ) 273endforeach 274 275subdir('service_files') 276subdir('src') 277 278if not build_tests.disabled() 279 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 280 gtest = dependency('gtest', main: true, disabler: true, required: false) 281 gmock = dependency('gmock', disabler: true, required: false) 282 if not (gtest.found() and gmock.found()) and build_tests.enabled() 283 cmake = import('cmake') 284 gtest_subproject = cmake.subproject('gtest') 285 cm_gtest = gtest_subproject.dependency('gtest') 286 cm_gtest_main = gtest_subproject.dependency('gtest_main') 287 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 288 gmock = gtest_subproject.dependency('gmock') 289 290 endif 291 292 test( 293 'test_entity_manager', 294 executable( 295 'test_entity_manager', 296 'test/test_entity-manager.cpp', 297 'src/expression.cpp', 298 'src/utils.cpp', 299 cpp_args: test_boost_args, 300 dependencies: [ 301 boost, 302 gtest, 303 nlohmann_json_dep, 304 sdbusplus, 305 valijson, 306 ], 307 include_directories: 'src', 308 ) 309 ) 310 311 test( 312 'test_fru_utils', 313 executable( 314 'test_fru_utils', 315 'test/test_fru-utils.cpp', 316 'src/fru_utils.cpp', 317 'src/fru_reader.cpp', 318 cpp_args: test_boost_args, 319 dependencies: [ 320 boost, 321 gtest, 322 sdbusplus, 323 ], 324 include_directories: 'src', 325 ) 326 ) 327 328 test( 329 'test_topology', 330 executable( 331 'test_topology', 332 'test/test_topology.cpp', 333 'src/topology.cpp', 334 cpp_args: test_boost_args, 335 dependencies: [ 336 gtest, 337 gmock, 338 nlohmann_json_dep, 339 ], 340 include_directories: 'src', 341 ) 342 ) 343endif 344