Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open source Watchman C++ client library
Summary: Move the Watchman C++ client library out of HHVM and into the Watchman distribution proper and tidy up for open-sourcing. The open-source build of Watchman should only include the client library by default only if Folly is available. Configure will hard fail if `--enable-cppclient` is used and folly is not present. The open-source build of Watchman has now gained a hard dependency on libtool. This could kind of be softened but the dependency would still be present when running `autogen.sh` and this will probably spit out a bunch of whiney error messages with such a setup. Reviewed By: wez Differential Revision: D4292974 fbshipit-source-id: 589b5b25bb9487117e7a2b03d86c2e58b74d062f
- Loading branch information
1 parent
ae2adb8
commit 3782208
Showing
20 changed files
with
1,380 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
#!/bin/sh | ||
#!/bin/bash -e | ||
# vim:ts=2:sw=2:et: | ||
if test -d autom4te.cache ; then | ||
rm -rf autom4te.cache | ||
fi | ||
if test -d config.status ; then | ||
rm -f config.status | ||
fi | ||
|
||
for p in libtoolize glibtoolize FAIL; do | ||
test "$p" = FAIL && { echo "your system lacks libtoolize" 1>&2; exit 1; } || : | ||
( $p --version ) > /dev/null 2>&1 && { eval "libtoolize() { env $p; }"; break; } || : | ||
done | ||
libtoolize --no-warn -i -f | ||
|
||
aclocal | ||
autoheader | ||
automake --add-missing --foreign | ||
|
||
# This checks to make sure PKG_CHECK_MODULES is available to autoconf. This | ||
# should be the case provided pkg-config is installed AND the above commands | ||
# have been run to prep the source tree with local set-up. | ||
CHECK_PKG_CONFIG_M4='m4_ifdef([PKG_CHECK_MODULES], [errprint([ok])])' | ||
if [ "x$(autoconf <(echo "$CHECK_PKG_CONFIG_M4") 2>&1)" != "xok" ] ; then | ||
echo 'pkg-config appears to be missing (not available to autoconf tools)' | ||
echo 'please install the pkg-config package for your system.' | ||
exit 1 | ||
fi | ||
|
||
autoconf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* Copyright 2016-present Facebook, Inc. | ||
* Licensed under the Apache License, Version 2.0 */ | ||
|
||
/* | ||
This is a test utility for WatchmanConnection. This works a bit like the | ||
watchman CLI. | ||
Build with something like: | ||
$ LDFLAGS=$(pkg-config watchmanclient --libs) \ | ||
CPPFLAGS=$(pkg-config watchmanclient --cflags) \ | ||
make CLI | ||
WatchmanConnection is automatically tested via the cppclient test more | ||
thoroughly. | ||
*/ | ||
|
||
#include <watchman/WatchmanConnection.h> | ||
|
||
#include <iostream> | ||
|
||
#include <folly/init/Init.h> | ||
#include <folly/io/async/ScopedEventBaseThread.h> | ||
#include <folly/json.h> | ||
|
||
using namespace folly; | ||
using namespace watchman; | ||
|
||
int main(int argc, char** argv) { | ||
folly::init(&argc, &argv); | ||
|
||
folly::ScopedEventBaseThread sebt; | ||
auto eb = sebt.getEventBase(); | ||
|
||
folly::dynamic cmd = folly::dynamic::array; | ||
for (int i = 1; i < argc; i++) { | ||
cmd.push_back(std::string(argv[i])); | ||
} | ||
|
||
WatchmanConnection c(eb); | ||
c.connect() | ||
.then([&](folly::dynamic version) { | ||
std::cout << "Connected to watchman: " << version << std::endl; | ||
std::cout << "Going to run " << cmd << std::endl; | ||
return c.run(cmd); | ||
}) | ||
.then([](folly::dynamic result) { LOG(INFO) << "Result: " << result; }) | ||
.onError([](const folly::exception_wrapper& ex) { | ||
std::cerr << "Failed: " << ex.what() << std::endl; | ||
}) | ||
.wait(); | ||
|
||
c.run(folly::dynamic::array("watch-list")) | ||
.then([](folly::dynamic res) { std::cout << res << std::endl; }) | ||
.wait(); | ||
c.close(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
cpp_library( | ||
name='cppclient', | ||
headers=['WatchmanClient.h', 'WatchmanConnection.h'], | ||
srcs=[ | ||
'WatchmanConnection.cpp', | ||
'WatchmanResponseError.cpp', | ||
'WatchmanClient.cpp', | ||
], | ||
deps=[ | ||
'@/folly:folly', | ||
'@/folly/io/async:async', | ||
'@/folly:subprocess', | ||
'@/folly/futures:futures', | ||
'@/folly/experimental/bser:bser', | ||
] | ||
) | ||
|
||
buck_cxx_library( | ||
name='headers', | ||
exported_headers=['WatchmanClient.h', 'WatchmanConnection.h'], | ||
header_namespace='', | ||
visibility=['PUBLIC'], | ||
) |
Oops, something went wrong.