有没有办法让命令make clean
需要用户确认?我错误地执行了它,现在我必须等待6个小时才能再次完成构建。
Makefile
由cmake
创建。
所需的工作流程:
> make clean
> [make] Are you sure you want to remove all the built files? [Y/N]
> N
> [make] Target 'make clean' not executed.
> make clean
> [make] Are you sure you want to remove all the built files? [Y/N]
> Y
> [make] Target 'make clean' executed.
答案 0 :(得分:9)
我不熟悉cmake,但对于gnu make,一个可能的黑客将是:
clean: check_clean
check_clean:
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
.PHONY: clean check_clean
如果check_clean
失败(用户未输入y
),则make会在执行清除之前退出并显示错误。