akarpovskii / build.crab

Use Rust libraries in Zig
MIT License
25 stars 3 forks source link

How to set RUST_FLAGS #6

Closed AlvaroMS25 closed 5 months ago

AlvaroMS25 commented 5 months ago

Hello!, i'm using this library to build a rust project alongside a zig one, but i need to set RUST_FLAGS in order to compile the rust one, how can i do that?

akarpovskii commented 5 months ago

Hi! Do you mean RUSTFLAGS?

You can set the value in .cargo/config.toml to avoid using the env variable.

Using the env variable is a bit tricky because ideally you want to add the variable to the actual run step which is local to the function and is not available on the call site. But you can set the variable globally for the whole build graph:

b.graph.env_map.put("RUSTFLAGS", "flags go here") catch @panic("OOM");

Or set the value before running zig build (assuming *nix shell):

RUSTFLAGS="flags go here" zig build
AlvaroMS25 commented 5 months ago

That was it, thanks!