Skip to content

Commit 8930555

Browse files
authored
Allow use of 'libfswatch' in non-standard filesystem locations (#28)
* Allow use of libfswatch in non-standard locations * Fix configure test
1 parent 4c37284 commit 8930555

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# watcher (development version)
22

3+
* Watcher can now use a system-installed 'libfswatch' in a non-standard filesystem location.
4+
35
# watcher 0.1.3
46

57
* `watcher()` now accepts a vector for the `path` argument to monitor multiple files or directories (#16).

configure

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LIB_VER="5c443d2"
55

66
# Initialise
77
PKG_CFLAGS=""
8+
PKG_LIBL="-lfswatch"
89
PKG_LIBS="-lpthread"
910

1011
# Find compiler and export flags
@@ -37,33 +38,36 @@ if [ -z "$WATCHER_LIBS" ]; then
3738
if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]
3839
then
3940
PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
40-
PKG_LIBS="-L$LIB_DIR -lfswatch $PKG_LIBS"
41+
PKG_LIBL="-L$LIB_DIR $PKG_LIBL"
4142
echo "Found INCLUDE_DIR $INCLUDE_DIR"
4243
echo "Found LIB_DIR $LIB_DIR"
4344
elif [ -d "/usr/local/include/libfswatch" ]
4445
then
4546
PKG_CFLAGS="-I/usr/local/include $PKG_CFLAGS"
46-
PKG_LIBS="-L/usr/local/lib -lfswatch $PKG_LIBS"
47-
echo "Found 'libfswatch' $PKG_CFLAGS"
47+
PKG_LIBL="-L/usr/local/lib $PKG_LIBL"
4848
elif [ -d "/usr/include/libfswatch" ]
4949
then
5050
PKG_CFLAGS="-I/usr/include $PKG_CFLAGS"
51-
PKG_LIBS="-L/usr/lib -lfswatch $PKG_LIBS"
52-
echo "Found 'libfswatch' $PKG_CFLAGS"
51+
PKG_LIBL="-L/usr/lib $PKG_LIBL"
5352
elif [ -d "/usr/local/opt/libfswatch" ]
5453
then
5554
PKG_CFLAGS="-I/usr/local/opt/fswatch/include $PKG_CFLAGS"
56-
PKG_LIBS="-L/usr/local/opt/fswatch/lib -lfswatch $PKG_LIBS"
57-
echo "Found 'libfswatch' $PKG_CFLAGS"
58-
else
59-
echo "Existing 'libfswatch' not found"
55+
PKG_LIBL="-L/usr/local/opt/fswatch/lib $PKG_LIBL"
6056
fi
57+
echo "#include <libfswatch/c/libfswatch.h>
58+
int main() {
59+
#if FSW_OK
60+
*(void *) 0 = 0;
61+
#endif
62+
}" | ${CC} ${PKG_CFLAGS} -xc - -o /dev/null > /dev/null 2>&1
6163

6264
else
6365
echo "WATCHER_LIBS is set... skipping detection"
66+
false
6467
fi
6568

66-
if [ -z "$PKG_CFLAGS" ]; then
69+
if [ $? -ne 0 ]
70+
then
6771
echo "Compiling 'libfswatch' from source..."
6872
echo "Detecting 'cmake'..."
6973
which cmake
@@ -92,6 +96,9 @@ if [ -z "$PKG_CFLAGS" ]; then
9296
PKG_CFLAGS="-I../install/include $PKG_CFLAGS"
9397
PKG_LIBS="../install/lib/libfswatch.b $PKG_LIBS"
9498
fi
99+
else
100+
echo "Found 'libfswatch' $PKG_CFLAGS"
101+
PKG_LIBS="$PKG_LIBL $PKG_LIBS"
95102
fi
96103

97104
# Write to Makevars

tests/testthat/test-watch.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ test_that("watcher() logs", {
2525
})
2626

2727
test_that("watcher() callbacks", {
28+
skip_if(R.version$arch == "aarch64" && !Sys.getenv("NOT_CRAN") == "true")
2829
x <- 0L
2930
w <- watcher(
3031
c(dir, dir2),

0 commit comments

Comments
 (0)