[WIP] Generate C++ header files from public extern (C++) declarations#8591
[WIP] Generate C++ header files from public extern (C++) declarations#8591ibuclaw wants to merge 7 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request, @ibuclaw! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8591" |
fd44e79 to
2f24603
Compare
|
I would recommend using the Dub package. Also building the new tool as a Dub package. |
wilzbach
left a comment
There was a problem hiding this comment.
Yeah it would save a lot of code in the main method if this would use the DMD dub package.
src/dmd/dtoh.d
Outdated
| "safe.d", "sapply.d", "semantic2.d", "semantic3.d", "sideeffect.d", "statement.d", | ||
| "statementsem.d", "staticassert.d", "staticcond.d", | ||
| "target.d", "templateparamsem.d", "tokens.d", "traits.d", "typesem.d", "typinf.d", | ||
| "utf.d", "utils.d", |
There was a problem hiding this comment.
Can't we use globbing here like we do for the dub package or build.d, s.t. we have less files to update whenever a file gets moved?
There was a problem hiding this comment.
Maybe, this part was carried over from the old PR.
For sure am open to design improvements - the most important part is the blacklisting of certain modules that we retain manual updates for.
| // Generate special static inline function. | ||
| if (cd.isIdentifierClass()) | ||
| { | ||
| buf.writestring(" static inline Identifier *idPool(const char *s) { return idPool(s, strlen(s)); }\n"); |
There was a problem hiding this comment.
Because this doesn't exist in D for obvious reasons.
There was a problem hiding this comment.
Oh I was more asking: shouldn't we do this in a more general-purpose way.
src/dmd/dtoh.d
Outdated
| global.params.isLP64 = global.params.is64bit; | ||
|
|
||
| global.path = new Strings(); | ||
| global.path.push(__FILE_FULL_PATH__.dirName.buildPath("../../../druntime/src/").toStringz()); |
There was a problem hiding this comment.
This is fragile if druntime is checkout out in a different directory (I think the LDC people do this).
There was a problem hiding this comment.
Yes our path is $LDCROOT/runtime/druntime.
|
SemaphoreCI failure is due to the dub package trying to include |
|
Related [1]. Perhaps join forces? [1] https://forum.dlang.org/thread/oikrrejcengbjivsyzws@forum.dlang.org |
|
@TurkeyMan this should be interesting for you. |
|
@jacob-carlborg this differs in that it is not intended to be a general purpose tool. Same as the tool used to convert dmd to D. This handles only dmd specific style and quirks. |
|
Nice job Iain, thanks! |
|
It would be better to make the hard-coded lists and paths command-line / or environment parameters. |
|
What's going on with this? I could really use this like, yesterday. |
|
@TurkeyMan - it's hardly meant for general purpose, there are many special cases that look for dmd-specific code. If it gets used at all, it'll be part of the build process for generating headers that gdc and ldc can include. No need to check what is and isn't in sync. |
|
Right... I want to do an experiment where I define some struct's and functions in D, but they are extern(C++), and the .h file needs to be emit by the D compiler. Is that the goal here? It sounds like the same goal; keeping the C++ headers in sync. |
|
@TurkeyMan I'll do this up as a dub package once #8776 goes in. |
|
Is this still a WIP? |
|
This needs:
It would also be good to have the DMD-specific stuff factored out. |
Yes, as I have done no testing whatsoever against gdc and auto-generated headers. I've been too busy with work on other things to look back at this (you should know what other things are :-) The cxxfrontend tests that are in dmd only cover the surface of the C++ bindings. That the generated header is compilable and the running program passes all tests is promising though. As I've said before, this not meant to be general purpose, I would suggest maybe dpp is better suited for you than this utility tool. |
|
As a general purpose dub-package-to-be: https://github.com/thewilsonator/dtoh N.B. also completely untested. |
dpp is for the other way. |
dpp is the wrong way around; we want to emit Is there a path to making this work general purpose in the way I say? |
For DMDFE as a library so that tools can populate `global.params` correctly. Required for https://github.com/thewilsonator/dtoh the dub package of dlang#8591
Factor out compiler specific parts Attempt to make cross platform
1d2f88b to
9b9e45a
Compare
| } | ||
| // Read the configurarion file | ||
| auto inifile = File(global.inifilename); | ||
| inifile.read(); |
There was a problem hiding this comment.
I think most of this code in this main method could be saved by using DMD's dmd.frontend:
|
There is #9971 now, can this be closed? |
|
If they're willing to take the baton in this relay race. |
|
It's Edi's GSoC project, so he'll be working full-time on this over the next weeks. |
Takes #5082 and converts it into a standalone program.
Still needs a bit of work, documentation, command-line option handling maybe to turn on/off certain parts.
Some bugs that I reported are still present, such as #5082 (comment)
Using the auto-generated header in the C++ unittest works at least.