1project( 2 'entity-manager', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++23' 8 ], 9 license: 'Apache-2.0', 10 version: '0.1', 11 meson_version: '>=1.1.1', 12) 13add_project_arguments('-Wno-psabi', language: 'cpp') 14 15boost_args = [ 16 '-DBOOST_ASIO_NO_DEPRECATED', 17 '-DBOOST_SYSTEM_NO_DEPRECATED', 18 '-DBOOST_ERROR_CODE_HEADER_ONLY', 19 '-DBOOST_NO_RTTI', 20 '-DBOOST_NO_TYPEID', 21 '-DBOOST_ALL_NO_LIB', 22 '-DBOOST_ALLOW_DEPRECATED_HEADERS' 23] 24build_tests = get_option('tests') 25cpp = meson.get_compiler('cpp') 26boost = dependency('boost', required: false) 27if not boost.found() 28 subproject('boost', required: false) 29 boost = declare_dependency( 30 include_directories: 'subprojects/boost_1_71_0', 31 ) 32 boost = boost.as_system('system') 33endif 34if get_option('fru-device') 35 i2c = cpp.find_library('i2c') 36endif 37 38if get_option('devicetree-vpd') 39 phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces', include_type: 'system') 40endif 41 42nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 43sdbusplus = dependency('sdbusplus', include_type: 'system') 44phosphor_logging_dep = dependency('phosphor-logging') 45 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 73# this creates the 'configs' variable 74subdir('configurations') 75 76filepaths = [] 77foreach c : configs 78 file = join_paths('configurations', c) 79 install_data( 80 file, 81 install_dir: join_paths( 82 packagedir, 83 'configurations', 84 ) 85 ) 86 filepaths += [file] 87endforeach 88 89if get_option('validate-json') 90 validate_script = files('scripts/validate_configs.py') 91 autojson = custom_target( 92 'check_syntax', 93 command: [ 94 validate_script, 95 '-v', 96 '-k', 97 ], 98 depend_files: files(filepaths), 99 build_by_default: true, 100 capture: true, 101 output: 'validate_configs.log', 102 ) 103endif 104 105schemas = [ 106 'global.json', 107 'legacy.json', 108 'openbmc-dbus.json', 109 'ibm.json', 110 'intel.json', 111 'pid.json', 112 'pid_zone.json', 113 'stepwise.json', 114 'virtual_sensor.json', 115 'satellite_controller.json', 116 'leak_detector.json', 117 'firmware.json', 118] 119 120foreach s : schemas 121 install_data( 122 join_paths('schemas', s), 123 install_dir: join_paths( 124 packagedir, 125 'configurations', 126 'schemas', 127 ) 128 ) 129endforeach 130 131subdir('service_files') 132subdir('src') 133 134if not build_tests.disabled() 135 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'] 136 gtest = dependency('gtest', main: true, disabler: true, required: false) 137 gmock = dependency('gmock', disabler: true, required: false) 138 if not (gtest.found() and gmock.found()) and build_tests.enabled() 139 cmake = import('cmake') 140 gtest_subproject = cmake.subproject('gtest') 141 cm_gtest = gtest_subproject.dependency('gtest') 142 cm_gtest_main = gtest_subproject.dependency('gtest_main') 143 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads]) 144 gmock = gtest_subproject.dependency('gmock') 145 146 endif 147 148 test( 149 'test_entity_manager', 150 executable( 151 'test_entity_manager', 152 'test/test_entity-manager.cpp', 153 'src/expression.cpp', 154 'src/utils.cpp', 155 cpp_args: test_boost_args, 156 dependencies: [ 157 boost, 158 gtest, 159 nlohmann_json_dep, 160 phosphor_logging_dep, 161 sdbusplus, 162 valijson, 163 ], 164 include_directories: 'src', 165 ) 166 ) 167 168 test( 169 'test_fru_utils', 170 executable( 171 'test_fru_utils', 172 'test/test_fru-utils.cpp', 173 'src/fru_utils.cpp', 174 'src/fru_reader.cpp', 175 cpp_args: test_boost_args, 176 dependencies: [ 177 boost, 178 gtest, 179 phosphor_logging_dep, 180 sdbusplus, 181 ], 182 include_directories: 'src', 183 ) 184 ) 185 186 test( 187 'test_topology', 188 executable( 189 'test_topology', 190 'test/test_topology.cpp', 191 'src/topology.cpp', 192 cpp_args: test_boost_args, 193 dependencies: [ 194 gtest, 195 gmock, 196 nlohmann_json_dep, 197 phosphor_logging_dep, 198 ], 199 include_directories: 'src', 200 ) 201 ) 202endif 203