| project( |
| 'gvrlog', 'cpp', |
| version : '1.0.0', |
| meson_version: '>=1.1.1', |
| default_options: [ |
| 'warning_level=3', |
| 'werror=true', |
| 'cpp_std=c++23', |
| 'buildtype=debug' |
| ] |
| ) |
| |
| # getting dependencies |
| cpp = meson.get_compiler('cpp') |
| i2c = cpp.find_library('i2c') |
| sdbusplus_dep = dependency('sdbusplus') |
| phosphor_logging_dep = dependency('phosphor-logging') |
| gvrlog_deps = [i2c, sdbusplus_dep, phosphor_logging_dep] |
| |
| ## test dependencies |
| if(get_option('tests').enabled()) |
| gtest = dependency('gtest', main: true, disabler: true, required: false) |
| gmock = dependency('gmock', required: false) |
| |
| if not gtest.found() or not gmock.found() |
| message('gtest or gmock not found, trying to import googletest subproject') |
| gtest_proj = import('cmake').subproject('googletest', required: false) |
| if gtest_proj.found() |
| message('googletest subproject found') |
| gtest = declare_dependency( |
| dependencies: [ |
| dependency('threads'), |
| gtest_proj.dependency('gtest'), |
| gtest_proj.dependency('gtest_main'), |
| ]) |
| gmock = gtest_proj.dependency('gmock') |
| else |
| message('googletest subproject not found') |
| assert(not get_option('tests').allowed(), 'Googletest is required') |
| endif |
| endif |
| gvrlog_deps += [gtest, gmock] |
| add_project_arguments('-DUNIT_TEST', language : 'cpp') |
| endif |
| |
| incdir = include_directories( |
| '.', |
| 'include', |
| 'test/include', |
| ) |
| |
| subdir('configs') |
| gvrlog_deps += conf_h_dep |
| |
| subdir('service_files') |
| |
| |
| if(get_option('tests').disabled()) |
| executable( |
| 'log_tool', |
| [ |
| 'src/main.cpp', |
| 'src/power_rail/power_rail_utility.cpp', |
| 'src/power_rail/max34451_utility.cpp', |
| 'src/power_rail/pmbus_lib.cpp', |
| 'src/voltage_regulator/voltage_regulator_utility.cpp', |
| 'src/voltage_regulator/voltage_regulator_parse_common_log.cpp', |
| 'src/voltage_regulator/voltage_regulator_parse_MFR_log.cpp', |
| 'src/voltage_regulator/voltage_regulator_query_MFR_log.cpp', |
| 'src/common_utility.cpp', |
| 'src/dbus_utility.cpp' |
| ], |
| dependencies: gvrlog_deps, |
| install: true, |
| install_dir: get_option('bindir'), |
| cpp_args: ['-DDEFAULT_LOG_DIR_PATH="@0@"'.format(get_option('logDirPath'))] |
| ) |
| |
| executable( |
| 'max34451_logger', |
| [ |
| 'src/power_rail/max34451_status.cpp', |
| 'src/power_rail/max34451_utility.cpp', |
| 'src/power_rail/pmbus_lib.cpp', |
| 'src/common_utility.cpp', |
| 'src/dbus_utility.cpp' |
| ], |
| dependencies: [ |
| i2c, |
| sdbusplus_dep, |
| phosphor_logging_dep |
| ], |
| install: true, |
| install_dir: get_option('bindir') |
| ) |
| else # test enabled |
| message('Tests are enabled') |
| |
| test( |
| 'common_utility_unittest', |
| executable( |
| 'common_utility_unittest', |
| [ |
| 'test/common_utility_unittest.cpp', |
| 'src/common_utility.cpp', |
| 'src/dbus_utility.cpp', |
| ], |
| dependencies: gvrlog_deps, |
| include_directories: incdir, |
| ) |
| ) |
| |
| test( |
| 'pmbus_lib_unittest', |
| executable( |
| 'pmbus_lib_unittest', |
| [ |
| 'test/power_rail/pmbus_lib_unittest.cpp', |
| 'src/power_rail/pmbus_lib.cpp', |
| 'src/common_utility.cpp', |
| 'src/dbus_utility.cpp', |
| ], |
| dependencies: gvrlog_deps, |
| include_directories: incdir, |
| ) |
| ) |
| |
| test( |
| 'power_rail_utility_unittest', |
| executable( |
| 'power_rail_utility_unittest', |
| [ |
| 'test/power_rail/power_rail_utility_unittest.cpp', |
| 'src/power_rail/power_rail_utility.cpp', |
| 'src/common_utility.cpp', |
| 'src/dbus_utility.cpp', |
| ], |
| dependencies: gvrlog_deps, |
| include_directories: incdir, |
| ) |
| ) |
| |
| test( |
| 'voltage_regulator_utility_unittest', |
| executable( |
| 'voltage_regulator_utility_unittest', |
| [ |
| 'test/voltage_regulator/voltage_regulator_utility_unittest.cpp', |
| 'src/voltage_regulator/voltage_regulator_utility.cpp', |
| 'src/voltage_regulator/voltage_regulator_parse_common_log.cpp', |
| 'src/voltage_regulator/voltage_regulator_parse_MFR_log.cpp', |
| 'src/voltage_regulator/voltage_regulator_query_MFR_log.cpp', |
| 'src/common_utility.cpp', |
| 'src/dbus_utility.cpp', |
| ], |
| dependencies: gvrlog_deps, |
| include_directories: incdir, |
| ) |
| ) |
| |
| test( |
| 'max34451_utility_unittest', |
| executable( |
| 'max34451_utility_unittest', |
| [ |
| 'test/power_rail/max34451_utility_unittest.cpp', |
| 'src/power_rail/max34451_utility.cpp', |
| 'src/common_utility.cpp', |
| 'src/dbus_utility.cpp', |
| ], |
| dependencies: gvrlog_deps, |
| include_directories: incdir, |
| ) |
| ) |
| |
| endif |