Makefile:如果不存在则忽略先决条件
有没有办法说,如果给定目标的先决条件不存在,则忽略该目标?
例如,我有以下一组文件夹
chrome_src_folders := $(chrome_src_folder)/content/* \
$(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*
这是我使用它的地方
$(jar_path): $(chrome_src_folders)
zip -urq $(jar_path) $(chrome_src_folders)
基本上皮肤或区域设置很可能不在那里,这会给我一个很好的错误。 如何避免该错误并使 chrome_src_folders
成为强制?或者我应该以某种方式过滤chrome_src_folders
并只留下那些存在的?
Is there any way to say that if prerequisite for the given target doesn't exist then ignore that target?
For instance, I have the following set of folders
chrome_src_folders := $(chrome_src_folder)/content/* \
$(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*
This is where I use it
$(jar_path): $(chrome_src_folders)
zip -urq $(jar_path) $(chrome_src_folders)
Basically skin or locale may very well not be there, which will give me a nice error.
How to avoid that error and make the chrome_src_folders
mandatory? or should I filter somehow chrome_src_folders
and leave only those which exist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有不止一种方法可以做到这一点;最简单的是使用通配符过滤列表
There's more than one way to do this; the simplest is to filter the list using
wildcard
两个想法;由于皮肤和语言环境文件夹是可选的,您是否需要将它们称为依赖项?如果需要的话,让构建命令来处理它们。所以就像这样:
如果您必须在依赖行上拥有正确的文件夹,以便捕获错误,我会编写一些宏来定义何时以及如何需要它们。然后相应地更新您的目标,以便仅在您知道需要这些目录时才需要它们。
Two thoughts; Since the skin and locale folders are optional, do you need to call them about as dependencies? Let the build commands take care of them if they need to. So something like:
If you have to have the right folders on the dependency line, so you catch errors, I would write some macros that define when and how you require them. Then update your targets accordingly to only require those directories when you know they are required.