From edeeebc33c155cf1b8fb26e4a34c92ee0b226ac9 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:06:39 +0100 Subject: [PATCH 1/2] Allow use of libfswatch in non-standard locations --- NEWS.md | 2 ++ configure | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index 009a272..02ade49 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # watcher (development version) +* Watcher can now use a system-installed 'libfswatch' in a non-standard filesystem location. + # watcher 0.1.3 * `watcher()` now accepts a vector for the `path` argument to monitor multiple files or directories (#16). diff --git a/configure b/configure index 4c1779d..f16c02d 100755 --- a/configure +++ b/configure @@ -5,6 +5,7 @@ LIB_VER="5c443d2" # Initialise PKG_CFLAGS="" +PKG_LIBL="-lfswatch" PKG_LIBS="-lpthread" # Find compiler and export flags @@ -37,33 +38,34 @@ if [ -z "$WATCHER_LIBS" ]; then if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ] then PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS" - PKG_LIBS="-L$LIB_DIR -lfswatch $PKG_LIBS" + PKG_LIBL="-L$LIB_DIR $PKG_LIBL" echo "Found INCLUDE_DIR $INCLUDE_DIR" echo "Found LIB_DIR $LIB_DIR" elif [ -d "/usr/local/include/libfswatch" ] then PKG_CFLAGS="-I/usr/local/include $PKG_CFLAGS" - PKG_LIBS="-L/usr/local/lib -lfswatch $PKG_LIBS" - echo "Found 'libfswatch' $PKG_CFLAGS" + PKG_LIBL="-L/usr/local/lib $PKG_LIBL" elif [ -d "/usr/include/libfswatch" ] then PKG_CFLAGS="-I/usr/include $PKG_CFLAGS" - PKG_LIBS="-L/usr/lib -lfswatch $PKG_LIBS" - echo "Found 'libfswatch' $PKG_CFLAGS" + PKG_LIBL="-L/usr/lib $PKG_LIBL" elif [ -d "/usr/local/opt/libfswatch" ] then PKG_CFLAGS="-I/usr/local/opt/fswatch/include $PKG_CFLAGS" - PKG_LIBS="-L/usr/local/opt/fswatch/lib -lfswatch $PKG_LIBS" - echo "Found 'libfswatch' $PKG_CFLAGS" -else - echo "Existing 'libfswatch' not found" + PKG_LIBL="-L/usr/local/opt/fswatch/lib $PKG_LIBL" fi +echo "#include +int main() { + if (fsw_init_library() != FSW_OK) return; +}" | ${CC} ${PKG_CFLAGS} -xc - -o /dev/null > /dev/null 2>&1 else echo "WATCHER_LIBS is set... skipping detection" + false fi -if [ -z "$PKG_CFLAGS" ]; then +if [ $? -ne 0 ] +then echo "Compiling 'libfswatch' from source..." echo "Detecting 'cmake'..." which cmake @@ -92,6 +94,9 @@ if [ -z "$PKG_CFLAGS" ]; then PKG_CFLAGS="-I../install/include $PKG_CFLAGS" PKG_LIBS="../install/lib/libfswatch.b $PKG_LIBS" fi +else + echo "Found 'libfswatch' $PKG_CFLAGS" + PKG_LIBS="$PKG_LIBL $PKG_LIBS" fi # Write to Makevars From 38d535b2c307991af4f5ee7d30f6869b39c90be8 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Tue, 15 Jul 2025 19:44:53 +0100 Subject: [PATCH 2/2] Fix configure test --- configure | 4 +++- tests/testthat/test-watch.R | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure b/configure index f16c02d..a19798b 100755 --- a/configure +++ b/configure @@ -56,7 +56,9 @@ then fi echo "#include int main() { - if (fsw_init_library() != FSW_OK) return; +#if FSW_OK + *(void *) 0 = 0; +#endif }" | ${CC} ${PKG_CFLAGS} -xc - -o /dev/null > /dev/null 2>&1 else diff --git a/tests/testthat/test-watch.R b/tests/testthat/test-watch.R index 19357d0..c18d348 100644 --- a/tests/testthat/test-watch.R +++ b/tests/testthat/test-watch.R @@ -25,6 +25,7 @@ test_that("watcher() logs", { }) test_that("watcher() callbacks", { + skip_if(R.version$arch == "aarch64" && !Sys.getenv("NOT_CRAN") == "true") x <- 0L w <- watcher( c(dir, dir2),