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') 38sdbusplus = dependency('sdbusplus', include_type: 'system') 39phosphor_logging_dep = dependency('phosphor-logging') 40 41systemd = dependency('systemd') 42systemd_system_unit_dir = systemd.get_variable( 43 'systemdsystemunitdir', 44 pkgconfig_define: ['prefix', get_option('prefix')]) 45packagedir = join_paths( 46 get_option('prefix'), 47 get_option('datadir'), 48 meson.project_name(), 49) 50sysconfdir = join_paths( 51 get_option('prefix'), 52 get_option('sysconfdir'), 53 meson.project_name(), 54) 55threads = dependency('threads') 56if cpp.has_header('valijson/validator.hpp') 57 valijson = declare_dependency() 58else 59 subproject('valijson', required: false) 60 valijson = declare_dependency( 61 include_directories: 'subprojects/valijson/include' 62 ) 63 valijson = valijson.as_system('system') 64endif 65 66install_data('blacklist.json') 67 68configs = [ 69 '1ux16_riser.json', 70 '2ux8_riser.json', 71 '3ypower_vast2112_psu.json', 72 '8x25_hsbp.json', 73 'a2ul16riser.json', 74 'a2ux8x4riser.json', 75 'acbel_r1ca2122a_psu.json', 76 'acbell_rica_psu.json', 77 'ahw1um2riser.json', 78 'aspower_u1a-d10550_psu.json', 79 'aspower_u1a-d10800_psu.json', 80 'aspower_u1a-d11200_psu.json', 81 'aspower_u1a-d11600_psu.json', 82 'aspower_u1d-d10800_psu.json', 83 'asrock_c3_medium_x86.json', 84 'asrock_e3c246d4i.json', 85 'asrock_e3c256d4i.json', 86 'asrock_m3_small_x86.json', 87 'asrock_n3_xlarge_x86.json', 88 'asrock_romed8hm3.json', 89 'asrock_spc621d8hm3.json', 90 'axx1p100hssi_aic.json', 91 'axx2prthdhd.json', 92 'bellavista.json', 93 'bletchley_baseboard.json', 94 'bletchley_chassis.json', 95 'bletchley_frontpanel.json', 96 'blueridge_1s4u_chassis.json', 97 'blueridge_2u_chassis.json', 98 'blueridge_4u_chassis.json', 99 'blyth.json', 100 'bmc_storage_module.json', 101 'bnp_baseboard.json', 102 'bonnell.json', 103 'brcm_100g_1p_ocp_mezz.json', 104 'brcm_200g_1p_ocp_mezz.json', 105 'catalina_fio.json', 106 'catalina_hdd.json', 107 'catalina_osfp.json', 108 'catalina_pdb.json', 109 'catalina_scm.json', 110 'cx7_ocp.json', 111 'delta_awf2dc3200w_psu.json', 112 'delta_dps-1600ab_psu.json', 113 'delta_dps-2000ab_psu.json', 114 'delta_dps-750xb_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_baseboard.json', 129 'genesis3_chassis.json', 130 'genesis3_psu.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_bsm.json', 147 'minerva_cmm_hsc_infineon.json', 148 'minerva_cmm_scm.json', 149 'minerva_fanboard.json', 150 'minerva_pdb.json', 151 'minerva_pdb_hsc_xdp.json', 152 'minerva_pttv.json', 153 'minerva_sitv.json', 154 'mori_bmc.json', 155 'mori_motherboard.json', 156 'mtjade.json', 157 'mtmitchell_bmc.json', 158 'mtmitchell_mb.json', 159 'mudflap.json', 160 'nf5280m7_baseboard.json', 161 'nisqually.json', 162 'nuvoton_npcm8xx_evb.json', 163 'nvme_intel_p_series.json', 164 'nvme_p4500_p5500.json', 165 'pcie_ssd_retimer.json', 166 'pennybacker.json', 167 'pssf132202a.json', 168 'pssf162205a.json', 169 'pssf212201a.json', 170 'pssf222201a.json', 171 'r1000_chassis.json', 172 'r2000_chassis.json', 173 'rainier_1s4u_chassis.json', 174 'rainier_2u_chassis.json', 175 'rainier_4u_chassis.json', 176 'sas_module.json', 177 'sbp1_baseboard.json', 178 'sbp1_chassis.json', 179 'sbp1_hbm.json', 180 'sbp1_nvme.json', 181 'sbp1_psu.json', 182 'sbp1_rssd.json', 183 'solum_pssf162202_psu.json', 184 'storm_king.json', 185 'stp_baseboard.json', 186 'stp_p4000_chassis.json', 187 'supermicro-pws-920p-sq_psu.json', 188 'system1_baseboard.json', 189 'system1_chassis.json', 190 'terminus_2x100g_nic_tsff.json', 191 'tola.json', 192 'twinlake.json', 193 'tyan_s7106_baseboard.json', 194 'tyan_s8036_baseboard.json', 195 'vegman_n110_baseboard.json', 196 'vegman_rx20_baseboard.json', 197 'vegman_sx20_baseboard.json', 198 'wft_baseboard.json', 199 'yosemite4.json', 200 'yosemite4_chassis.json', 201 'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_max.json', 202 'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_mps.json', 203 'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_max.json', 204 'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_mps.json', 205 'yosemite4_floatingfalls.json', 206 'yosemite4_medusaboard_adc_rns_12vhsc_adi_48vhsc_inf.json', 207 'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_adi.json', 208 'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_inf.json', 209 'yosemite4_medusaboard_adc_rns_hsc_adi.json', 210 'yosemite4_medusaboard_adc_rns_isl_12vhsc_adi_48vhsc_inf.json', 211 'yosemite4_medusaboard_adc_ti_12vhsc_adi_48vhsc_inf.json', 212 'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_adi.json', 213 'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_inf.json', 214 'yosemite4_medusaboard_adc_ti_hsc_adi.json', 215 'yosemite4_sentineldome_chassis.json', 216 'yosemite4_sentineldome_t1.json', 217 'yosemite4_sentineldome_t1_retimer.json', 218 'yosemite4_sentineldome_t2.json', 219 'yosemite4_sentineldome_t2_retimer.json', 220 'yosemite4_spiderboard_adc_max_pwr_ti.json', 221 'yosemite4_spiderboard_adc_ti_pwr_ti.json', 222 'yosemite4_wailuafalls.json', 223 'yosemite4n.json', 224] 225filepaths = [] 226foreach c : configs 227 file = join_paths('configurations', c) 228 install_data( 229 file, 230 install_dir: join_paths( 231 packagedir, 232 'configurations', 233 ) 234 ) 235 filepaths += [file] 236endforeach 237 238if get_option('validate-json') 239 validate_script = files('scripts/validate_configs.py') 240 autojson = custom_target( 241 'check_syntax', 242 command: [ 243 validate_script, 244 '-v', 245 '-k', 246 ], 247 depend_files: files(filepaths), 248 build_by_default: true, 249 capture: true, 250 output: 'validate_configs.log', 251 ) 252endif 253 254schemas = [ 255 'global.json', 256 'legacy.json', 257 'openbmc-dbus.json', 258 'ibm.json', 259 'intel.json', 260 'pid.json', 261 'pid_zone.json', 262 'stepwise.json', 263 'virtual_sensor.json', 264 'satellite_controller.json', 265] 266 267foreach s : schemas 268 install_data( 269 join_paths('schemas', s), 270 install_dir: join_paths( 271 packagedir, 272 'configurations', 273 'schemas', 274 ) 275 ) 276endforeach 277 278subdir('service_files') 279subdir('src') 280 281if not build_tests.disabled() 282 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 283 gtest = dependency('gtest', main: true, disabler: true, required: false) 284 gmock = dependency('gmock', disabler: true, required: false) 285 if not (gtest.found() and gmock.found()) and build_tests.enabled() 286 cmake = import('cmake') 287 gtest_subproject = cmake.subproject('gtest') 288 cm_gtest = gtest_subproject.dependency('gtest') 289 cm_gtest_main = gtest_subproject.dependency('gtest_main') 290 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 291 gmock = gtest_subproject.dependency('gmock') 292 293 endif 294 295 test( 296 'test_entity_manager', 297 executable( 298 'test_entity_manager', 299 'test/test_entity-manager.cpp', 300 'src/expression.cpp', 301 'src/utils.cpp', 302 cpp_args: test_boost_args, 303 dependencies: [ 304 boost, 305 gtest, 306 nlohmann_json_dep, 307 phosphor_logging_dep, 308 sdbusplus, 309 valijson, 310 ], 311 include_directories: 'src', 312 ) 313 ) 314 315 test( 316 'test_fru_utils', 317 executable( 318 'test_fru_utils', 319 'test/test_fru-utils.cpp', 320 'src/fru_utils.cpp', 321 'src/fru_reader.cpp', 322 cpp_args: test_boost_args, 323 dependencies: [ 324 boost, 325 gtest, 326 phosphor_logging_dep, 327 sdbusplus, 328 ], 329 include_directories: 'src', 330 ) 331 ) 332 333 test( 334 'test_topology', 335 executable( 336 'test_topology', 337 'test/test_topology.cpp', 338 'src/topology.cpp', 339 cpp_args: test_boost_args, 340 dependencies: [ 341 gtest, 342 gmock, 343 nlohmann_json_dep, 344 phosphor_logging_dep, 345 ], 346 include_directories: 'src', 347 ) 348 ) 349endif 350