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

Add support for C3 to bindgen #1148

Merged
merged 1 commit into from
Feb 10, 2025
Merged

Add support for C3 to bindgen #1148

merged 1 commit into from
Feb 10, 2025

Conversation

radekm
Copy link
Contributor

@radekm radekm commented Nov 12, 2024

I thought bindgen support for C3 language could be useful, so I created this PR.

Unfortunately I haven't yet ported examples to C3 and have tested it only on macOS arm64.

Generated code can be browsed in my repository https://github.com/radekm/sokol-c3/

@floooh
Copy link
Owner

floooh commented Nov 12, 2024

Looks like there's a python error in gen_c3.py:

https://github.com/floooh/sokol/actions/runs/11796284494/job/32872697466?pr=1148#step:9:9

@radekm
Copy link
Contributor Author

radekm commented Nov 12, 2024

Oh my, you're right, I somehow managed to use Python 3.12 feature which doesn't work in older Pythons (specifically using single quotes inside single-quoted f-string).

@radekm
Copy link
Contributor Author

radekm commented Nov 13, 2024

I have fixed CI (at least in my repo) by adding checkout of radekm/sokol-c3 into .github/workflows/gen_bindings.yml.

@floooh
Copy link
Owner

floooh commented Nov 13, 2024

Oki, before merging C3 support, I'd like to get to a similar state as https://github.com/floooh/sokol-zig, e.g. a repository for the bindings, at least a handful examples ported, and an easy way to build the examples.

Should I create a repo under floooh/sokol-c3, and you could populate that?

@radekm
Copy link
Contributor Author

radekm commented Nov 14, 2024

Should I create a repo under floooh/sokol-c3, and you could populate that?

Sounds great! Yes, please create the repo.

@floooh
Copy link
Owner

floooh commented Nov 14, 2024

Ok see: https://github.com/floooh/sokol-c3

I added you as collaborator so you can push directly (I think Github will send you an invite email). Later we should probably both work through PRs instead of committing directly to main.

I also added your name to the LICENSE file.

Once everything is setup I will add the code to the sokol CI pipeline to automatically update and push changes.

@floooh
Copy link
Owner

floooh commented Nov 30, 2024

Hi @radekm what's the state of the PR, is it ready to merge or should I wait a bit more?

There's a curious CI error in the sokol-c3 repo:

https://github.com/floooh/sokol-c3/actions/runs/12096168226/job/33730154985

...any ideas what this is about? If it is some sort of Mac-specific C3 compiler error or regression we can out-comment the Mac build from the CI build matrix for now (I've seen similar stuff in the past in other languages when ARM Macs were new-ish).

.github/workflows/gen_bindings.yml Outdated Show resolved Hide resolved
bindgen/README.md Outdated Show resolved Hide resolved
@radekm
Copy link
Contributor Author

radekm commented Nov 30, 2024

Hi, I think I’ll need a few more weeks. Before merging, I want to ensure that everything is in good shape and makes sense:

  • First, I’d like to port more examples from other languages to C3.
    These examples help me test C3’s code generation in the shader compiler.

  • Second, you’re right - there’s currently an issue where some examples don’t compile on macOS arm64.

    This is due to a bug in the latest version of the C3 compiler (type_int_unsigned_by_bitsize fails with illegal bitsize on arm64 c3lang/c3c#1649),
    which I discovered yesterday. It’s already fixed in the master branch, but I’d prefer to wait
    for the next official release of the compiler before proceeding.

  • Third, I plan to ask some members of the C3 Discord community
    to review the code and possibly test it to ensure everything works as expected.

I’ll let you know as soon as it’s ready for merging. Thanks for your patience!

@floooh
Copy link
Owner

floooh commented Dec 1, 2024

Oki doki, then I'll move to something else in the meantime. I'll keep an eye on the Github notifications to check if there's something to review or merge. If I don't react just explicitly 'at' me :)

@floooh
Copy link
Owner

floooh commented Jan 13, 2025

I wonder if it makes sense to wait with merging floooh/sokol-tools#158 until this PR is ready. Do you have a general ETA? :)

@radekm
Copy link
Contributor Author

radekm commented Jan 26, 2025

I'll try to finalize everything during the next week. Till now I have been testing it in a small ImPlot visualization and it works like a charm. Today I have just updated everything and I would like to quickly retest it.

@floooh
Copy link
Owner

floooh commented Jan 26, 2025

No pressure ;)

@radekm
Copy link
Contributor Author

radekm commented Feb 2, 2025

I've added the test-c3 CI job and updated the README in sokol-c3. I believe it's ready for review.

@floooh
Copy link
Owner

floooh commented Feb 3, 2025

Oki doki, I'll try to do a thorough review, but it might be until next weekend before I can put the proper time into it.

@floooh
Copy link
Owner

floooh commented Feb 9, 2025

Starting to look into your C3 PRs now (the other smaller pending PRs took a bit longer than expected).

I'm planning to use my M1 Mac for testing (at least a c3 hello-world works).

@floooh
Copy link
Owner

floooh commented Feb 9, 2025

Your samples in https://github.com/floooh/sokol-c3 all work nicely and out of the box :) (actually pretty cool that the C library compilation 'just works' - I guess via that manifest.json magic...) - I want to take my time reviewing the bindings and sokol-tools PR though, but I guess an ETA of tomorrow evening is realistic :)

@floooh floooh merged commit 4395d06 into floooh:master Feb 10, 2025
35 checks passed
@floooh
Copy link
Owner

floooh commented Feb 10, 2025

Ok, merged. Now I will add a deploy-c3 step into gen_bindings.yml so that https://github.com/floooh/sokol-c3 is automatically updated...

@floooh floooh changed the title [WIP] Add support for C3 to bindgen Add support for C3 to bindgen Feb 10, 2025
@floooh
Copy link
Owner

floooh commented Feb 10, 2025

Ok, the first automatic commit to sokol-c3 :)

floooh/sokol-c3@ac48c0b

I also updated the changelog (floooh/sokol-c3@ac48c0b), and updated the readme (sokol-c3 build badge and added link to https://github.com/floooh/sokol-c3 to the list of language bindings.

Many thanks! :)

Going forward I would suggest:

  • feel free to continue pushing fixes directly to the sokol-c3 repo, for bigger changes I would suggest to still go through a pull request (you don't need to wait for me doing code reviews though, if you want that, please mention that specifically in the PR)
  • for fixes to the bindgen scripts, just go through a usual PR, and if I somehow miss that, please 'at' me until I react ;)

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