Skip to content

Commit

Permalink
chore: add clean.sh, rm build-rs.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
harveyghq committed Jul 5, 2024
1 parent 7227756 commit fa87731
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 106 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ If successful, a success message will be displayed, typically **after several se
Sample Wasm binaries, including "Hello World" in C, Go, and Rust, are provided in the folder.
These can be compiled from their respective source languages; the compilation processes are detailed in [WASI tutorial](https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-tutorial.md#compiling-to-wasi) (C and Rust), and [WASI "Hello World" example](https://wasmbyexample.dev/examples/wasi-hello-world/wasi-hello-world.go.en-us.html) (Go).

For Rust and C++ project, you can use `wasm-tools` to demangle symbol names in the `name` section. Install with `cargo install wasm-tools`. Confirm by `wasm-tools --version`. Details can be found at [Wasm Tools](https://github.com/bytecodealliance/wasm-tools).

## Analyze
This section demonstrates how to use SeeWasm to analyze a generated WebAssembly file.

Expand Down
106 changes: 0 additions & 106 deletions build-rs.sh

This file was deleted.

50 changes: 50 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -e

OUTPUT_DIR=output

error() {
command printf '\033[1;31mError: %s\033[0m\n\n' "$1" 1>&2
}

usage() {
cat >&2 <<END_USAGE
clean: remove output files and directories
USAGE:
clean [FLAGS]
FLAGS:
-h, --help Prints help information
-f, --force Force remove output files and directories
END_USAGE
}

# parse command line options
while [ $# -gt 0 ]
do
arg="$1"

case "$arg" in
-h|--help)
usage
exit 1
;;
-f|--force)
shift # shift off the argument
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/log $OUTPUT_DIR/result
touch $OUTPUT_DIR/log/.placeholder $OUTPUT_DIR/result/.placeholder
exit 0
;;
*)
error "Unknown option: '$arg'"
usage
exit 1
;;
esac
done

# normal delete
rm -ri $OUTPUT_DIR

0 comments on commit fa87731

Please sign in to comment.