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