wrote some bash commands for rust things
This commit is contained in:
parent
242ec9bd6a
commit
571aaaa96e
60
bashrc
Normal file
60
bashrc
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
function rust_create_embedded_project() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "you need to specify a project name. for example"
|
||||
echo "create_rust_embedded_project proj-name"
|
||||
else
|
||||
cargo generate \
|
||||
--git https://github.com/knurling-rs/app-template \
|
||||
--branch main \
|
||||
--name $1
|
||||
cd $1
|
||||
cargo add panic-halt
|
||||
fi
|
||||
}
|
||||
|
||||
function rust_embedded_available_chips() {
|
||||
if [ -z "$1" ]; then
|
||||
probe-rs chip list
|
||||
else
|
||||
probe-rs chip list >> $1
|
||||
fi
|
||||
}
|
||||
|
||||
function rust_print_elf_headers() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "you need to specify a project name. for example"
|
||||
echo "rust_print_elf_headers proj-name"
|
||||
else
|
||||
cargo readobj --bin $1 -- --file-headers
|
||||
fi
|
||||
}
|
||||
|
||||
function rust_print_linker_sections() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "you need to specify a project name. for example"
|
||||
echo "rust_print_linker_sections proj-name"
|
||||
echo ""
|
||||
echo "above example will print the release version to print dev version use"
|
||||
echo "rust_print_linker_sections proj-name dev"
|
||||
elif [ -z "$2" ]; then
|
||||
cargo size --bin $1 --release -- -A
|
||||
else
|
||||
cargo size --bin $1 -- -A
|
||||
fi
|
||||
}
|
||||
|
||||
function rust_disassemble() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "you need to specify a project name. for example"
|
||||
echo "rust_disassemble proj-name"
|
||||
echo ""
|
||||
echo "above example will print the release version to print dev version use"
|
||||
echo "rust_disassemble proj-name dev"
|
||||
elif [ -z "$2" ]; then
|
||||
cargo objdump --bin $1 --release -- --disassemble --no-show-raw-insn --print-imm-hex
|
||||
else
|
||||
cargo objdump --bin $1 -- --disassemble --no-show-raw-insn --print-imm-hex
|
||||
fi
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user