fix: exclude APIs that dup given file descriptors from WASI builds

WASI doesn't support `dup(2)` system call, so we cannot implement the
`print_dot_graph` and `print_dot_graphs` functions with exactly the same
semantics as in other platforms.

(cherry picked from commit 94a8262110)
This commit is contained in:
Yuta Saito 2024-07-18 15:14:10 +09:00 committed by Amaan Qureshi
parent d10308528d
commit bf094bd98a
3 changed files with 15 additions and 6 deletions

View file

@ -148,7 +148,7 @@ void ts_tree_print_dot_graph(const TSTree *self, int fd) {
fclose(file);
}
#else
#elif !defined(__wasi__) // WASI doesn't support dup
#include <unistd.h>
@ -162,4 +162,11 @@ void ts_tree_print_dot_graph(const TSTree *self, int file_descriptor) {
fclose(file);
}
#else
void ts_tree_print_dot_graph(const TSTree *self, int file_descriptor) {
(void)self;
(void)file_descriptor;
}
#endif