-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable extras/module-node
and examples/debug-trans-socket
to be used in DLLs
#2020
base: master
Are you sure you want to change the base?
Conversation
Bump. Something wrong with this PR? Since Duktape is DLL-ready then it seems reasonable to make at least Node-style modules ready too. |
The main thing is that those visibility macros are not intended for external use. |
Also setting |
One approach would be to intentionally expose the visibility symbols as part of the documented API so that calling code could rely on them with versioning guarantees. That would eliminate the need to force |
I guess different export/import macros could be used for non-duktape.c sources. As long as required symbols can be exported from a DLL then it should be fine. |
Looking at the definition of
I'm not sure what would be a clean solution. Suppose for example that a file wanted to simultaneously call Duktape API (import symbols) and declare externally visible DLL symbols (export symbols); no single |
Also, any library that wants to use a certain header file both when compiling the library itself (export) and the calling code (import) will need to distinguish the compilation context using something similar to So maybe Duktape headers could provide explicit
This is pretty much what Duktape does itself in Not sure if this is clean enough though? |
Yes, in the case you described separate macros would be needed. The solution you proposed seems to be the standard practice and the way to go. One more thing worth considering is users that already might be using these extra features (e.g Node modules) by directly jamming them in their custom build targets (i.e. linking against pre-built When I made my changes I figured that these extra features could be treated as optional, but standard extensions to Duktape's core functionality. That's why I re-used existing macros. But your concerns are valid if you want to keep separation between the core and extensions. Separate macros would definitely be a cleaner approach. |
That's definitely a goal, the examples/extras could be moved to separate repos and should function as normal calling code from Duktape perspective. |
When deploying Duktape as a DLL it is sometimes useful to bundle some extra functionality, compared to what vanilla
duktape.h
provides. In my case I wanted to be able to deployduktape.dll
with support for Node.js modules and debugging out of the box . However, it seems that these extra modules are not ready to be used that way because of missing__declspec
specifiers.I understand I could put these modules in separate DLLs (like
duktape-module-node.dll
etc), but it seems a bit overkill, and even then I would need to resolve__declspec
specifiers, which would require me to modify sources that come with Duktape, which isn't perfect from maintenance perspective.