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) 63sysconfdir = join_paths( 64 get_option('prefix'), 65 get_option('sysconfdir'), 66 meson.project_name(), 67) 68threads = dependency('threads') 69if cpp.has_header('valijson/validator.hpp') 70 valijson = declare_dependency() 71else 72 subproject('valijson', required: false) 73 valijson = declare_dependency( 74 include_directories: 'subprojects/valijson/include' 75 ) 76 valijson = valijson.as_system('system') 77endif 78 79install_data('blacklist.json') 80 81configs = [ 82 '1Ux16 Riser.json', 83 '2Ux8 Riser.json', 84 '8X25 HSBP.json', 85 'A2UL16RISER.json', 86 'A2UX8X4RISER.json', 87 'ACBELL_RICA_PSU.json', 88 'ASRock_E3C246D4I.json', 89 'ASRock_ROMED8HM3.json', 90 'Bletchley_Baseboard.json', 91 'Bletchley_Chassis.json', 92 'Blyth.json', 93 'AHW1UM2RISER.json', 94 'ASPOWER_U1A-D10550_PSU.json', 95 'ASPOWER_U1A-D10800_PSU.json', 96 'ASPOWER_U1A-D11200_PSU.json', 97 'ASPOWER_U1A-D11600_PSU.json', 98 'ASPOWER_U1D-D10800_PSU.json', 99 'AXX1P100HSSI_AIC.json', 100 'AXX2PRTHDHD.json', 101 'BNP Baseboard.json', 102 'Bellavista.json', 103 'Delta_AWF2DC3200W_PSU.json', 104 'Delta DPS-750XB PSU.json', 105 'Delta_DPS-1600AB_PSU.json', 106 'Delta_DPS-2000AB_PSU.json', 107 'Everest.json', 108 'F1U12X25 HSBP.json', 109 'F1U4X25 HSBP.json', 110 'F2U12X35 HSBP.json', 111 'F2U8X25 HSBP.json', 112 'FBTP.json', 113 'FBYV2.json', 114 'Flextronics S-1100ADU00-201 PSU.json', 115 'IBM 1000W CFFPS.json', 116 'IBM 1400W CFFPS.json', 117 'IBM 1600W CFFPS.json', 118 'IBM 2000W CFFPS.json', 119 'IBM 2300W CFFPS.json', 120 'Intel Front Panel.json', 121 'Kudo_BMC.json', 122 'Kudo_Motherboard.json', 123 'Mt_Jade.json', 124 'Nisqually.json', 125 'NVME P4000.json', 126 'PCIE SSD Retimer.json', 127 'PSSF132202A.json', 128 'PSSF162205A.json', 129 'PSSF212201A.json', 130 'PSSF222201A.json', 131 'Rainier 2U Chassis.json', 132 'Rainier 4U Chassis.json', 133 'Rainier 1S4U Chassis.json', 134 'R1000 Chassis.json', 135 'R2000 Chassis.json', 136 'SAS Module.json', 137 'SOLUM_PSSF162202_PSU.json', 138 'Storm King.json', 139 'STP Baseboard.json', 140 'STP P4000 Chassis.json', 141 'Tyan_S7106_Baseboard.json', 142 'Tyan_S8036_Baseboard.json', 143 'WFT Baseboard.json', 144] 145filepaths = [] 146foreach c : configs 147 file = join_paths('configurations', c) 148 install_data( 149 file, 150 install_dir: join_paths( 151 packagedir, 152 'configurations', 153 ) 154 ) 155 filepaths += [file] 156endforeach 157 158validate_script = files('scripts/validate-configs.py') 159autojson = custom_target( 160 'check_syntax', 161 command: [ 162 validate_script, 163 '-v', 164 '-k', 165 ], 166 depend_files: files(filepaths), 167 build_by_default: true, 168 capture: true, 169 output: 'validate_configs.log', 170) 171 172schemas = [ 173 'global.json', 174 'legacy.json', 175 'openbmc-dbus.json', 176 'IBM.json', 177 'Intel.json', 178 'Pid.json', 179 'Pid.Zone.json', 180 'Stepwise.json', 181 'VirtualSensor.json', 182] 183 184foreach s : schemas 185 install_data( 186 join_paths('schemas', s), 187 install_dir: join_paths( 188 packagedir, 189 'configurations', 190 'schemas', 191 ) 192 ) 193endforeach 194 195subdir('service_files') 196subdir('src') 197 198if not build_tests.disabled() 199 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 200 gtest = dependency('gtest', main: true, disabler: true, required: false) 201 if not gtest.found() and build_tests.enabled() 202 cmake = import('cmake') 203 gtest_subproject = cmake.subproject('gtest') 204 cm_gtest = gtest_subproject.dependency('gtest') 205 cm_gtest_main = gtest_subproject.dependency('gtest_main') 206 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 207 endif 208 209 test( 210 'test_entity_manager', 211 executable( 212 'test_entity_manager', 213 'test/test_entity-manager.cpp', 214 'src/Expression.cpp', 215 'src/Utils.cpp', 216 cpp_args: test_boost_args, 217 dependencies: [ 218 boost, 219 gtest, 220 nlohmann_json, 221 sdbusplus, 222 valijson, 223 ], 224 implicit_include_directories: false, 225 include_directories: 'include', 226 ) 227 ) 228 229 test( 230 'test_fru_utils', 231 executable( 232 'test_fru_utils', 233 'test/test_fru-utils.cpp', 234 'src/FruUtils.cpp', 235 cpp_args: test_boost_args, 236 dependencies: [ 237 boost, 238 gtest, 239 ], 240 implicit_include_directories: false, 241 include_directories: 'include', 242 ) 243 ) 244endif 245