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 36if cpp.has_header('nlohmann/json.hpp') 37 nlohmann_json = declare_dependency() 38else 39 subproject('nlohmann', required: false) 40 nlohmann_json = declare_dependency( 41 include_directories: [ 42 'subprojects/nlohmann/single_include', 43 'subprojects/nlohmann/single_include/nlohmann', 44 ] 45 ) 46 nlohmann_json = nlohmann_json.as_system('system') 47endif 48sdbusplus = dependency('sdbusplus', required: false) 49if not sdbusplus.found() 50 sdbusplus_proj = subproject('sdbusplus', required: true) 51 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') 52 sdbusplus = sdbusplus.as_system('system') 53endif 54systemd = dependency('systemd') 55systemd_system_unit_dir = systemd.get_pkgconfig_variable( 56 'systemdsystemunitdir', 57 define_variable: ['prefix', get_option('prefix')]) 58packagedir = join_paths( 59 get_option('prefix'), 60 get_option('datadir'), 61 meson.project_name(), 62) 63threads = dependency('threads') 64if cpp.has_header('valijson/validator.hpp') 65 valijson = declare_dependency() 66else 67 subproject('valijson', required: false) 68 valijson = declare_dependency( 69 include_directories: 'subprojects/valijson/include' 70 ) 71 valijson = valijson.as_system('system') 72endif 73 74install_data('blacklist.json') 75 76configs = [ 77 '1Ux16 Riser.json', 78 '2Ux8 Riser.json', 79 '8X25 HSBP.json', 80 'A2UL16RISER.json', 81 'A2UX8X4RISER.json', 82 'ACBELL_RICA_PSU.json', 83 'ASRock_E3C246D4I.json', 84 'Bletchley.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 DPS-750XB PSU.json', 97 'Delta_DPS-1600AB_PSU.json', 98 'Delta_DPS-2000AB_PSU.json', 99 'Everest.json', 100 'F1U12X25 HSBP.json', 101 'F1U4X25 HSBP.json', 102 'F2U12X35 HSBP.json', 103 'F2U8X25 HSBP.json', 104 'FBTP.json', 105 'FBYV2.json', 106 'Flextronics S-1100ADU00-201 PSU.json', 107 'IBM 1000W CFFPS.json', 108 'IBM 1400W CFFPS.json', 109 'IBM 1600W CFFPS.json', 110 'IBM 2000W CFFPS.json', 111 'IBM 2300W CFFPS.json', 112 'Intel Front Panel.json', 113 'Kudo_BMC.json', 114 'Kudo_Motherboard.json', 115 'Nisqually.json', 116 'NVME P4000.json', 117 'PCIE SSD Retimer.json', 118 'PSSF132202A.json', 119 'PSSF162205A.json', 120 'PSSF212201A.json', 121 'PSSF222201A.json', 122 'Rainier 2U Chassis.json', 123 'Rainier 4U Chassis.json', 124 'Rainier 1S4U Chassis.json', 125 'R1000 Chassis.json', 126 'R2000 Chassis.json', 127 'SAS Module.json', 128 'SOLUM_PSSF162202_PSU.json', 129 'STP Baseboard.json', 130 'STP P4000 Chassis.json', 131 'Tyan_S7106_Baseboard.json', 132 'WFT Baseboard.json', 133] 134 135foreach c : configs 136 install_data( 137 join_paths('configurations', c), 138 install_dir: join_paths( 139 packagedir, 140 'configurations', 141 ) 142 ) 143endforeach 144 145schemas = [ 146 'global.json', 147 'legacy.json', 148 'openbmc-dbus.json', 149 'IBM.json', 150 'Intel.json', 151 'Pid.json', 152 'Pid.Zone.json', 153 'Stepwise.json', 154 'VirtualSensor.json', 155] 156 157foreach s : schemas 158 install_data( 159 join_paths('schemas', s), 160 install_dir: join_paths( 161 packagedir, 162 'configurations', 163 'schemas', 164 ) 165 ) 166endforeach 167 168subdir('service_files') 169subdir('src') 170 171if not build_tests.disabled() 172 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 173 gtest = dependency('gtest', main: true, disabler: true, required: false) 174 if not gtest.found() and build_tests.enabled() 175 cmake = import('cmake') 176 gtest_subproject = cmake.subproject('gtest') 177 cm_gtest = gtest_subproject.dependency('gtest') 178 cm_gtest_main = gtest_subproject.dependency('gtest_main') 179 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 180 endif 181 182 test( 183 'test_entity_manager', 184 executable( 185 'test_entity_manager', 186 'test/test_entity-manager.cpp', 187 'src/Utils.cpp', 188 cpp_args: test_boost_args, 189 dependencies: [ 190 boost, 191 gtest, 192 nlohmann_json, 193 sdbusplus, 194 valijson, 195 ], 196 implicit_include_directories: false, 197 include_directories: 'include', 198 ) 199 ) 200 201 test( 202 'test_fru_utils', 203 executable( 204 'test_fru_utils', 205 'test/test_fru-utils.cpp', 206 'src/FruUtils.cpp', 207 cpp_args: test_boost_args, 208 dependencies: [ 209 boost, 210 gtest, 211 ], 212 implicit_include_directories: false, 213 include_directories: 'include', 214 ) 215 ) 216endif 217