Created
April 7, 2017 19:01
-
-
Save matutter/f8111e0bbd0a90d0eee83bd75aeb010e to your computer and use it in GitHub Desktop.
Installs antlr4 on linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| export ANTLR4_JAR=antlr-4.7-complete.jar | |
| if ! type -p java; then | |
| # Install Java 8 | |
| echo "Installing Java 8" | |
| sudo add-apt-repository ppa:webupd8team/java | |
| sudo apt updatee; sudo apt install oracle-java8-installer | |
| # Check version | |
| javac -version | |
| fi | |
| if ! -f "${ANTLR4_JAR}"; then | |
| # Download Runtime | |
| echo "Downloading ${ANTLR4_JAR}" | |
| wget http://www.antlr.org/download/${ANTLR4_JAR} | |
| sudo mkdir -p /opt/antlr/bin | |
| sudo mv antlr-4.7-complete.jar /opt/antlr | |
| fi | |
| echo "Writing antlr4 script to /opt/antlr4/bin" | |
| cat > /opt/antlr/bin/antlr4 << EOF | |
| #!/bin/bash | |
| java -jar /opt/antlr/${ANTLR4_JAR} \$@ | |
| EOF | |
| chmod +x /opt/antlr/bin/antlr4 | |
| if ! grep -Fxq "#TAG_ANTLR4" ~/.bashrc; then | |
| echo "Writing ~/.antlr4rc" | |
| cat > /home/$USER/.antlr4rc << EOF | |
| export PATH=/opt/antlr/bin:\$PATH | |
| export CLASSPATH=".:/opt/antlr/${ANTLR4_JAR}:\$CLASSPATH" | |
| alias grun='java org.antlr.v4.runtime.misc.TestRig' | |
| EOF | |
| echo "Appending to ~/.bashrc" | |
| echo '#TAG_ANTLR4' >> ~/.bashrc | |
| echo 'source /home/$USER/.antlr4rc' >> ~/.bashrc | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment