From a8c7b8886e87d868363ca9b18aaa155b33d2516b Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 25 Aug 2022 15:29:39 -0700 Subject: [PATCH 1/2] tools: delete obsolete tools/.gitignore We moved to CMake and out-of-source builds years ago. Signed-off-by: Marc Herbert --- tools/.gitignore | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 tools/.gitignore diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index d931772e0d8f..000000000000 --- a/tools/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -*.o -*.in -*~ -autom4te* -*.Po -*.swp -Makefile -config.* -configure -depcomp -install-sh -missing -stamp-h1 -aclocal.m4 -compile -ltmain.sh -rwav/rwav -*.tplg -topology/*.conf -test/topology/*.conf -eqctl/sof-eqctl -logger/sof-logger From 75d4f2833dff00d0ef4f622db0301088e3f5355a Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 25 Aug 2022 15:14:40 -0700 Subject: [PATCH 2/2] sof-logger: make inotify optional Restores ability to compile on Windows with MSYS. Fixes commit dcf0577a7725 ("logger: allow starting before the driver is loaded") Signed-off-by: Marc Herbert --- tools/logger/CMakeLists.txt | 8 ++++++++ tools/logger/config.h.in | 1 + tools/logger/logger.c | 24 ++++++++++++++++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tools/logger/config.h.in diff --git a/tools/logger/CMakeLists.txt b/tools/logger/CMakeLists.txt index d84c92ce0cc5..57637706c5d6 100644 --- a/tools/logger/CMakeLists.txt +++ b/tools/logger/CMakeLists.txt @@ -1,5 +1,13 @@ # SPDX-License-Identifier: BSD-3-Clause +# https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-To-Write-Platform-Checks +INCLUDE (CheckIncludeFiles) +CHECK_INCLUDE_FILES(sys/inotify.h HAS_INOTIFY) + +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/config.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_executable(sof-logger logger.c convert.c diff --git a/tools/logger/config.h.in b/tools/logger/config.h.in new file mode 100644 index 000000000000..fecbafbd274c --- /dev/null +++ b/tools/logger/config.h.in @@ -0,0 +1 @@ +#cmakedefine01 HAS_INOTIFY diff --git a/tools/logger/logger.c b/tools/logger/logger.c index a28661e53caa..b5df7e185d32 100644 --- a/tools/logger/logger.c +++ b/tools/logger/logger.c @@ -5,6 +5,7 @@ // Author: Bartosz Kokoszko // Artur Kloniecki +#include #include #include #include @@ -15,11 +16,17 @@ #include #include #include + +#include +#include + +#include "config.h" + +#if HAS_INOTIFY #include #include -#include #include -#include +#endif #include "convert.h" #include "misc.h" @@ -176,6 +183,12 @@ static int append_filter_config(struct convert_config *config, const char *input return 0; } +#if !HAS_INOTIFY +static void *wait_open(const char *watched_dir, const char *expected_file) +{ + assert(HAS_INOTIFY); /* Should never be called */ +} +#else /* * This 5 minutes timeout is for "backward compatible safety" in case * any user/script of an earlier, pre-inotify version of sof-logger @@ -262,6 +275,8 @@ static void *wait_open(const char *watched_dir, const char *expected_file) return ret_stream; } +#endif // HAS_INOTIFY + int main(int argc, char *argv[]) { @@ -436,9 +451,10 @@ int main(int argc, char *argv[]) * for _any_ input file, not just for /sys/kernel/debug/sof/[e]trace */ config.in_fd = NULL; - if (strncmp(config.in_file, sys_debug, strlen(sys_debug))) { + if (!HAS_INOTIFY || + strncmp(config.in_file, sys_debug, strlen(sys_debug))) { config.in_fd = fopen(config.in_file, "rb"); - } else { + } else { // both inotify and /sys/kernel/debug/ DIR *dbg_sof = (DIR *)wait_open(sys_debug, "sof"); if (dbg_sof) {