mmomtchev / libnode

Current libnode packages for Ubuntu and Debian
MIT License
9 stars 1 forks source link

Missing libv8.so and friends #1

Open rubenlg opened 1 year ago

rubenlg commented 1 year ago

Thanks for maintaining these packages, super useful, especially since Ubuntu ships a particularly old versions of V8 (and node) libraries.

Would it be possible to provide V8 library files? It could be just a bunch of symlinks to libnode.so just like the official Ubuntu package does as well. Without that file it's hard to compile V8 dependencies such as v8pp which looks for a libv8.so and libv8_libplatform.so and fails to find them, aborting compilation.

I list here all the libraries that the official package includes that are just symlinks. I checked that by adding these manually, v8pp compiles correctly.

libv8_libbase.so -> libnode.so
libv8_libplatform.so -> libnode.so
libv8_libsampler.so -> libnode.so
libv8.so -> libnode.so

Actually, for v8pp I only need two of them, but other dependencies might need others, so it would be a good idea to have parity with the official Ubuntu package.

Thank you!

mmomtchev commented 1 year ago

The whole point of NAPI embedding is that is a single-point entry into JS - v8pp completely defeats its purpose. What do you need it for, NAPI should provide everything it has?

rubenlg commented 1 year ago

Thanks for the fast response!

The reason I use v8pp is the convenience of creating Javascript bindings for my existing C++ APIs. Rather than writing a ton of repetitive code for each constructor, property and method of your classes, you write something like this:

v8pp::class_<Vec3> Vec3_class(vm);
  Vec3_class.ctor<double, double, double>(); // Constructor disambiguation
  Vec3_class.var("x", &Vec3::x); // Regular property
  Vec3_class.var("y", &Vec3::y);
  Vec3_class.var("z", &Vec3::z);
  Vec3_class.function("length", &Vec3::length); // Method

The library uses template metaprogramming to automatically generate all the V8 code to wrap and unwrap values. I have to create bindings for a significant API surface that is going to be changing frequently for a while, and v8pp makes that process much simpler and less error-prone. The compiler tells me when I forgot to update some binding, rather than a Segmentation Fault at runtime :disappointed: I've seen that NAPI slightly simplifies the binding creation process w.r.t. V8, but it's still way more boilerplate than the v8pp approach.

Forking v8pp to work with NAPI should be possible, but also a very significant project... It's very likely I won't need (or want) node at all. V8 alone should be way easier to port to my target platforms since it interacts very little with the OS. But that's just a concern when I release the binary, during development it's fine to link against libnode.

Feel free to close this bug if you think adding these links to the .deb packages is a bad idea. I will continue using your packages anyway since they are super useful (creating the links myself).