Background: I’m trying to create OCaml (js_of_ocaml) bindings to the tree-sitter.js library. My repository is at GitHub - joelburget/brr-web-tree-sitter: Ocaml (Brr) bindings to web-tree-sitter.
Question 1: Reading through the opam manual, I don’t see any mention of js_of_ocaml, minimal mention of stubs, and the document assumes architectures are ’ typically one of
"arm64" , or the lowercased output of
uname -m , or
"unknown"'. How does the distribution of js_of_ocaml-specific libraries typically work?
I attempted to add the tree-sitter.js library using dune sites in Work on using dune sites. · joelburget/brr-web-tree-sitter@8354580 · GitHub. Unfortunately this didn’t work, I believe because js_of_ocaml removed the library when linking. Quoting the docs:
Primitive code must be annotated with the primitive name and primitive requirements. The linker uses these information to only include the primitive actually used in the program and to perform better deadcode elimination.
I attempted to fix this in two different ways in https://github.com/joelburget/brr-web-tree-sitter/commit/5fdd6ee72cfebd7c9f26a2dbafefcd3a17f87534:
- Adding a line
joo_global_object.TreeSitter = TreeSitter;to the end of tree-sitter.js. This didn’t have any effect I could see.
external _tree_sitter_fake_primitive : unit -> unit = "tree_sitter_fake_primitive") in.
dune build gives:
Undefined symbols for architecture x86_64: "_tree_sitter_fake_primitive", referenced from: _caml_builtin_cprim in camlobj2b27a0-2f17c0.o
I tried adding
(modes js) to the library, but get “Error: Unknown value js” (I guess this is only available for executables?).