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

Emit C #56

Open
Cre3per opened this issue Jul 22, 2024 · 1 comment
Open

Emit C #56

Cre3per opened this issue Jul 22, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Cre3per
Copy link

Cre3per commented Jul 22, 2024

In addition to C++.
The goal is to support more languages, and many languages have binding generators that consume C.
If it turns out the generated bindings are not user-friendly, we can implement language-specific generators later on.

Usage example

source2gen --emit-language c
@Cre3per
Copy link
Author

Cre3per commented Jul 22, 2024

I'd like to work on this issue

Implementation idea

  • Add a CLI option --emit-language=[cpp,c]
    • Use a CLI parser library
      • Use a portable package manager (conan)
  • Add an interface for generator_t
  • Implement the interface for a cpp and a c generator
  • Add unit tests for the language generators
    • GTest via conan
  • cpp and c generator share common code ("c family")
  • Base classes are represented by a data member ("base")
  • Nested types are prefixed with the name of the enclosing class/namespace
  • Enumerators are prefixed with the name of the enclosing enum

Using libraries and a package maneger increases the build complexity of the project, but the CLI parser can also be used for other options (e.g. to set the game path, and output directory), and having a package manager could make it easier to implement future features.

Conan works on Windows/Mac/Linux and can automatically build libraries from source if no prebuilt binaries are available. New build steps would be

conan install --output-folder build --settings:host build_type=Release .
cmake -S . -B build --preset conan-debug -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DSOURCE2GEN_GAME=CS2
cmake --build build

I don't know if conan is compatible with premake. Why does source2gen use multiple build systems anyway?

Reply by @es3n1n in neverlosecc/source2sdk#23 (comment)

Very nice idea, you can start working on this and we'll be more than happy to merge this, however probably I should first finish my work on #47 (been busy with other stuff, hopefully I can find some free time to work on it 🤞)

Everything from that list sounds awesome, as for the premake - premake is just a legacy stuff we used before so its pretty much a leftover. Feel free to remove it, without doing it scaling the project further would be really painful.

I will close this issue here, please reopen it in https://github.com/neverlosecc/source2gen

@es3n1n es3n1n added the enhancement New feature or request label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants