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 'micron_7450.json', 125 'mori_bmc.json', 126 'mori_motherboard.json', 127 'mtjade.json', 128 'mtmitchell_bmc.json', 129 'mtmitchell_mb.json', 130 'nisqually.json', 131 'nvme_p4000.json', 132 'pcie_ssd_retimer.json', 133 'pennybacker.json', 134 'pssf132202a.json', 135 'pssf162205a.json', 136 'pssf212201a.json', 137 'pssf222201a.json', 138 'rainier_2u_chassis.json', 139 'rainier_4u_chassis.json', 140 'rainier_1s4u_chassis.json', 141 'r1000_chassis.json', 142 'r2000_chassis.json', 143 'sas_module.json', 144 'sbp1_baseboard.json', 145 'sbp1_chassis.json', 146 'sbp1_psu.json', 147 'system1_baseboard.json', 148 'solum_pssf162202_psu.json', 149 'storm_king.json', 150 'stp_baseboard.json', 151 'stp_p4000_chassis.json', 152 'twinlake.json', 153 'tyan_s7106_baseboard.json', 154 'tyan_s8036_baseboard.json', 155 'vegman_n110_baseboard.json', 156 'vegman_rx20_baseboard.json', 157 'vegman_sx20_baseboard.json', 158 'wft_baseboard.json', 159] 160filepaths = [] 161foreach c : configs 162 file = join_paths('configurations', c) 163 install_data( 164 file, 165 install_dir: join_paths( 166 packagedir, 167 'configurations', 168 ) 169 ) 170 filepaths += [file] 171endforeach 172 173validate_script = files('scripts/validate_configs.py') 174autojson = custom_target( 175 'check_syntax', 176 command: [ 177 validate_script, 178 '-v', 179 '-k', 180 ], 181 depend_files: files(filepaths), 182 build_by_default: true, 183 capture: true, 184 output: 'validate_configs.log', 185) 186 187schemas = [ 188 'global.json', 189 'legacy.json', 190 'openbmc-dbus.json', 191 'ibm.json', 192 'intel.json', 193 'pid.json', 194 'pid_zone.json', 195 'stepwise.json', 196 'virtual_sensor.json', 197 'satellite_controller.json', 198] 199 200foreach s : schemas 201 install_data( 202 join_paths('schemas', s), 203 install_dir: join_paths( 204 packagedir, 205 'configurations', 206 'schemas', 207 ) 208 ) 209endforeach 210 211subdir('service_files') 212subdir('src') 213 214if not build_tests.disabled() 215 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 216 gtest = dependency('gtest', main: true, disabler: true, required: false) 217 gmock = dependency('gmock', disabler: true, required: false) 218 if not (gtest.found() and gmock.found()) and build_tests.enabled() 219 cmake = import('cmake') 220 gtest_subproject = cmake.subproject('gtest') 221 cm_gtest = gtest_subproject.dependency('gtest') 222 cm_gtest_main = gtest_subproject.dependency('gtest_main') 223 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 224 gmock = gtest_subproject.dependency('gmock') 225 226 endif 227 228 test( 229 'test_entity_manager', 230 executable( 231 'test_entity_manager', 232 'test/test_entity-manager.cpp', 233 'src/expression.cpp', 234 'src/utils.cpp', 235 cpp_args: test_boost_args, 236 dependencies: [ 237 boost, 238 gtest, 239 nlohmann_json_dep, 240 sdbusplus, 241 valijson, 242 ], 243 include_directories: 'src', 244 ) 245 ) 246 247 test( 248 'test_fru_utils', 249 executable( 250 'test_fru_utils', 251 'test/test_fru-utils.cpp', 252 'src/fru_utils.cpp', 253 'src/fru_reader.cpp', 254 cpp_args: test_boost_args, 255 dependencies: [ 256 boost, 257 gtest, 258 sdbusplus, 259 ], 260 include_directories: 'src', 261 ) 262 ) 263 264 test( 265 'test_topology', 266 executable( 267 'test_topology', 268 'test/test_topology.cpp', 269 'src/topology.cpp', 270 cpp_args: test_boost_args, 271 dependencies: [ 272 gtest, 273 gmock, 274 nlohmann_json_dep, 275 ], 276 include_directories: 'src', 277 ) 278 ) 279endif 280