build(mk): added auto ninja installer

This commit is contained in:
2025-03-21 11:42:01 -04:00
parent 9f524cf821
commit 58ef0d495e

59
mk
View File

@@ -183,8 +183,63 @@ fi
log "${BLUE}[Info] Checking if Ninja is installed...${NC}"
if ! command -v ninja &> /dev/null; then
log "${RED}[Error] Ninja is not installed. Exiting...${NC}"
log "${YELLOW}[Info] Please install Ninja and try again.${NC}"
exit 1
# Check if the user would like to try to install ninja by getting input
installNinja=0
while true; do
read -p "Would you like to try to install Ninja? [y/n]: " yn
case $yn in
[Yy]* ) installNinja=1; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
if [[ $installNinja -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 ninja
log "${BLUE}[Info] Installing Ninja...${NC}"
pip install ninja
# confirm ninja is installed
if ! command -v ninja &> /dev/null; then
log "${RED}[Error] Ninja did not install properly. Exiting...${NC}"
log "${YELLOW}[Info] Please manually install Ninja and try again.${NC}"
exit 1
else
log "${GREEN}[Success] Ninja installed.${NC}"
fi
else
log "${YELLOW}[Info] Please install Ninja and try again.${NC}"
exit 1
fi
else
log "${MAGENTA}[Success] Ninja is installed. Continuing...${NC}"
fi