34 lines
876 B
Bash
34 lines
876 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -xe
|
||
|
|
||
|
DEFAULT_PREFIX=/usr/local
|
||
|
INSTALL_PREFIX="${PREFIX:-$DEFAULT_PREFIX}"
|
||
|
|
||
|
if [[ $1 == "uninstall" ]]; then
|
||
|
echo "Uninstalling at ${INSTALL_PREFIX}..."
|
||
|
sudo rm -r "${INSTALL_PREFIX}/share/ast_generator"
|
||
|
sudo rm "${INSTALL_PREFIX}/bin/generate_ast"
|
||
|
echo "Uninstalled"
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
echo "Installing at ${INSTALL_PREFIX}..."
|
||
|
|
||
|
./build.sh
|
||
|
|
||
|
sudo mkdir -p "${INSTALL_PREFIX}/share/ast_generator"
|
||
|
|
||
|
sudo cp ast_generator.ts "${INSTALL_PREFIX}/share/ast_generator/"
|
||
|
sudo cp ast.out.ts "${INSTALL_PREFIX}/share/ast_generator/"
|
||
|
sudo cp parser.out.ts "${INSTALL_PREFIX}/share/ast_generator/"
|
||
|
|
||
|
echo "#!/bin/bash" >> generate_ast.temp
|
||
|
echo "deno run --allow-read ${INSTALL_PREFIX}/share/ast_generator/ast_generator.ts \$1" >> generate_ast.temp
|
||
|
chmod +x generate_ast.temp
|
||
|
|
||
|
sudo mv generate_ast.temp "${INSTALL_PREFIX}/bin/generate_ast"
|
||
|
|
||
|
echo "Installed"
|
||
|
|