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