Last active
April 13, 2021 12:23
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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