macalimlim / godot-rust-template

A template for godot-rust projects
MIT License
51 stars 22 forks source link

remove make dependency by using xtask #42

Closed IceSentry closed 2 years ago

IceSentry commented 3 years ago

I tried the template recently and I had some issues with using make on my windows machine. Since this is a rust project, I decided to use rust tools as much as possible to build the template.

I added xtask to replace make. This PR is not yet at 100% feature parity, but I wanted to see if you were interested in this change.

This should also be easier for people that know rust but are unfamiliar with make. Since we have a full programming language we can also create the required lib folder only when necessary instead of having a bunch of .gitkeep.

macalimlim commented 3 years ago

Hi @IceSentry, thank you for pointing out xtask. Have you tried ftw? I think the Makefile is a much simpler tool to have for the template. Can I know what issues you are having with using the make tool? Maybe I could help you out...

IceSentry commented 3 years ago

I believe the issue was mostly on my side because I didn't set it up properly, but that's also the reason why I don't think make is a good option. On windows it requires some setup that can simply be avoided by using rust tooling that integrates more directly with cargo.

I did try ftw after making this PR and while I didn't use it directly, I was inspired by it to generate the lib.rs file. Instead of using templates I simply parsed the existing lib.rs file and used syn and quote to modify the source code directly instead of completely regenerating the file everytime. Technically, my approach also rewrites the file every time, but if it was modified by the user it will keep those changes. Here's my repo if you want to look at what I did: https://github.com/IceSentry/godot-rust-template-test

I preferred this approach because it's less setup on the user side and uses the rust ecosystem directly. I also think it makes it more cross platform by default. It's also easier for someone like me that is familiar with rust but has pretty much never written a make file longer than 3 lines. Although, I used clap to generate the cli and there was an issue with using it in wsl, but I created an issue and there's a workaround while the offending crate is working on a fix.

IceSentry commented 3 years ago

btw my repo did borrow some code from ftw because it was closed source and I wasn't planning on releasing any of this. I'm not sure if this can cause licensing issues. I can add a license if it causes any problem.

IceSentry commented 3 years ago

Also, while I put everything in the same repo for testing purposes, I'm pretty sure most of the logic could be in a library and the xtask workspace could probably be generated by a macro similar to godot_init!(), but I haven't tried any of this.

macalimlim commented 2 years ago

Closing this issue, the template is now using cargo-make instead of make