Is it possible to release a package without easily exposing the source code? In my use case, my package is a library where the user must provide callback functions as input. Most of the ideas I found seem to apply only to applications, as in How to build closed-source julia package?
From the PackageCompiler.jl docs, it seems that I could compile the code to a C library and create a wrapper that calls the C library from Julia, but it doesn’t seem feasible to pass functions to the C library.
Is it possible to do what I’m trying? Am I having any misconception?
Passing Julia function pointers as an input for C functions is technically possible with some limitations, but that’s for Julia embedded in C or ccall-ing a C function. No idea if that can work for a @ccallable function as smoothly as a normal higher-order Julia function, and the @cfunction macro would likely constrain how users handle their callback functions.
There’s a good discussion and examples here (for dynamic libraries) that I recently used. The basic approach is to create the Julia function, then generate a pointer to it with @cfunction, then get a the global for the symbol you’ve assigned the result to, and that is the pointer to the function in a C callable form.