5 ms·
I hope someone creates a rule set for Bazel to automate this stuff. This seems like a really nice way to start rewriting performance critical code in a safe lan
by gravypod 5y ago
I hope someone creates a rule set for Bazel to automate this stuff. This seems like a really nice way to start rewriting performance critical code in a safe language!
- dijit 5y agoI’ve been having difficulty recently trying to get bazel and rust to work together nicely. It seems like cargo does a lot of heavy lifting w.r.t. dependencies which Bazel does not like. Do you have to vendor your dependencies- and your dependencies dependencies. Ad infinitum. There is cargo-raze which helps, but only if you’re making a rust library: not if you’re making a binary. So maybe it works for this case.
- gravypod 5y ago> It seems like cargo does a lot of heavy lifting w.r.t. dependencies which Bazel does not like. Do you have to vendor your dependencies- and your dependencies dependencies. Ad infinitum. I'm really hoping bzlmod helps in this case: https://www.youtube.com/watch?v=TxOCKtU39Fs https://www.youtube.com/watch?v=TxOCKtU39Fs The story for external deps is indeed extremely painful right now.
- bluejekyll 5y agoHave you tried cargo-vendor for managing all the dependencies?
- bytearray64 5y agoNot disagreeing that cargo-raze in bazel is awkward, but just wanted to add: Cargo raze should let you consume libraries you've imported in a rust_binary target, if that's what you're talking about. It's also possible, but slightly more annoying, to vendor the dependency tree if you need to rely on pulling from a local mirror. I've also used it to import cargo binaries (i.e wasm-bindgen-cli) into a Bazel workspace -- it just makes the resulting target something like @raze_some_bin//:bin
- HelloNurse 5y agoIsn't it possible to make a little script to run bazel clean or the equivalent whenever you run Cargo to actually add, remove or update Rust libraries, and ignore them as dependencies because they are immutable apart from such user interventions? Are Bazel and/or Cargo too smart?
- bytearray64 5y agoI've been using this macro in my personal projects repo: https://pastebin.com/raw/atNtPgwv https://pastebin.com/raw/atNtPgwv The three big gotchas with this are: - You need to name the rule the same as the module you've exported in Rust - It creates a copy to get the naming right. You could write an actual rule instead of a macro that just makes a symlink with the right name for Python to pick it up. - Since the macro just exposes a genrule and isn't a PyInfo provider, you need to add it in the data of the py_library/binary you intend to use it in. Again, could be fixed by an actual rule impl.