Makefile 5.16 KB
BLEND      = avatar_cartoon_v1.0.0.blend
BLENDER    = blender
BLUE       = \33[34;5m
CACHE      = ./__pycache__
CONTROLLER = controller.py
CORE       = git@git.lavid.ufpb.br:wikilibras-core
DONE       = [$(GREEN)Finalizado$(NONE)]
FAIL       = [$(RED)Falhou$(NONE)] Codigo: $$?
GREEN      = \33[32;5m
JSON       = '{"userId": 2, "rightHand": ["circular", "plano", "horario", 1, 2, 0, 50, 20], "leftHand":[], "facialExp": [6], "signName":"teste_circular"}'
MAIN       = libras.py
MODULE     = Wikilibras
NONE       = \33[m
PYTHON     = python3
RED        = \33[31;5m
WHITE      = \33[37;5m

__default__: py

.clscr:
	@echo -n "\033c"

bpy:
	@echo "[$(GREEN)Executando$(NONE)]$(BLUE) $(BLENDER) -b "$(BLEND)" -P "$(MAIN)" JSON ...$(NONE)";\
	$(BLENDER) -b "$(BLEND)" -P "$(MAIN)" $(JSON)\
	&& echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; }

clean: .clscr
	@echo -n "$(WHITE)Limpando... $(NONE) ";\
	rm -rf "$(CACHE)"\
	&& echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; }

git-clone:
	@input="";\
	while [ "$$input" != "s" ] && [ "$$input" != "n" ];\
	do\
	    echo -n "$(GREEN)Clonar $(BLUE)$(CORE)?$(NONE) (s/n): ";\
	    read input;\
	    input="`echo $$input | tr [:upper:] [:lower:]`";\
	done;\
	if [ "$$input" = "s" ];\
	then\
	    git clone $(CORE);\
	else\
	    exit 0;\
	fi\
	&& echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; }

git-config:
	@echo -n "$(GREEN)Nome:$(BLUE) ";\
	git config --global user.name;\
	echo -n "$(GREEN)Email:$(BLUE) ";\
	git config --global user.email;\
	input="";\
	while [ "$$input" != "s" ] && [ "$$input" != "n" ];\
	do\
	    echo -n "$(GREEN)Configurar Git?$(NONE) (s/n): ";\
	    read input;\
	    input="`echo $$input | tr [:upper:] [:lower:]`";\
	done;\
	if [ "$$input" = "s" ];\
	then\
	    name="";\
	    while [ -z "$$name" ];\
	    do\
	        echo -n "$(GREEN)Digite seu nome:$(NONE) ";\
	        read name;\
	    done;\
	    email="";\
	    while [ -z "$$email" ];\
	    do\
	        echo -n "$(GREEN)Digite seu email:$(NONE) ";\
	        read email;\
	    done;\
	    input="";\
	    while [ "$$input" != "s" ] && [ "$$input" != "n" ];\
	    do\
	        echo -n "$(GREEN)Confirma dados?$(NONE) (s/n): ";\
	        read input;\
	        input="`echo $$input | tr [:upper:] [:lower:]`";\
	    done;\
	    if [ "$$input" = "s" ];\
	    then\
	        git config --global user.name "$$name";\
	        git config --global user.email "$$email";\
	        git config --global color.diff auto;\
	        git config --global color.status auto;\
	        git config --global color.branch auto;\
	        git config --global color.ui true;\
                git config --global push.default simple;\
	    else\
	        exit 0;\
	    fi;\
	else\
	    exit 0;\
	fi\
	&& echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; }

help:
	@echo ""
	@echo " $(WHITE) Make <args> $(NONE)"
	@echo ""
	@echo " $(GREEN) <args> $(NONE)     $(BLUE) <funcao> $(NONE)"
	@echo ""
	@echo " $(GREEN) bpy $(NONE)        $(BLUE) Executa: $(BLENDER) <$(MAIN)> com parametros JSON do Makefile $(NONE)"
	@echo " $(GREEN) clean $(NONE)      $(BLUE) Remove pasta(s) temporaria(s): $(CACHE) $(NONE)"
	@echo " $(GREEN) git-clone $(NONE)  $(BLUE) Clona repositorio: \"$(CORE)\" na pasta atual $(NONE)"
	@echo " $(GREEN) git-config $(NONE) $(BLUE) Configura Git para o primeiro uso $(NONE)"
	@echo " $(GREEN) help $(NONE)       $(BLUE) Exibe ajuda $(NONE)"
	@echo " $(GREEN) py $(NONE)         $(BLUE) Executa: $(PYTHON) <$(CONTROLLER)> com parametros JSON do Makefile $(NONE)"
	@echo " $(GREEN) recv $(NONE)       $(BLUE) Recebe dados do repositorio: \"$(CORE)\" $(NONE)"
	@echo " $(GREEN) send $(NONE)       $(BLUE) Envia dados para o repositorio: \"$(CORE)\" $(NONE)"
	@echo ""

py:
	@echo "[$(GREEN)Executando$(NONE)]$(BLUE) $(PYTHON) "$(CONTROLLER)" JSON ...$(NONE)";\
	$(PYTHON) "$(CONTROLLER)" $(JSON)\
	&& echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; }

recv:
	@input="";\
	while [ "$$input" != "s" ] && [ "$$input" != "n" ];\
	do\
	    echo -n "$(GREEN)Receber dados alterados?$(NONE) (s/n): ";\
	    read input;\
	    input="`echo $$input | tr [:upper:] [:lower:]`";\
	done;\
	if [ "$$input" = "s" ];\
	then\
	    git pull;\
	else\
	    exit 0;\
	fi\
	&& echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; }

send:
	@input="";\
	while [ "$$input" != "s" ] && [ "$$input" != "n" ];\
	do\
	    echo -n "$(GREEN)Enviar alteracoes realizadas?$(NONE) (s/n): ";\
	    read input;\
	    input="`echo $$input | tr [:upper:] [:lower:]`";\
	done;\
	if [ "$$input" = "s" ];\
	then\
	    comment="";\
	    while [ -z "$$comment" ];\
	    do\
	        echo -n "$(GREEN)Digite o comentario das alteracoes:$(NONE) ";\
	        read comment;\
	    done;\
	    input="";\
	    while [ "$$input" != "s" ] && [ "$$input" != "n" ];\
	    do\
	        echo -n "$(GREEN)Enviar dados?$(NONE) (s/n): ";\
	        read input;\
	        input="`echo $$input | tr [:upper:] [:lower:]`";\
	    done;\
	    if [ "$$input" = "s" ];\
	    then\
	        git add .;\
	        git commit -m "$$comment";\
	        git push;\
	    else\
	        exit 0;\
	    fi;\
	else\
	    exit 0;\
	fi\
	&& echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; }