rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running `cargo doc` with `cargo-zigbuild`

cpick opened this issue · comments

I'm currently running cargo doc on macOS using the following:

$ cat cargo-zigbuild-zig-cc
#!/bin/sh
exec cargo-zigbuild zig cc -- "$@"
$ CC="$(pwd)/cargo-zigbuild-zig-cc" cargo doc --target x86_64-unknown-linux-musl

This mostly works (I sometimes have to precede it with a cargo-zigbuild check --target x86_64-unknown-linux-musl so likely the cargo doc command also needs some other environment variables {linker?} set to work with an empty cache/target directory), but I'm wondering if there's a cleaner way?

I originally got the idea for the script from #105, but I don't think the ultimate solution from that issue would work in this case. I also tried setting cargo-zigbuild as various permutations for $RUSTC_WRAPPER and/or $RUSTC but didn't find success.

I took a look at how the cargo-zigbuild check command appeared to be implemented and that doesn't look too painful, so maybe I can clone that to create a cargo-zigbuild doc subcommand? (If so, I think most of the work would be adding cargo doc to the cargo_options crate?)

The whole reason I'm trying to pass --target into cargo doc is that my project is using a bunch of libc and nix crate functions and definitions that are very target-specific.

so maybe I can clone that to create a cargo-zigbuild doc subcommand? (If so, I think most of the work would be adding cargo doc to the cargo_options crate?)

yes, pull requests are welcome.

Pull request opened in #235.