3 ms·
Without makefiles, how do you do projects with multiple languages or code generators like lex and yacc?
by amelius 2y ago
Without makefiles, how do you do projects with multiple languages or code generators like lex and yacc?
- nostradumbasp 2y agoWell, I don't use makefiles to deploy software with Rust. I also have never used lex or yacc, but I bet there are similar tools in the ecosystem, or wrappers for those. That would obviate what I will offer below. Often a new language in a project would define an application boundary. So those would be different containers or services. I may deploy via container images, or an OS specific installer, etc. If we aren't crossing an application boundary I may use FFI. Sometimes I use https://rust-lang.github.io/rust-bindgen/ https://rust-lang.github.io/rust-bindgen/ to smooth that over for C dependencies. There is also a nice concept called a build.rs file: https://doc.rust-lang.org/cargo/reference/build-script-examples.html https://doc.rust-lang.org/cargo/reference/build-script-examp.... There's also tools like: https://github.com/casey/just https://github.com/casey/just and https://sagiegurari.github.io/cargo-make/ https://sagiegurari.github.io/cargo-make/ I rarely use multiple languages with Rust. A lot of interpreted languages have bindings through crates and can go in to a project through Cargo (python, etc). If it involves JS/TS on desktop, I'm usually using Tauri for that. Guess it depends on the system? Hopefully that helps. You can also still use a Makefile if you want I just haven't dealt with one in a long time.
- eslaught 2y agoIf you're embedding, say, a C library inside of Rust, you can do so via a so-called "build.rs" script [1]. These run at build time so you can do pretty much whatever you want. They're not necessarily pretty, but given that Cargo isn't going to support other languages natively, it's often a less-evil option. Then there are build systems that natively support Rust in addition to other languages and know how to plug them together [2] [3] [4]. If you're already using one of these existing tools, then you don't need to roll your own, you can plug it into your existing project. Of course if you really are using Makefiles in C you're already living in the wild west, so it's on you to figure out how to add Rust to your projects in that case (or switch to a better build system). [1]: https://doc.rust-lang.org/cargo/reference/build-scripts.html https://doc.rust-lang.org/cargo/reference/build-scripts.html [2]: https://bazelbuild.github.io/rules_rust/ https://bazelbuild.github.io/rules_rust/ [3]: https://buck.build/rule/rust_library.html https://buck.build/rule/rust_library.html [4]: https://mesonbuild.com/Rust.html https://mesonbuild.com/Rust.html