Open alexkirsz opened 1 month ago
If I understand correctly, running rustc
in "check" mode (the same way it's invoked by cargo check
) with a few environment variables should be sufficient. cargo sqlx prepare
invokes cargo check
with SQLX_TMP
, SQLX_OFFLINE
set to false
, and SQLX_OFFLINE_DIR
points to the .sqlx
folder.
So it should be possible to set up such a rule in Bazel to generate the .sqlx
.
Is your feature request related to a problem? Please describe.
We're using Bazel and
rules_rust
to build all of our Rust libraries and binaries. We don't use Cargo at all, which means that we don't have anyCargo.toml
file to describe our workspace or crates, and as suchcargo build
cannot compile our project. Everything is defined inBUILD.bazel
files instead.Describe the solution you'd like
Provide a
sqlx prepare
command that doesn't require being run through Cargo, possibly taking in a.rlib
instead and using a solution akin to UniFFI's metadata macros: embed the generated queries within the generated binary or library, and extract it as part of thesqlx prepare
command.Describe alternatives you've considered
Another way to fix this issue would be to provide first-class Bazel support, but that would not scale well to other cargo-less setups.