Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
27 changes: 17 additions & 10 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LIB_VER="5c443d2"

# Initialise
PKG_CFLAGS=""
PKG_LIBL="-lfswatch"
PKG_LIBS="-lpthread"

# Find compiler and export flags
Expand Down Expand Up @@ -37,33 +38,36 @@ 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 <libfswatch/c/libfswatch.h>
int main() {
#if FSW_OK
*(void *) 0 = 0;
#endif
}" | ${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
Expand Down Expand Up @@ -92,6 +96,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
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-watch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading