Revive Generate C++ header files from public extern (C++) declarations #9971
Revive Generate C++ header files from public extern (C++) declarations #9971edi33416 wants to merge 44 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @edi33416! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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#9971" |
|
Bootstrapping is an issue now - we need to compile the compiler before using it to generate the headers. @edi33416 please make sure the compiler does not need the headers. |
|
I guess the same comments that were made in the original PR apply here as well. |
That is no concern. D already requires a host D compiler (>= 2.079) to be built and has no dependence on C++ anymore. |
|
As far as I'm aware, no testing of this has been done beyond the cxxfrontend unittests, which only covers a small amount of the actual use of the c++ api. So integration with gdc and ldc - as well as bootstrapping - would also be required as a preliminary requirement. Secondly, we should have a way to red flag any prs that modify the output of the c++ headers, so that extra checking can be done to verify its correctness. |
|
|
||
| diff -pu --strip-trailing-cr ${EXTRA_FILES}/${TEST_NAME}.out ${OUTPUT_BASE}.out | ||
|
|
||
| rm -f ${OUTPUT_BASE}.out |
There was a problem hiding this comment.
Is there really a need for removing this file? Might be useful for debugging when the test failed?
There was a problem hiding this comment.
The test suite will complain if any files are left over with the shell tests (which I despise). Also this should be made in to a D test rather than a shell one. The less shell tests the better.
There was a problem hiding this comment.
No it won't. It will only complain if the files aren't placed in the test_results directory.
| //} | ||
|
|
||
| /**************************************************** | ||
| */ |
This could be done by simply checking in the generated DMD frontend C++ headers into the source code and in one CI checking whether the output has been changed. This way all future changes to the C++ headers will be visible and I'm sure we can either make the test work with |
|
Let's make this PR happen people! |
|
The initial version could be limited to the test suite without the changes to existing C++ headers/Tests. That would yield a much smaller change and avoid breaking stuff while being WIP. |
The -HC switch let's dmd output header files from existing extern(C++) files to ease C++ interoperation. Use -HCd=<directory> / -HCf=<file> to select the directory/file where the header should be generated. The following commits were squashed from dlang#9971 without the changes to the existing C++ interface/test suite: Testing D to H tool Remove unused and redundant dmd headers Improve dtoh Factor out compiler specific parts Attempt to make cross platform Fix stuff Add dtoh as a compiler switch Update code after rebase Compile frontend srcs and write to flie Add dtoh enum test Add free functions dtoh test Add unittest block dtoh test Add VarDeclaration dtoh test Add AliasDeclaration dtoh test Add AnonDeclaration dtoh test Add StructDeclaration dtoh test Add ClassDeclaration dtoh test Add TemplateDeclaration dtoh test Add debug prints Fix struct field void initializer Add ignoredModule tmp helper Add tmp workaround for alias forward decl and >> template issue Add support for enum base type Add support for alignment of pow2 Fix alignment issues Generate enums based on -extern-std version Update tool auto-gen message Update tests Code cleanup CPP does not support covariant const methods Correctly write ctor declarations Generate default args for literals Generate dtor and copy ctor declarations Rebase with master Add compiler switch to cli.d Update tests Add support for @disable Improve default ctor generation Update struct decl test Use member initializer list for default ctor definition Co-Authored-By: Eduard Staniloiu <edi33416@gmail.com> (Rebase + Fixup) Co-Authored-By: MoonlightSentinel <moonlightsentinel@disroot.org>
The -HC switch let's dmd output header files from existing extern(C++) files to ease C++ interoperation. Use -HCd=<directory> / -HCf=<file> to select the directory/file where the header should be generated. The following commits were squashed from dlang#9971 without the changes to the existing C++ interface/test suite: Testing D to H tool Remove unused and redundant dmd headers Improve dtoh Factor out compiler specific parts Attempt to make cross platform Fix stuff Add dtoh as a compiler switch Update code after rebase Compile frontend srcs and write to flie Add dtoh enum test Add free functions dtoh test Add unittest block dtoh test Add VarDeclaration dtoh test Add AliasDeclaration dtoh test Add AnonDeclaration dtoh test Add StructDeclaration dtoh test Add ClassDeclaration dtoh test Add TemplateDeclaration dtoh test Add debug prints Fix struct field void initializer Add ignoredModule tmp helper Add tmp workaround for alias forward decl and >> template issue Add support for enum base type Add support for alignment of pow2 Fix alignment issues Generate enums based on -extern-std version Update tool auto-gen message Update tests Code cleanup CPP does not support covariant const methods Correctly write ctor declarations Generate default args for literals Generate dtor and copy ctor declarations Rebase with master Add compiler switch to cli.d Update tests Add support for @disable Improve default ctor generation Update struct decl test Use member initializer list for default ctor definition Co-Authored-By: Eduard Staniloiu <edi33416@gmail.com> (Rebase + Fixup) Co-Authored-By: MoonlightSentinel <moonlightsentinel@disroot.org>
The -HC switch let's dmd output header files from existing extern(C++) files to ease C++ interoperation. Use -HCd=<directory> / -HCf=<file> to select the directory/file where the header should be generated. The following commits were squashed from dlang#9971 without the changes to the existing C++ interface/test suite: Testing D to H tool Remove unused and redundant dmd headers Improve dtoh Factor out compiler specific parts Attempt to make cross platform Fix stuff Add dtoh as a compiler switch Update code after rebase Compile frontend srcs and write to flie Add dtoh enum test Add free functions dtoh test Add unittest block dtoh test Add VarDeclaration dtoh test Add AliasDeclaration dtoh test Add AnonDeclaration dtoh test Add StructDeclaration dtoh test Add ClassDeclaration dtoh test Add TemplateDeclaration dtoh test Add debug prints Fix struct field void initializer Add ignoredModule tmp helper Add tmp workaround for alias forward decl and >> template issue Add support for enum base type Add support for alignment of pow2 Fix alignment issues Generate enums based on -extern-std version Update tool auto-gen message Update tests Code cleanup CPP does not support covariant const methods Correctly write ctor declarations Generate default args for literals Generate dtor and copy ctor declarations Rebase with master Add compiler switch to cli.d Update tests Add support for @disable Improve default ctor generation Update struct decl test Use member initializer list for default ctor definition Co-Authored-By: Eduard Staniloiu <edi33416@gmail.com> (Rebase + Fixup) Co-Authored-By: MoonlightSentinel <moonlightsentinel@disroot.org>
The -HC switch let's dmd output header files from existing extern(C++) files to ease C++ interoperation. Use -HCd=<directory> / -HCf=<file> to select the directory/file where the header should be generated. The following commits were squashed from dlang#9971 without the changes to the existing C++ interface/test suite: Testing D to H tool Remove unused and redundant dmd headers Improve dtoh Factor out compiler specific parts Attempt to make cross platform Fix stuff Add dtoh as a compiler switch Update code after rebase Compile frontend srcs and write to flie Add dtoh enum test Add free functions dtoh test Add unittest block dtoh test Add VarDeclaration dtoh test Add AliasDeclaration dtoh test Add AnonDeclaration dtoh test Add StructDeclaration dtoh test Add ClassDeclaration dtoh test Add TemplateDeclaration dtoh test Add debug prints Fix struct field void initializer Add ignoredModule tmp helper Add tmp workaround for alias forward decl and >> template issue Add support for enum base type Add support for alignment of pow2 Fix alignment issues Generate enums based on -extern-std version Update tool auto-gen message Update tests Code cleanup CPP does not support covariant const methods Correctly write ctor declarations Generate default args for literals Generate dtor and copy ctor declarations Rebase with master Add compiler switch to cli.d Update tests Add support for @disable Improve default ctor generation Update struct decl test Use member initializer list for default ctor definition Co-Authored-By: Eduard Staniloiu <edi33416@gmail.com> (Rebase + Fixup) Co-Authored-By: MoonlightSentinel <moonlightsentinel@disroot.org>
|
Yes, though I will let Edi close or update his PR as it contains a few more things. Most importantly the setup to emit the header files for DMD itself |
|
I'm gonna close this since the superseded #10801 got merged and since then it was continuously improved. If any of the features in this PR are needed, the PR is already linked to the one that got in. |
This PR takes #8591, rebases with master and converts it into a compiler switch.
This is a separate PR as I don't have the rights to push to existing dmd PRs.
Credit to @ibuclaw for the actual work.