Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fsevents): allow on older mac sdk's #6218

Merged
merged 2 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
3.5.0 (unreleased)
------------------

- Enable file watching on MacOS SDK < 10.13. (#6218, @rgrinberg)

- Sandbox running cinaps actions starting from cinaps 1.1 (#6176, @rgrinberg)

- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
Expand Down
19 changes: 12 additions & 7 deletions src/fsevents/fsevents_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#include <caml/threads.h>

#if defined(__APPLE__)
#include <Availability.h>
#endif

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
#include <Availability.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>

Expand Down Expand Up @@ -89,9 +87,13 @@ static void dune_fsevents_callback(const FSEventStreamRef streamRef,
if (!(interesting_flags & flags)) {
continue;
}
CFStringRef cf_path;
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
CFDictionaryRef details = CFArrayGetValueAtIndex(eventPaths, i);
CFStringRef cf_path =
CFDictionaryGetValue(details, kFSEventStreamEventExtendedDataPathKey);
cf_path = CFDictionaryGetValue(details, kFSEventStreamEventExtendedDataPathKey);
#else
cf_path = (CFStringRef) CFArrayGetValueAtIndex(eventPaths, i);
#endif
CFIndex len = CFStringGetLength(cf_path);
CFIndex byte_len;
CFIndex res =
Expand Down Expand Up @@ -152,7 +154,9 @@ CAMLprim value dune_fsevents_create(value v_paths, value v_latency,

const FSEventStreamEventFlags flags =
kFSEventStreamCreateFlagNoDefer |
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
kFSEventStreamCreateFlagUseExtendedData |
#endif
kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagFileEvents;

dune_fsevents_t *t;
Expand Down Expand Up @@ -316,7 +320,9 @@ static const FSEventStreamEventFlags all_flags[] = {
kFSEventStreamEventFlagOwnEvent,
kFSEventStreamEventFlagItemIsHardlink,
kFSEventStreamEventFlagItemIsLastHardlink,
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
kFSEventStreamEventFlagItemCloned,
#endif
};

CAMLprim value dune_fsevents_raw(value v_flags) {
Expand All @@ -338,8 +344,7 @@ CAMLprim value dune_fsevents_available(value unit) {

#else

static char *unavailable_message =
"fsevents is only available on macos >= 10.13";
static char *unavailable_message = "fsevents is only available on macos";

CAMLprim value dune_fsevents_stop(value v_t) {
caml_failwith(unavailable_message);
Expand Down