project_name := `basename "$(pwd)"`
# just search "just a <search_str>"(cargo install ripgrep)
a SEARCH:
just -l | rg -i {{SEARCH}}
# "rustup show" & remove toolchains
toolremove TOOLCHAINS:
rustup toolchain remove {{TOOLCHAINS}}
# rust-analyzer is available in rustup:
rupdate:
rustup component add rust-analyzer
# rust-lang(rustc) update stable
rustupdate:
rustup update stable
# cargo doc (documentation preview)
doc:
cargo doc --open
# cargo run
r:
cargo r 2>&1
# (optimization)cargo run --release
rr:
cargo run --release 2>&1
# cargo watch(check & test & run)(cargo install cargo-watch)
w:
cargo watch -x check -x test -x run
# cargo watch(simple only run)
ws:
cargo watch -x 'run'
# final review
fi:
cargo fmt --all -- --check
cargo check --all-features --all-targets --all
cargo nextest run --all-features --no-fail-fast --workspace --no-capture
cargo clippy --all-features --all-targets -- -D warnings
cargo doc --open
cargo audit
# cargo check(Test Before Deployment)
c:
cargo check --all-features --all-targets --all
# cargo test
t:
cargo t 2>&1
# cargo expand(test --lib)
tex:
cargo expand --lib --tests
# cargo test -- --nocapture
tp:
cargo t -- --nocapture 2>&1
# nightly(cargo nextest run)
tn:
cargo nextest run 2>&1
# nightly(cargo nextest run --nocapture)
tnp:
cargo nextest run --nocapture 2>&1
# macro show(cargo expand)
ex:
cargo expand
# emit mir file(nightly)
mir:
cargo rustc -- -Zunpretty=mir > target/{{project_name}}.mir
# emit asm file
es:
cargo rustc -- --emit asm=target/{{project_name}}.s
# optimized assembly
eos:
cargo rustc --release -- --emit asm > target/{{project_name}}.s
# emit llvm-ir file
llvm:
cargo rustc -- --emit llvm-ir=target/{{project_name}}.ll
# emit hir file(nightly)
hir:
cargo rustc -- -Zunpretty=hir > target/{{project_name}}.hir
# cargo asm
asm METHOD:
cargo asm {{project_name}}::{{METHOD}}
# (nightly)clang sanitize(ASan=address / LSan=leak / TSan=thread / MSan=memory / UBSan=undefined)
[linux]
san SAN:
export RUSTFLAGS=-Zsanitizer={{SAN}} RUSTDOCFLAGS=-Zsanitizer={{SAN}}
just n
cargo run -Zbuild-std --target x86_64-unknown-linux-gnu
# hex view("rg -i <search>" | "grep -rni <search>")
xx:
cargo r
xxd -c 16 ./target/debug/{{project_name}} > ./target/debug/hex_print.txt
# hex view(cat "SEARCH" | rg -i --line-number --color=always "SEARCH"("rg -i <search>"))
xv STR:
just xx
cat ./target/debug/hex_print.txt | rg -i --line-number --color=always {{STR}}
# clean file
clean:
rm -rf target ./config rust-toolchain.toml *.lock
# nightly setting(faster compilation)
n:
rm -rf .cargo rust-toolchain.toml
mkdir -p .cargo
echo "[toolchain]" > rust-toolchain.toml
echo "channel = \"nightly\"" >> rust-toolchain.toml
echo "components = [\"rustfmt\", \"rust-src\"]" >> rust-toolchain.toml
echo "[build]" > .cargo/config.toml
echo "rustflags = [\"-Z\", \"threads=8\"]" >> .cargo/config.toml
# .gitignore setting
gi:
echo "# Result" >> README.md
echo "" >> README.md
echo "" >> README.md
echo '```bash' >> README.md
echo "" >> README.md
echo "" >> README.md
echo '```' >> README.md
echo "" >> README.md
echo "# Visual Studio 2015/2017 cache/options directory" > .gitignore
echo ".vs/" >> .gitignore
echo "" >> .gitignore
echo "# A collection of useful .gitignore templates" >> .gitignore
echo "# https://github.com/github/gitignore" >> .gitignore
echo "# General" >> .gitignore
echo ".DS_Store" >> .gitignore
echo "dir/otherdir/.DS_Store" >> .gitignore
echo "" >> .gitignore
echo "# VS Code files for those working on multiple tools" >> .gitignore
echo ".vscode/" >> .gitignore
echo "# Generated by Cargo" >> .gitignore
echo "# will have compiled files and executables" >> .gitignore
echo "debug/" >> .gitignore
echo "target/" >> .gitignore
echo "" >> .gitignore
echo "# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries" >> .gitignore
echo "# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html" >> .gitignore
echo "Cargo.lock" >> .gitignore
echo "" >> .gitignore
echo "# These are backup files generated by rustfmt" >> .gitignore
echo "**/*.rs.bk" >> .gitignore
echo "" >> .gitignore
echo "# MSVC Windows builds of rustc generate these, which store debugging information" >> .gitignore
echo "*.pdb" >> .gitignore
echo "" >> .gitignore
echo "# WASM" >> .gitignore
echo "pkg/" >> .gitignore
echo "/wasm-pack.log" >> .gitignore
echo "dist/" >> .gitignore