FosterFramework / Foster

A small C# game framework
MIT License
450 stars 37 forks source link

Investigate Action to build native Platform libs #13

Closed NoelFB closed 1 year ago

NoelFB commented 1 year ago

Right now I manually build the native Platform libs for Linux/Windows (and in theory MacOS but so far I have not), and then they're included in the repo directly. I like having them in the repo because it doesn't require downloading, building, or copying library files around when someone freshly clones the project.

However, this does mean that occasionally the compiled libraries are outdated depending on which platforms I happen to rebuild. Ideally there would be some way to automatically rebuild the native Platform libs for Linux/Windows/Mac whenever they actually change. The downside is that it feels like you could end up with double-commits for any changes (ex. commit changes to native API, action runs and rebuilds libs and then commits those?).

So I'm not sure if there's a suitable answer that both 1) keeps the libraries inside the repo for ease-of-use and 2) doesn't get overly complicated with lots of double-commits and stuff.

MrBrixican commented 1 year ago

To my knowledge, there isn't much that could be done to avoid double commits without accidentally causing issues for those syncing with master.

Two options (each with their own cons) I could see:

Also worth noting is that GitHub actions doesn't have Apple Silicon support yet, so no GitHub Action will build libs for that, unless you use a self hosted runner.

NoelFB commented 1 year ago

I think I like the first option a lot more, and to just use a path filter so it only rebuilds them if changes to the native C files were pushed. I really want to avoid any end-user requirements (for major platforms) because I don't feel like most people writing C# want to have to deal with CMake or C/C++ tooling. If they want to build it for a different platform (or Apple Silicon until that's supported) then I'm OK with the requirement of having to build the native lib yourself.

I would need to look into how to actually do that. I'm not super familiar with Github Actions, but I see it basically needing to:

NoelFB commented 1 year ago

This seems to be in a good working state! Can re-open if other issues arise, or if we want to add more platforms (and eventually Apple Silicon if Github ever supports that)