From f6106f62c7f224bda2f0d6a3f8a50f26edf0a018 Mon Sep 17 00:00:00 2001 From: Max Base Date: Sun, 17 Nov 2024 14:43:21 +0330 Subject: [PATCH] Update Makefile - Add check_command --- Makefile | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index a62a126ea..d60ec5ea7 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,56 @@ # mruby is using Rake (https://ruby.github.io/rake/) as a build tool. RAKE = rake +DOCKER_COMPOSE = docker-compose +PRE_COMMIT = pre-commit -all : +define check_command + @command -v $(1) >/dev/null 2>&1 || { \ + echo "Error: $(1) is not installed or not in PATH."; \ + exit 1; \ + } +endef + +all : check_rake $(RAKE) .PHONY : all -test : all +test : check_rake all $(RAKE) test .PHONY : test -clean : +clean : check_rake $(RAKE) clean .PHONY : clean -check : - pre-commit run --all-files +check : check_pre_commit + $(PRE_COMMIT) run --all-files .PHONY : check -checkinstall : - pre-commit install +checkinstall : check_pre_commit + $(PRE_COMMIT) install .PHONY : checkinstall -checkupdate : - pre-commit autoupdate +checkupdate : check_pre_commit + $(PRE_COMMIT) autoupdate .PHONY : checkupdate -composecheck : - docker-compose -p mruby run test pre-commit run --all-files +composecheck : check_docker_compose check_pre_commit + $(DOCKER_COMPOSE) -p mruby run test $(PRE_COMMIT) run --all-files .PHONY : composecheck -composetest : - docker-compose -p mruby run test +composetest : check_docker_compose + $(DOCKER_COMPOSE) -p mruby run test .PHONY : composetest + +check_rake: + $(call check_command, $(RAKE)) +.PHONY : check_rake + +check_docker_compose: + $(call check_command, $(DOCKER_COMPOSE)) +.PHONY : check_docker_compose + +check_pre_commit: + $(call check_command, $(PRE_COMMIT)) +.PHONY : check_pre_commit