-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwasm.sh
executable file
·20 lines (14 loc) · 839 Bytes
/
wasm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# Depends on the 'jq' tool.
rust_playground_api_wasm() {
input_filename="$@"
if [ $# -eq 0 ]; then
input_str="fn main() {\n println!(\"Hello, world!\");\n}"
else
input_str="$(cat $input_filename | sed ':a;N;$!ba;s/\n/\\n/g')"
fi
input_str2="$(printf '%s' "$input_str" | sed 's/\"/\\\"/g')"
input_param="$(printf '%b' "$input_str"|jq -sRr @uri)"
curl -sL -H 'Content-Type: application/json' -X POST -d '{"channel":"nightly","mode":"debug","edition":"2018","crateType":"bin","tests":false,"code":"'"$input_str2"'","target":"wasm","assemblyFlavor":"att","demangleAssembly":"demangle","processAssembly":"filter","backtrace":false}' -H "Referrer: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&code=$input_param" https://play.rust-lang.org/compile
}
rust_playground_api_wasm "$@"