From 9f524cf821b17bba30f97bf2b59489c0443d3598 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Fri, 21 Mar 2025 11:39:02 -0400 Subject: [PATCH] build(mk): added meson auto installer --- mk | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/mk b/mk index 97a1e1e..cf93850 100755 --- a/mk +++ b/mk @@ -119,8 +119,62 @@ fi log "${BLUE}[Info] Checking if Meson is installed...${NC}" if ! command -v meson &> /dev/null; then log "${RED}[Error] Meson is not installed. Exiting...${NC}" - log "${YELLOW}[Info] Please install Meson and try again.${NC}" - exit 1 + # Check if the user would like to try to install meson by getting input + installMeson=0 + while true; do + read -p "Would you like to try to install Meson? [y/n]: " yn + case $yn in + [Yy]* ) installMeson=1; break;; + [Nn]* ) break;; + * ) echo "Please answer yes or no.";; + esac + done + if [[ $installMeson -eq 1 ]]; then + # check if pip is installed + if ! command -v pip &> /dev/null; then + log "${RED}[Error] pip is not installed. Exiting...${NC}" + log "${YELLOW}[Info] Please install pip and try again.${NC}" + exit 1 + else + log "${MAGENTA}[Success] pip is installed. Continuing...${NC}" + fi + + # check if python3 is installed + if ! command -v python3 &> /dev/null; then + log "${RED}[Error] python3 is not installed. Exiting...${NC}" + log "${YELLOW}[Info] Please install python3 and try again.${NC}" + log "${YELLOW}[INFO] If you have python3 installed, please add it to your PATH.${NC}" + exit 1 + else + log "${MAGENTA}[Success] python3 is installed. Continuing...${NC}" + fi + + # Check if the venv ~/.4DSSE_env exists + if [[ ! -d "$HOME/.4DSSE_env" ]]; then + log "${BLUE}[Info] Creating virtual environment...${NC}" + python3 -m venv "$HOME/.4DSSE_env" + source "$HOME/.4DSSE_env/bin/activate" + log "${GREEN}[Success] Virtual environment created.${NC}" + else + log "${MAGENTA}[Succsess] Virtual environment already exists. Skipping...${NC}" + fi + + # install meson + log "${BLUE}[Info] Installing Meson...${NC}" + pip install meson + + # confirm meson is installed + if ! command -v meson &> /dev/null; then + log "${RED}[Error] Meson did not install properly. Exiting...${NC}" + log "${YELLOW}[Info] Please manually install Meson and try again.${NC}" + exit 1 + else + log "${GREEN}[Success] Meson installed.${NC}" + fi + else + log "${YELLOW}[Info] Please install Meson and try again.${NC}" + exit 1 + fi else log "${MAGENTA}[Success] Meson is installed. Continuing...${NC}" fi