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