meson: Cleanup library linking
Change-Id: Ie1fa47ec3c6f2d2a88f8487f3a533c5ebd801612
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meson.build b/meson.build
index 66e6801..19dfc62 100644
--- a/meson.build
+++ b/meson.build
@@ -12,16 +12,9 @@
build_tests = get_option('tests')
-gmock = dependency('gmock')
-gpioplus = dependency('gpioplus')
-gtest = dependency('gtest', main: true)
-phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
-phosphor_logging = dependency('phosphor-logging')
-sdbusplus = dependency('sdbusplus')
-sdeventplus = dependency('sdeventplus')
-stdplus = dependency('stdplus')
fmt = dependency('fmt')
-threads = dependency('threads')
+gmock = dependency('gmock')
+gtest = dependency('gtest', main: true)
conf = configuration_data()
conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix'))
@@ -29,82 +22,62 @@
conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail'))
conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail'))
-configure_file(output: 'config.h', configuration: conf)
+sysfs_headers = include_directories('.')
-libaverage = static_library(
- 'average',
- 'average.cpp',
-)
+sysfs_deps = [
+ fmt,
+]
-libfan_pwm = static_library(
- 'fan_pwm',
- 'fan_pwm.cpp',
-)
-
-libhwmon = static_library(
- 'hwmon',
- 'hwmon.cpp',
-)
-
-libhwmonio = static_library(
- 'hwmonio',
- 'hwmonio.cpp',
-)
-
-libsensor = static_library(
- 'sensor',
- 'sensor.cpp',
- dependencies: [
- phosphor_dbus_interfaces,
- phosphor_logging,
- sdbusplus,
- ],
- link_with: [
- libhwmon,
- ],
-)
-
-libsysfs = static_library(
+sysfs_lib = static_library(
'sysfs',
'sysfs.cpp',
- dependencies: [
- sdbusplus,
- ],
-)
+ include_directories: sysfs_headers,
+ dependencies: sysfs_deps)
-libhwmon_all = static_library(
- 'hwmon_all',
+sysfs_dep = declare_dependency(
+ dependencies: sysfs_deps,
+ include_directories: sysfs_headers,
+ link_with: sysfs_lib)
+
+hwmon_headers = include_directories('.')
+
+hwmon_deps = [
+ fmt,
+ dependency('gpioplus'),
+ dependency('phosphor-dbus-interfaces'),
+ dependency('phosphor-logging'),
+ dependency('sdbusplus'),
+ dependency('sdeventplus'),
+ dependency('stdplus'),
+ sysfs_dep,
+]
+
+hwmon_lib = static_library(
+ 'hwmon',
+ 'average.cpp',
+ configure_file(output: 'config.h', configuration: conf),
'env.cpp',
+ 'fan_pwm.cpp',
'fan_speed.cpp',
'gpio_handle.cpp',
+ 'hwmon.cpp',
+ 'hwmonio.cpp',
'mainloop.cpp',
+ 'sensor.cpp',
'sensorset.cpp',
- dependencies: [
- fmt,
- gpioplus,
- phosphor_dbus_interfaces,
- phosphor_logging,
- ],
- link_with: [
- libaverage,
- libfan_pwm,
- libhwmon,
- libhwmonio,
- libsensor,
- libsysfs,
- ],
-)
+ dependencies: hwmon_deps,
+ include_directories: hwmon_headers)
+
+hwmon_dep = declare_dependency(
+ dependencies: hwmon_deps,
+ include_directories: hwmon_headers,
+ link_with: hwmon_lib)
executable(
'phosphor-hwmon-readd',
'readd.cpp',
- dependencies: [
- sdeventplus,
- ],
+ dependencies: hwmon_dep,
install: true,
- link_with: [
- libhwmon_all,
- ],
)
subdir('msl')
diff --git a/sysfs.cpp b/sysfs.cpp
index 7fdadd0..f5b12bc 100644
--- a/sysfs.cpp
+++ b/sysfs.cpp
@@ -13,18 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "config.h"
-
#include "sysfs.hpp"
+#include <fmt/format.h>
+
#include <algorithm>
#include <cerrno>
#include <cstdlib>
#include <filesystem>
#include <fstream>
-#include <memory>
-#include <phosphor-logging/log.hpp>
-#include <thread>
+#include <string>
using namespace std::string_literals;
namespace fs = std::filesystem;
@@ -233,9 +231,9 @@
}
catch (const std::exception& e)
{
- using namespace phosphor::logging;
- log<level::ERR>("Unable to find hwmon directory from the dev path",
- entry("PATH=%s", devPath.c_str()));
+ fmt::print(stderr,
+ "Unable to find hwmon directory from the dev path: {}\n",
+ devPath.c_str());
}
return emptyString;
}
diff --git a/sysfs.hpp b/sysfs.hpp
index c1799f6..80fb3d6 100644
--- a/sysfs.hpp
+++ b/sysfs.hpp
@@ -1,8 +1,5 @@
#pragma once
-#include <chrono>
-#include <exception>
-#include <fstream>
#include <string>
namespace sysfs
diff --git a/test/meson.build b/test/meson.build
index cbe1f5d..1cd4eef 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -4,10 +4,7 @@
dependencies: [
gmock,
gtest,
- ],
- include_directories: '..',
- link_with: [
- libaverage,
+ hwmon_dep,
],
)
@@ -17,8 +14,8 @@
dependencies: [
gmock,
gtest,
+ hwmon_dep,
],
- include_directories: '..',
)
fanpwm_unittest = executable(
@@ -27,12 +24,7 @@
dependencies: [
gmock,
gtest,
- phosphor_logging,
- fmt,
- ],
- include_directories: '..',
- link_with: [
- libfan_pwm,
+ hwmon_dep,
],
)
@@ -42,11 +34,7 @@
dependencies: [
gmock,
gtest,
- fmt,
- ],
- include_directories: '..',
- link_with: [
- libhwmon,
+ hwmon_dep,
],
)
@@ -56,11 +44,7 @@
dependencies: [
gtest,
gmock,
- fmt,
- ],
- include_directories: '..',
- link_with: [
- libhwmonio,
+ hwmon_dep,
],
)
@@ -71,10 +55,6 @@
dependencies: [
gtest,
gmock,
- fmt,
- ],
- include_directories: '..',
- link_with: [
- libsensor,
+ hwmon_dep,
],
)
diff --git a/tools/meson.build b/tools/meson.build
index 4b8ea4e..8458b3e 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -1,13 +1,9 @@
executable(
'find_hwmon',
'find_hwmon.cpp',
- include_directories: '..',
- link_with: libsysfs,
-)
+ dependencies: sysfs_dep)
executable(
'find_callout_path',
'find_callout_path.cpp',
- include_directories: '..',
- link_with: libsysfs,
-)
+ dependencies: sysfs_dep)