[DirectoryWatcher] Do not use FSEvents on non-macOS platforms
authorVedant Kumar <vsk@apple.com>
Thu, 23 Apr 2020 17:20:01 +0000 (10:20 -0700)
committerVedant Kumar <vsk@apple.com>
Thu, 23 Apr 2020 17:22:28 +0000 (10:22 -0700)
The FSEvents APIs are available on iOS6+: however, the DirectoryWatcher
code isn't wired up to really use FSEvents on embedded platforms.

I've duplicated code from DirectoryWatcher-not-implemented.cpp here and
used TargetConditionals instead of adding cmakery to check try_compile;
I couldn't get that to work properly.

clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp

index 7864fb7..bdc3895 100644 (file)
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include <CoreServices/CoreServices.h>
+#include <TargetConditionals.h>
 
 using namespace llvm;
 using namespace clang;
 
+#if TARGET_OS_OSX
+
 static void stopFSEventStream(FSEventStreamRef);
 
 namespace {
@@ -249,3 +252,17 @@ llvm::Expected<std::unique_ptr<DirectoryWatcher>> clang::DirectoryWatcher::creat
 
   return Result;
 }
+
+#else // TARGET_OS_OSX
+
+llvm::Expected<std::unique_ptr<DirectoryWatcher>>
+clang::DirectoryWatcher::create(
+    StringRef Path,
+    std::function<void(llvm::ArrayRef<DirectoryWatcher::Event>, bool)> Receiver,
+    bool WaitForInitialSync) {
+  return llvm::make_error<llvm::StringError>(
+      "DirectoryWatcher is not implemented for this platform!",
+      llvm::inconvertibleErrorCode());
+}
+
+#endif // TARGET_OS_OSX