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_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 'bonnell.json', 104 'brcm_100g_1p_ocp_mezz.json', 105 'brcm_200g_1p_ocp_mezz.json', 106 'cx7_ocp.json', 107 'delta_awf2dc3200w_psu.json', 108 'delta_dps-750xb_psu.json', 109 'delta_dps-1600ab_psu.json', 110 'delta_dps-2000ab_psu.json', 111 'supermicro-pws-920p-sq_psu.json', 112 'everest.json', 113 'f1u12x25_hsbp.json', 114 'f1u4x25_hsbp.json', 115 'f2u12x35_hsbp.json', 116 'f2u8x25_hsbp.json', 117 'fbtp.json', 118 'fbyv2.json', 119 'fbyv35.json', 120 'fbyv35_nic_mellanox.json', 121 'flextronics_s-1100adu00-201_psu.json', 122 'fp5280g3_chassis.json', 123 'fp5280g3_fanboard.json', 124 'fuji.json', 125 'genesis3_psu.json', 126 'genesis3_baseboard.json', 127 'genesis3_chassis.json', 128 'gospower_g1136-1300wna_psu.json', 129 'greatlakes.json', 130 'greatlakes_nic_mellanox.json', 131 'harma_bsm.json', 132 'harma_fanboard.json', 133 'harma_mb.json', 134 'harma_scm.json', 135 'ibm_tacoma_rack_controller.json', 136 'ingraham.json', 137 'intel_front_panel.json', 138 'kudo_bmc.json', 139 'kudo_motherboard.json', 140 'micron_7450.json', 141 'minerva_cmm.json', 142 'minerva_cmm_bsm.json', 143 'minerva_cmm_scm.json', 144 'minerva_fanboard.json', 145 'minerva_pdb.json', 146 'minerva_pttv.json', 147 'minerva_sitv.json', 148 'mori_bmc.json', 149 'mori_motherboard.json', 150 'mtjade.json', 151 'mtmitchell_bmc.json', 152 'mtmitchell_mb.json', 153 'mudflap.json', 154 'nisqually.json', 155 'nuvoton_npcm8xx_evb.json', 156 'nvme_intel_p_series.json', 157 'nvme_p4500_p5500.json', 158 'pcie_ssd_retimer.json', 159 'pennybacker.json', 160 'pssf132202a.json', 161 'pssf162205a.json', 162 'pssf212201a.json', 163 'pssf222201a.json', 164 'rainier_2u_chassis.json', 165 'rainier_4u_chassis.json', 166 'rainier_1s4u_chassis.json', 167 'r1000_chassis.json', 168 'r2000_chassis.json', 169 'sas_module.json', 170 'sbp1_baseboard.json', 171 'sbp1_chassis.json', 172 'sbp1_nvme.json', 173 'sbp1_psu.json', 174 'sbp1_rssd.json', 175 'sbp1_hbm.json', 176 'system1_baseboard.json', 177 'system1_chassis.json', 178 'solum_pssf162202_psu.json', 179 'storm_king.json', 180 'stp_baseboard.json', 181 'stp_p4000_chassis.json', 182 'tola.json', 183 'twinlake.json', 184 'tyan_s7106_baseboard.json', 185 'tyan_s8036_baseboard.json', 186 'vegman_n110_baseboard.json', 187 'vegman_rx20_baseboard.json', 188 'vegman_sx20_baseboard.json', 189 'wft_baseboard.json', 190 'yosemite4_fanboard.json', 191 'yosemite4_sentineldome.json', 192 'yosemite4_floatingfalls.json', 193 'yosemite4_wailuafalls.json', 194 'yosemite4.json', 195 'yosemite4_medusaboard.json', 196 'yosemite4_spiderboard.json', 197] 198filepaths = [] 199foreach c : configs 200 file = join_paths('configurations', c) 201 install_data( 202 file, 203 install_dir: join_paths( 204 packagedir, 205 'configurations', 206 ) 207 ) 208 filepaths += [file] 209endforeach 210 211if get_option('validate-json') 212 validate_script = files('scripts/validate_configs.py') 213 autojson = custom_target( 214 'check_syntax', 215 command: [ 216 validate_script, 217 '-v', 218 '-k', 219 ], 220 depend_files: files(filepaths), 221 build_by_default: true, 222 capture: true, 223 output: 'validate_configs.log', 224 ) 225endif 226 227schemas = [ 228 'global.json', 229 'legacy.json', 230 'openbmc-dbus.json', 231 'ibm.json', 232 'intel.json', 233 'pid.json', 234 'pid_zone.json', 235 'stepwise.json', 236 'virtual_sensor.json', 237 'satellite_controller.json', 238] 239 240foreach s : schemas 241 install_data( 242 join_paths('schemas', s), 243 install_dir: join_paths( 244 packagedir, 245 'configurations', 246 'schemas', 247 ) 248 ) 249endforeach 250 251subdir('service_files') 252subdir('src') 253 254if not build_tests.disabled() 255 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 256 gtest = dependency('gtest', main: true, disabler: true, required: false) 257 gmock = dependency('gmock', disabler: true, required: false) 258 if not (gtest.found() and gmock.found()) and build_tests.enabled() 259 cmake = import('cmake') 260 gtest_subproject = cmake.subproject('gtest') 261 cm_gtest = gtest_subproject.dependency('gtest') 262 cm_gtest_main = gtest_subproject.dependency('gtest_main') 263 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 264 gmock = gtest_subproject.dependency('gmock') 265 266 endif 267 268 test( 269 'test_entity_manager', 270 executable( 271 'test_entity_manager', 272 'test/test_entity-manager.cpp', 273 'src/expression.cpp', 274 'src/utils.cpp', 275 cpp_args: test_boost_args, 276 dependencies: [ 277 boost, 278 gtest, 279 nlohmann_json_dep, 280 sdbusplus, 281 valijson, 282 ], 283 include_directories: 'src', 284 ) 285 ) 286 287 test( 288 'test_fru_utils', 289 executable( 290 'test_fru_utils', 291 'test/test_fru-utils.cpp', 292 'src/fru_utils.cpp', 293 'src/fru_reader.cpp', 294 cpp_args: test_boost_args, 295 dependencies: [ 296 boost, 297 gtest, 298 sdbusplus, 299 ], 300 include_directories: 'src', 301 ) 302 ) 303 304 test( 305 'test_topology', 306 executable( 307 'test_topology', 308 'test/test_topology.cpp', 309 'src/topology.cpp', 310 cpp_args: test_boost_args, 311 dependencies: [ 312 gtest, 313 gmock, 314 nlohmann_json_dep, 315 ], 316 include_directories: 'src', 317 ) 318 ) 319endif 320