Skip to content

Instantly share code, notes, and snippets.

@TriplEight
Last active April 13, 2021 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TriplEight/43cb9dd6a5e0d06a5e64e9d97346ca2e to your computer and use it in GitHub Desktop.
Save TriplEight/43cb9dd6a5e0d06a5e64e9d97346ca2e to your computer and use it in GitHub Desktop.
Function for bash/fish to run cargo as a virtual environment in the current dir
# "Cargo as a virtual environment in the current dir"
function cargoenvhere {
dirname="$(basename $(pwd))"
user=$(whoami)
echo "Cargo as a virtual environment in" "$dirname" "dir"
mkdir -p /home/"$user"/cache/"$dirname"
podman run --rm -it -w /shellhere/"$dirname" -v "$(pwd)":/shellhere/"$dirname" -v /home/"$user"/cache/"$dirname"/:/cache/ -e CARGO_HOME=/cache/cargo/ -e SCCACHE_DIR=/cache/sccache/ -e CARGO_TARGET_DIR=/cache/target/ "$@"
}
# example use
# cargoenvhere paritytech/ci-linux:production /bin/bash -c 'RUSTFLAGS="-Cdebug-assertions=y -Dwarnings" RUST_BACKTRACE=1 time cargo test --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml'
#!/bin/bash
# "Cargo as a virtual environment in the current dir"
dirname="$(basename $(pwd))"
user=$(whoami)
echo "Cargo as a virtual environment in" "$dirname" "dir"
mkdir -p /home/"$user"/cache/"$dirname"
podman run --rm -it -w /shellhere/"$dirname" -v "$(pwd)":/shellhere/"$dirname" -v /home/"$user"/cache/"$dirname"/:/cache/ -e CARGO_HOME=/cache/cargo/ -e SCCACHE_DIR=/cache/sccache/ -e CARGO_TARGET_DIR=/cache/target/ "$@"
# example use
# cargoenvhere paritytech/ci-linux:production /bin/bash -c 'RUSTFLAGS="-Cdebug-assertions=y -Dwarnings" RUST_BACKTRACE=1 time cargo test --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml'
function cargoenvhere -d "Cargo as a virtual environment in the current dir"
set dirname (basename (pwd))
set user (whoami)
echo "Cargo as a virtual environment in" $dirname "dir"
mkdir -p /home/$user/cache/$dirname
podman run --rm -it -w /shellhere/$dirname -v (pwd):/shellhere/$dirname -v /home/$user/cache/$dirname/:/cache/ -e CARGO_HOME=/cache/cargo/ -e SCCACHE_DIR=/cache/sccache/ -e CARGO_TARGET_DIR=/cache/target/ $argv
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment