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.57.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_pkgconfig_variable( 48 'systemdsystemunitdir', 49 define_variable: ['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 '8x25_hsbp.json', 77 'a2ul16riser.json', 78 'a2ux8x4riser.json', 79 'acbell_rica_psu.json', 80 'asrock_e3c246d4i.json', 81 'asrock_romed8hm3.json', 82 'bletchley_baseboard.json', 83 'bletchley_chassis.json', 84 'bletchley_frontpanel.json', 85 'blyth.json', 86 'ahw1um2riser.json', 87 'aspower_u1a-d10550_psu.json', 88 'aspower_u1a-d10800_psu.json', 89 'aspower_u1a-d11200_psu.json', 90 'aspower_u1a-d11600_psu.json', 91 'aspower_u1d-d10800_psu.json', 92 'axx1p100hssi_aic.json', 93 'axx2prthdhd.json', 94 'bnp_baseboard.json', 95 'bellavista.json', 96 'delta_awf2dc3200w_psu.json', 97 'delta_dps-750xb_psu.json', 98 'delta_dps-1600ab_psu.json', 99 'delta_dps-2000ab_psu.json', 100 'everest.json', 101 'f1u12x25_hsbp.json', 102 'f1u4x25_hsbp.json', 103 'f2u12x35_hsbp.json', 104 'f2u8x25_hsbp.json', 105 'fbtp.json', 106 'fbyv2.json', 107 'fbyv35.json', 108 'fbyv35_nic_mellanox.json', 109 'flextronics_s-1100adu00-201_psu.json', 110 'ibm_1000w_cffps.json', 111 'ibm_1400w_cffps.json', 112 'ibm_1600w_cffps.json', 113 'ibm_2000w_cffps.json', 114 'ibm_2300w_cffps.json', 115 'intel_front_panel.json', 116 'kudo_bmc.json', 117 'kudo_motherboard.json', 118 'mt_jade.json', 119 'nisqually.json', 120 'nvme_p4000.json', 121 'pcie_ssd_retimer.json', 122 'pssf132202a.json', 123 'pssf162205a.json', 124 'pssf212201a.json', 125 'pssf222201a.json', 126 'rainier_2u_chassis.json', 127 'rainier_4u_chassis.json', 128 'rainier_1s4u_chassis.json', 129 'r1000_chassis.json', 130 'r2000_chassis.json', 131 'sas_module.json', 132 'solum_pssf162202_psu.json', 133 'storm_king.json', 134 'stp_baseboard.json', 135 'stp_p4000_chassis.json', 136 'tyan_s7106_baseboard.json', 137 'tyan_s8036_baseboard.json', 138 'vegman_n110_baseboard.json', 139 'vegman_rx20_baseboard.json', 140 'vegman_sx20_baseboard.json', 141 'wft_baseboard.json', 142] 143filepaths = [] 144foreach c : configs 145 file = join_paths('configurations', c) 146 install_data( 147 file, 148 install_dir: join_paths( 149 packagedir, 150 'configurations', 151 ) 152 ) 153 filepaths += [file] 154endforeach 155 156validate_script = files('scripts/validate_configs.py') 157autojson = custom_target( 158 'check_syntax', 159 command: [ 160 validate_script, 161 '-v', 162 '-k', 163 ], 164 depend_files: files(filepaths), 165 build_by_default: true, 166 capture: true, 167 output: 'validate_configs.log', 168) 169 170schemas = [ 171 'global.json', 172 'legacy.json', 173 'openbmc-dbus.json', 174 'ibm.json', 175 'intel.json', 176 'pid.json', 177 'pid_zone.json', 178 'stepwise.json', 179 'virtual_sensor.json', 180] 181 182foreach s : schemas 183 install_data( 184 join_paths('schemas', s), 185 install_dir: join_paths( 186 packagedir, 187 'configurations', 188 'schemas', 189 ) 190 ) 191endforeach 192 193subdir('service_files') 194subdir('src') 195 196if not build_tests.disabled() 197 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 198 gtest = dependency('gtest', main: true, disabler: true, required: false) 199 if not gtest.found() and build_tests.enabled() 200 cmake = import('cmake') 201 gtest_subproject = cmake.subproject('gtest') 202 cm_gtest = gtest_subproject.dependency('gtest') 203 cm_gtest_main = gtest_subproject.dependency('gtest_main') 204 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 205 endif 206 207 test( 208 'test_entity_manager', 209 executable( 210 'test_entity_manager', 211 'test/test_entity-manager.cpp', 212 'src/expression.cpp', 213 'src/utils.cpp', 214 cpp_args: test_boost_args, 215 dependencies: [ 216 boost, 217 gtest, 218 nlohmann_json_dep, 219 sdbusplus, 220 valijson, 221 ], 222 implicit_include_directories: false, 223 include_directories: 'include', 224 ) 225 ) 226 227 test( 228 'test_fru_utils', 229 executable( 230 'test_fru_utils', 231 'test/test_fru-utils.cpp', 232 'src/fru_utils.cpp', 233 'src/fru_reader.cpp', 234 cpp_args: test_boost_args, 235 dependencies: [ 236 boost, 237 gtest, 238 ], 239 implicit_include_directories: false, 240 include_directories: 'include', 241 ) 242 ) 243endif 244