Skip to content

Instantly share code, notes, and snippets.

@RaphGL
Created March 4, 2024 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaphGL/9c4068d3db2b5a18381cfb1771993dcb to your computer and use it in GitHub Desktop.
Save RaphGL/9c4068d3db2b5a18381cfb1771993dcb to your computer and use it in GitHub Desktop.
Install Odin compiler and LSP
#!/bin/env sh
USER_HOME=$(getent passwd $SUDO_USER | cut -d: -f6)
# where to put the odin repos
REPO_DIR=${USER_HOME}/Documents
if [ "$EUID" -ne 0 ];
then echo "Please run as root"
exit
fi
function notify() {
echo
echo "[[ $1 ]]"
echo
}
function clone_odin_compiler_and_lsp() {
notify "CLONING ODIN COMPILER"
git clone https://github.com/odin-lang/Odin ${REPO_DIR}/Odin
notify "CLONING ODIN LSP"
git clone https://github.com/DanielGavin/ols ${REPO_DIR}/ols
}
function get_latest_tagged_release() {
git checkout $(git describe --tags "$(git rev-list --tags --max-count=1)")
}
function install_odin_compiler() {
notify "INSTALLING ODIN COMPILER"
cd ${REPO_DIR}/Odin
git pull
get_latest_tagged_release
make
cp odin "/usr/lib/odin/odin"
cp -r base "/usr/lib/odin/base"
cp -r core "/usr/lib/odin/core"
cp -r shared "/usr/lib/odin/shared"
cp -r vendor "/usr/lib/odin/vendor"
rm -f /usr/bin/odin
ln -s "/usr/lib/odin/odin" "/usr/bin/odin"
}
function install_odin_lsp() {
notify "INSTALLING ODIN LSP"
cd ${REPO_DIR}/ols
git pull
sh build.sh
mv -f ols /usr/bin/ols
}
clone_odin_compiler_and_lsp
install_odin_compiler
install_odin_lsp
echo
echo
echo "Odin has been installed"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment