-
Notifications
You must be signed in to change notification settings - Fork 146
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
Update for Clang 6 and .NET standard #21
Conversation
a8803fd
to
239c07d
Compare
I have begun to translate some of the upstream These tests need to be checked on Windows too as I suspect Unicode will be broken there, I believe Clang uses UTF8 everywhere but currently the string encoding is not specified in code. On Linux/MacOS this works as .NET Core defaults to UTF8 there, however on Windows it'll default to ANSI which is likely to break. It would be nice to get Travis-CI/AppVeyor running the tests too unless you have any preferred testing infrastructure. |
Looks like switching to It would be nice though unnecessary to check the comment associated for I am also not sure why @blue3k removed |
534522e
to
dec3e84
Compare
c59820c
to
91686a6
Compare
Exclude functions that are manually defined in Generated.Custom.cs
Looking at the elaborated type change in #15 and #16 a little further it appears the approach there is incorrect. I think |
@benpye Thanks for the overhaul work here. Can you explain why the Generated.Custom.cs is no longer needed? I'll take a look at this again tomorrow and merge it in if I don't have any additional questions. |
I have removed nthe duplicate copy of Generated.cs and Generated.Custom.cs and instead added a dependency on the ClangSharp library. As the latest of each of those files is checked in under that directory with each commit anyway it should be able to bootstrap the generator. The only time an issue might arise is if a broken Generated.cs is written, but in that case it should be possible to use Git to revert to the last good version. This change ensures that the latest version is used with the generator which can acts as a test, before now it looks like the version in the generators code has been allowed to fall behind. |
@benpye Hi! I'm trying to use this branch... which version of libclang are you using? Using libclang.dll from the pre-compiled x64 LLVM for Windows, ClangSharpPInvokeGenerator generates |
That's interesting. I have generated on Ubuntu 18.04 with libclang 6.0. I'm a little surprised that symbol is different on Windows, if I get a chance I'll have a look but I probably won't be able to for the next couple weeks as I have exams coming up. It looks like the enum difference is also due to platform differences. |
I don't have an 18.04 on hand, but libclang-6.0-dev on 16.04 (from |
* Update build.bat to match build.sh * Add heuristic for typedefs-in-system-headers detection, fixes size_t issue * Force newlines to be Unix (to avoid crazy git diffs) * Update the generated file * Make VFO test OS-agnostic * Fix string marshalling since clang uses utf-8; add regression tests. * Add editorconfig, set newlines/charset everywhere, add .vs to gitignore * Don't print extra white space at the end of struct fields * Use dotnet msbuild to build ClangSharp instead of platform-specific scripts * Force ints for enums if possible, for cross-plat * Fix interpretation of typedefs, for cross-plat
@mjsabby I would love this PR to land here. Do you know when you will be able to merge it? |
@xoofx I just finishing landing a similar change in LLVMSharp. I intend to finish this before Saturday. |
The change has landed, thanks @benpye @SolalPirelli @amaitland A few annoyances remain:
|
There is also another one that I'm ok with for now since the PR had lots of goodness: The Custom String Marshaller. It adds a dependency on this type which is odd for a code-generator. @SolalPirelli I saw your fix, I'm hoping we can make it more robust. For (3) yes but we need build support in the repo. |
I have some time to work on improving this library, since I'd like to use it for a project of mine. @mjsabby re: the custom marshaller:
|
This PR updates for Clang 6 and .NET standard. I have taken some commits from PRs
#16 and#18 .I have moved the projects to .NET standard targets and updated the build.sh build script, though I haven't updated build.bat as of yet. I don't know if it makes sense to keep the
mono
build method or move entirely to thedotnet
CLI.I have also moved the
ClangSharp
project so that the simple wildcard.csproj
can be used, otherwise the files fromClangSharpPInvokeGenerator
would also be taken.This is a WIP as I believe we should be able to do away with the string wrapper methods introduced in 86aa75f by using a custom marshaller, as far as I can tell using the
[return: MarshalAs(UnmanagedType.LPStr)]
annotation will result in the string being deallocated, which I believe Clang does not expect as the returns appear to all beconst char *
.EDIT: Should now work with edc14c5
I also wonder why two versions of
Generated.cs
,Generated.Custom.cs
andExtensions.cs
are kept? Is there any reason we don't use the version in the library for the generator? It would seem better to use the newer versions as it ensures that the library is functional. It could be a useful automated test to ensure that the files present are the same as the files generated.EDIT: Check b4662c0 for this. Should always keep a working version in the repo for self-hosting but it means that the generated version will be tested by building again which is useful. This still isn't an automated test however.