charto / nbind

:sparkles: Magical headers that make your C++ library accessible from JavaScript :rocket:
MIT License
1.98k stars 120 forks source link

Linking directly to nbind.node #105

Closed BotellaA closed 4 years ago

BotellaA commented 6 years ago

I have another (maybe silly) question about nbind.

Could it be possible to compile nbind sources alone in a nbind.node and then link my libraries with it? Should it works or is there something to do with node addon linking?

Thanks

jjrv commented 6 years ago

Most of the code in nbind is template metaprogramming, generating code at compile time based on declarations in your libraries. What you suggest might be possible, but you'll need to put the NBIND_CLASS macros in separate files (because they need to be compiled together with nbind) and you might have to tweak the linking to get it working.

BotellaA commented 6 years ago

If using nbind with several libraries becomes possible, this feature could be very nice.

BotellaA commented 6 years ago

It is starting to work. I have copy and paste the v8/Binding.cc code inside each of my nbind addons. The goal is to have the NBIND_CLASS of NBind and to call a NODE_MODULE with the same initModule.

Could it be possible to separate the NBind class implementation from the remaining of the file? My idea is to compile nbind alone and only add in my addons the v8/Binding.cc file without NBind class implementation. This should simplify a lot the creation of nbind addon.