Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何检查Makefile cmd.exe调用的退出状态?_Windows_Makefile - Fatal编程技术网

Windows 如何检查Makefile cmd.exe调用的退出状态?

Windows 如何检查Makefile cmd.exe调用的退出状态?,windows,makefile,Windows,Makefile,我想检查在我的构建过程中是否在Windows中安装了GIT,然后再对此进行处理。所以,这个想法是 check_git: git > gitcheck GIT_PRESENT = $(shell type gitcheck) ifeq ($(findstring recognized, $(GIT_PRESENT)), recognized) #do nasty stuff else #do other stuff endif 因为cmd.exe说: Git未被识别为内部

我想检查在我的构建过程中是否在Windows中安装了GIT,然后再对此进行处理。所以,这个想法是

check_git:
    git  > gitcheck

GIT_PRESENT = $(shell type gitcheck)

ifeq ($(findstring recognized, $(GIT_PRESENT)), recognized)  
#do nasty stuff
else
#do other stuff
endif
因为cmd.exe说:

Git未被识别为内部或外部命令, 可操作的程序或批处理文件

如果没有安装Git,我只想检查可识别的关键字

当然,它不起作用,因为我意识到我必须检查退出状态,这是我在线程中读到的

我使用的是cs make 3.81,这就是我首先生成文件的原因。 我意识到也许做这件事的好方法并不存在。。。另外,我对这些东西还比较陌生,这是我的第一篇帖子,所以要温柔。
谢谢

我相信GIT_PRESENT:=$shell GIT-help>nul 2>&1&如果%errorlevel%eq 0 echo GIT_PRESENT在默认的%PATH%中找到GIT时会将GIT_PRESENT变量设置为GIT_PRESENT,如果它不在%PATH%中,则在调用中使用显式路径。

好的,下面是我在Etan慷慨帮助下所做的:

GIT_PRESENT := $(findstring Git, $(subst \,$(space),$(shell echo %path%)))

ifeq ($(GIT_PRESENT),Git)  
    git_info = Git detected!
    ver_num = $(lastword $(shell git tag))
# and more nasty business...
else
    git_info = Git not detected! Values below set to default.
    ver_num  := 0.00.000
# and even more nasty business...
endif

当然,Git必须包含在%path%中,但无论如何,Git从Windows cmd.exe运行是一个先决条件,你是想基于此控制目标规则行为还是基于此控制实际的生成级别行为?我想生成一些状态标志,并将其集成到我的源代码中,例如,如果Git存在,则此标志会出现在我的一个结构中:-D'GIT_FLAG=$FLAG'',那么这就是根据GIT的存在进行级别更改吗?设置make变量以供以后使用?是的,似乎是这样!很抱歉,我在理解您的语义时遇到一些问题,因为我对这方面比较陌生,英语不是我的母语。请尝试GIT_PRESENT:=$shell GIT-help>nul 2>&1&if%errorlevel%equ 0回显GIT_PRESENT,看看这是否适用于您。当GIT存在时,应该将$GIT_PRESENT设置为GIT_PRESENT,否则为空。如果git不在%PATH%中,则需要将该路径放在该命令行上。