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

Fix/bootstrap update #1904

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

duckdoom5
Copy link
Contributor

@duckdoom5 duckdoom5 commented Feb 3, 2025

  • Fixes the bootstrap code generator and updates the generated source and bindings for the new generated source
  • Introduces a workflow that allows you to update the parser bindings by building with the old source and hot patching it before the source is parsed so we can live update the bindings.
    • Might be an idea to automatically build and run these now as well
  • Some additional code cleanup is included

Depends on these PRs to fix the bootstrap codegen:

Note that these are included in the current PR. I'll rebase this PR and remove the draft marker once each is merged

@duckdoom5 duckdoom5 marked this pull request as draft February 3, 2025 21:39
@duckdoom5
Copy link
Contributor Author

duckdoom5 commented Feb 3, 2025

@tritao I'll just leave this here since then I can provide a bit of context. I've made these changes when I was working on this and just converted them into individual PR's.
I'll add tests to those requested and some might need a little bit of love :)

@duckdoom5
Copy link
Contributor Author

Also, I've continued using the 'old' method here, but I assume we could also update the bootstrap source generator to use the newer methods right?

@duckdoom5 duckdoom5 force-pushed the fix/bootstrap-update branch 2 times, most recently from 450c4a9 to 172b319 Compare February 3, 2025 22:25
@tritao
Copy link
Collaborator

tritao commented Feb 3, 2025

Also, I've continued using the 'old' method here, but I assume we could also update the bootstrap source generator to use the newer methods right?

Can you clarify what you mean by this?

@duckdoom5
Copy link
Contributor Author

duckdoom5 commented Feb 3, 2025

Yeah I mean like the way types are mapped, ignored and renamed and such.
For example the ParserGen is using a more 'modern' API with the generator passes and ctx.RenameNamespace and other helper functions etc.

@duckdoom5
Copy link
Contributor Author

duckdoom5 commented Feb 3, 2025

Btw, I have a question about the requirements on generated source. What promises are we making about the language version of the generated source? I kinda want to look into modernizing the output (like inline field initialization instead of using a constructor, which can then be marked = default etc.)

@tritao
Copy link
Collaborator

tritao commented Feb 3, 2025

Ah yes, I see what you mean now. I guess both approaches can have their pros/cons, but if you think the other approach is preferable and more readable here, feel free to go for it.

And overall really amazing work on this, everything looks great, think it should be ready to merge when all the dependencies are in.

@tritao
Copy link
Collaborator

tritao commented Feb 3, 2025

Btw, I have a question about the requirements on generated source. What promises are we making about the language version of the generated source? I kinda want to look into modernizing the output (like inline field initialization instead of using a constructor, which can then be marked = default etc.)

There is no formal promise I guess, but if it compiles in the supported CI environments, then it should be fine. Windows CI action is on 17.12.35707.178, which seems to be pretty recent. Personally I am not on using Windows lately, but it would probably be reasonable to keep compatibility with a somewhat older release too.

@duckdoom5
Copy link
Contributor Author

@tritao So quick question; Can I convert Parser.cpp's AST walking with clang's build-in ASTNodeTraverser?

Seems like it would avoid many of the issues we're facing now

@tritao
Copy link
Collaborator

tritao commented Feb 7, 2025

@tritao So quick question; Can I convert Parser.cpp's AST walking with clang's build-in ASTNodeTraverser?

Seems like it would avoid many of the issues we're facing now

I think that would be great, I don't think it was available at the time that code was written, so we had to come up with our own traversing solution, but nowadays re-using Clang's would definitely be the way to go.

@duckdoom5
Copy link
Contributor Author

Awesome, thought as much. I'll get on that then :)

@tritao
Copy link
Collaborator

tritao commented Feb 7, 2025

Also now that we have the bootstrap tool up-to-date, I wonder if it could be used to also generate the code for using ASTNodeTraverser.

@duckdoom5
Copy link
Contributor Author

Yeah, I was thinking the same. But I think I'll first get it working by coding it manually and then see if there's a way to generate that

@duckdoom5
Copy link
Contributor Author

duckdoom5 commented Feb 8, 2025

Okay, I'll change that plan a bit.

I've made a start now and have a plan of attack so I know what I need/want. I think I'll just get commit #1900 working with a small compromise and then get this PR merged as well.

That should allow me to at least work with that updated. Then I might just generate some of that code to reduce the workload. I think what I should do then, is first get the current version fully auto generated and then get to the AST node traverser update (since it's quite a bit of code to write XD)

@duckdoom5 duckdoom5 marked this pull request as ready for review February 8, 2025 22:42
@duckdoom5 duckdoom5 force-pushed the fix/bootstrap-update branch 3 times, most recently from 36a5157 to 1ac1add Compare February 8, 2025 23:11
@tritao
Copy link
Collaborator

tritao commented Feb 12, 2025

Is this ready to go now?

@duckdoom5
Copy link
Contributor Author

No not quite. I noticed there's a build error that didn't popup locally. It's because CI builds the csharp bindings while local windows uses c++/cli.

For the past 3 days I was working on getting that fixed, but I'm having trouble with getting those bindings to generate properly.

@tritao
Copy link
Collaborator

tritao commented Feb 12, 2025

I would be fine with just switching everything to C# bindings, if that makes it any easier.

@duckdoom5
Copy link
Contributor Author

duckdoom5 commented Feb 12, 2025

No it's the other way around. The c++/cli code works great, but the c# p/invoke (std) bindings have build errors currently

D:\a\CppSharp\CppSharp\src\CppParser\Bindings\CSharp\x86_64-pc-win32-msvc-d\CppSharp.CppParser.cs(40217,42): error CS0234: The type or namespace name 'Optional' does not exist in the namespace 'Std' (are you missing an assembly reference?) [D:\a\CppSharp\CppSharp\src\CppParser\Bindings\CSharp\CppSharp.Parser.CSharp.csproj]
D:\a\CppSharp\CppSharp\src\CppParser\Bindings\CSharp\x86_64-pc-win32-msvc-d\CppSharp.CppParser.cs(40512,42): error CS0234: The type or namespace name 'Optional' does not exist in the namespace 'Std' (are you missing an assembly reference?) [D:\a\CppSharp\CppSharp\src\CppParser\Bindings\CSharp\CppSharp.Parser.CSharp.csproj]
D:\a\CppSharp\CppSharp\src\CppParser\Bindings\CSharp\x86_64-pc-win32-msvc-d\CppSharp.CppParser.cs(41103,42): error CS0234: The type or namespace name 'Optional' does not exist in the namespace 'Std' (are you missing an assembly reference?) [D:\a\CppSharp\CppSharp\src\CppParser\Bindings\CSharp\CppSharp.Parser.CSharp.csproj]

@duckdoom5 duckdoom5 force-pushed the fix/bootstrap-update branch 4 times, most recently from 637e43c to f600234 Compare February 18, 2025 14:21
@duckdoom5 duckdoom5 force-pushed the fix/bootstrap-update branch from f600234 to 67aabd0 Compare February 18, 2025 14:27
@duckdoom5 duckdoom5 force-pushed the fix/bootstrap-update branch from 67aabd0 to a2f5b3b Compare February 18, 2025 23:15
@duckdoom5 duckdoom5 force-pushed the fix/bootstrap-update branch from f990cd5 to de6fec4 Compare February 22, 2025 10:22
@duckdoom5 duckdoom5 force-pushed the fix/bootstrap-update branch from 11e75d8 to eb3c54a Compare February 22, 2025 10:42
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

Successfully merging this pull request may close these issues.

2 participants