Makefile:如果不存在则忽略先决条件

发布于 2024-09-01 09:42:45 字数 485 浏览 4 评论 0原文

有没有办法说,如果给定目标的先决条件不存在,则忽略该目标?

例如,我有以下一组文件夹

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

¢好甜 2024-09-08 09:42:45

有不止一种方法可以做到这一点;最简单的是使用通配符过滤列表

chrome_src_folders  := $(wildcard $(chrome_src_folder)/content/*  \
    $(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*)

There's more than one way to do this; the simplest is to filter the list using wildcard

chrome_src_folders  := $(wildcard $(chrome_src_folder)/content/*  \
    $(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*)
千紇 2024-09-08 09:42:45

两个想法;由于皮肤和语言环境文件夹是可选的,您是否需要将它们称为依赖项?如果需要的话,让构建命令来处理它们。所以就像这样:

chrome_content_folder := $(chrome_src_folder)/content/*
chrome_content_optional := $(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/* 

$(jar_path): $(chrome_content_folder)
    zip -urq $(jar_path) $(chrome_content_folder) $(chrome_content_optional)

如果您必须在依赖行上拥有正确的文件夹,以便捕获错误,我会编写一些宏来定义何时以及如何需要它们。然后相应地更新您的目标,以便仅在您知道需要这些目录时才需要它们。

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:

chrome_content_folder := $(chrome_src_folder)/content/*
chrome_content_optional := $(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/* 

$(jar_path): $(chrome_content_folder)
    zip -urq $(jar_path) $(chrome_content_folder) $(chrome_content_optional)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文