This allows users to build parsers without having to run `test` or `parse` to invoke the compilation process, and allows them to output the object file to wherever they like. The `build-wasm` command was merged into this by just specifying the `--wasm` flag.
36 lines
846 B
Bash
Executable file
36 lines
846 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
root_dir=$PWD
|
|
|
|
if [ "$CI" == true ]; then
|
|
set -x
|
|
tree_sitter="$TREE_SITTER"
|
|
else
|
|
cargo build --release
|
|
tree_sitter=${root_dir}/target/release/tree-sitter
|
|
fi
|
|
|
|
build_wasm_args=
|
|
if [[ $1 == "--docker" ]]; then
|
|
build_wasm_args="--docker"
|
|
shift
|
|
fi
|
|
|
|
filter_grammar_name=$1
|
|
|
|
grammars_dir=${root_dir}/test/fixtures/grammars
|
|
grammar_files=$(find "$grammars_dir" -name grammar.js | grep -v node_modules)
|
|
|
|
while read -r grammar_file; do
|
|
grammar_dir=$(dirname "$grammar_file")
|
|
grammar_name=$(basename "$grammar_dir")
|
|
|
|
if [[ -n $filter_grammar_name && "$filter_grammar_name" != "$grammar_name" ]]; then
|
|
continue
|
|
fi
|
|
|
|
echo "Compiling ${grammar_name} parser to wasm"
|
|
"$tree_sitter" build --wasm $build_wasm_args -o target/release/tree-sitter-"${grammar_name}".wasm "$grammar_dir"
|
|
done <<<"$grammar_files"
|