[英]Why find command failing from make file
I am working on modifying a windows make file. 我正在修改Windows Make文件。 The file, which is part of legacy build code has the following lines --
该文件是旧版构建代码的一部分,具有以下几行内容-
WROOT := "MyBuild/win/Program Files/Windows Kits/10"
ROOT_SDK_Version := $(shell find $(WROOT_WIN10_SDK)/Include -maxdepth 1 -type d -path $(WROOT_WIN10_SDK)/Include/[0-9.]* )
The SHELL variable is mapped to bin/sh but when I print the variable ROOT_SDK_Version, it is empty. SHELL变量映射到bin / sh,但是当我打印变量ROOT_SDK_Version时,它为空。 However, when I manually invoke the find command with the same arguments, it is giving the expected out.
但是,当我使用相同的参数手动调用find命令时,它给出了预期的结果。
To debug this issue, I modified above line in make file as below 为了调试此问题,我修改了make文件中的以下行,如下所示
ROOT_SDK_Version := $(shell find $(WROOT_WIN10_SDK)/Include -maxdepth 1 -type d -path $(WROOT_WIN10_SDK)/Include/[0-9.]* 2> output.txt )
And I see the contents of the file output.txt after running make - 我在运行make后看到文件output.txt的内容-
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
So why is the find command failing when running from make file but is successful when I run it manually using the same arguments? 那么,为什么从make文件运行时find命令失败,但是当我使用相同的参数手动运行它时却成功了? Any pointers appreciated.
任何指针表示赞赏。
Providing more context- 提供更多背景信息-
WROOT_WIN10_SDK := "$(GOBUILD_CAYMAN_MSVC_DESKTOP_ROOT)/win/Program Files/Windows Kits/10" WROOT_WIN10_SDK:=“ $(GOBUILD_CAYMAN_MSVC_DESKTOP_ROOT)/ win / Program Files / Windows Kits / 10”
The variable GOBUID...is== E:/Myscpetre20/depot/sim/sim-20fq1/build/gobuild/compcache/cayman_msvc_desktop/ob-11144741/windows2016-clean 变量GOBUID ... is == E:/ Myscpetre20 / depot / sim / sim-20fq1 / build / gobuild / compcache / cayman_msvc_desktop / ob-11144741 / windows2016-clean
So WROOT_WIN10_SDK is == "E:/Myscpetre20/depot/sim/sim-20fq1/build/gobuild/compcache/cayman_msvc_desktop/ob-11144741/windows2016-clean/win/Program Files/Windows Kits/10" 因此WROOT_WIN10_SDK = =“ E:/ Myscpetre20 / depot / sim / sim-20fq1 / build / gobuild / compcache / cayman_msvc_desktop / ob-11144741 / windows2016-clean / win / Program Files / Windows Kits / 10”
I think the argument to the -path
option needs to be quoted -- otherwise the glob *
will be expanded by the shell rather than being passed to find
. 我认为
-path
选项的参数需要用引号引起来-否则glob *
将由shell扩展,而不是传递给find
。 So... 所以...
ROOT_SDK_Version := $(shell find $(WROOT_WIN10_SDK)/Include -maxdepth 1 -type d -path '$(WROOT_WIN10_SDK)/Include/[0-9.]*' )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.