Skip to content

Commit

Permalink
Run as cago flux instead of cargo-flux
Browse files Browse the repository at this point in the history
  • Loading branch information
nilehmann committed Nov 7, 2023
1 parent de5f676 commit 7d5361b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
11 changes: 4 additions & 7 deletions book/src/guide/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ You could for example check a file as a library instead of a binary like so
rustc-flux --crate-type=lib path/to/test.rs
```

## Running on a Crate: `cargo-flux`
## Running on a package: `cargo-flux`

You can use `cargo-flux` as you would use `cargo`. For the most part this means
instead of running `cargo check`, you should run
Flux is integrated with `cargo` and can be invoked in a package as follows:

``` bash
cargo-flux check
```bash
cargo flux
```

in order to get `flux` to check your code.

## A tiny example

The following example declares a function `inc`
Expand Down
9 changes: 4 additions & 5 deletions crates/flux-bin/src/bin/cargo-flux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ fn run() -> Result<i32> {
let ld_library_path = get_rustc_driver_lib_path(&rust_toolchain)?;
let extended_lib_path = prepend_path_to_env_var(LIB_PATH, ld_library_path)?;

let cargo_path = env::var("CARGO_PATH").unwrap_or_else(|_| "cargo".to_string());
let cargo_target = env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_string());
let cargo_target = PathBuf::from_iter([cargo_target, "flux".to_string()]);

let exit_code = Command::new("cargo")
// Skip the invocation of cargo-flux itself
.args(env::args().skip(1))
let exit_code = Command::new(cargo_path)
.arg("check")
.env(LIB_PATH, extended_lib_path)
// CODESYNC(build-sysroot, 5) When running flux within cargo we want to compile flux libraries
// as the precompiled versions.
// CODESYNC(build-sysroot, 5) Tell flux dependencies to build in flux mode.
.env("FLUX_BUILD_SYSROOT", "1")
// CODESYNC(flux-cargo) Tell the flux-driver it's being called from cargo.
.env("FLUX_CARGO", "1")
Expand Down

0 comments on commit 7d5361b

Please sign in to comment.