Skip to content
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

Support for dynamic loading ? #38

Open
EricGrange opened this issue Sep 11, 2024 · 7 comments
Open

Support for dynamic loading ? #38

EricGrange opened this issue Sep 11, 2024 · 7 comments

Comments

@EricGrange
Copy link

Current headers are converted to static bindings (with optional "delayed").

Would it be possible to have an option to generate dynamic bindings instead ? (with GetProcAddress, etc)

The use case would not be just to survive a dll not being present, but also allow the dll name and path to be specified.

@jarroddavis68
Copy link
Contributor

Click the post process button and click the help. I added a PP command to do just that. I hope to submit a PR at some point with all my fixes and enhancements since the last update. Sorting through some corner cases.

@EricGrange
Copy link
Author

@jarroddavis68 yes, that's one way I was looking at it (but doing it directly in small Delphi executable)
Did you publish your PP command ?

@jarroddavis68
Copy link
Contributor

jarroddavis68 commented Sep 11, 2024

image
CreateDynamicImport(0)
this post processing command will create:
image

image

then you can call GetExports in your own code to dynamically load. This is in now. You will run into a few issues that a future PR will address, but it does work.

@EricGrange
Copy link
Author

Thanks!

FWIW use case is for webgpu.h (https://github.com/EricGrange/Delphi-WebGPU) where you have several implementations, and each implementation regularly churns out builds, so plenty of "compatible" dlls to choose from :)

@EricGrange
Copy link
Author

Hmm, the "CreateDynamicImport(0)" in Post process doesn't seem to have any effect ?
Though I'm not even sure the post process script is executed at all (a lone SaveToFile doesn't create anything AFAICT and there is no error when placing garbage in the pp script)

@jarroddavis68
Copy link
Contributor

jarroddavis68 commented Sep 12, 2024

post processing will effect this output:
image

here is a build with all the PP changes I've made since the release that you have:
Chet.zip | VirusTotal Report

So, the script processing is basic, enough to get the job done. If the script command is mispelled and/or not in the correct format, it will just be silently ignored. For example, if you add a ; at the end, like I tend to do at times, that command will be ignored. So, if it does not seem to be working, check the syntax and make sure it's correct.

@EricGrange
Copy link
Author

@jarroddavis68 with your build this worked, thanks.

As a small side-request, maybe the post-processing should appear in the translate log ? Currently it's not mentioned, and if the PP script contains invalid commands, there is no error reported either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants