使用 Makefile 中的通用目标进行 make 的 Bash 补全
我有一个 Makefile,其中大多数目标通常都是通过固定序列创建的。 bash 完成似乎仅建议完成正常目标,例如,
target_name:
#$@
而不建议完成通用目标。 有没有办法让 bash 完成完成所有目标,即使它们没有像上面的示例那样明确? 更具体地说,假设我定义了一个目标名称列表,并执行如下操作:
list=target1 target2
$(list):
#$@
是否有某种方法可以使这些目标可用于 bash 完成? 或者,更高级的是,假设我有两个列表,并且我希望目标由两个列表的元素的所有可能组合组成。 我还可以让这些目标可用于 bash 完成吗?
I have a Makefile where most of my targets are created generically through a canned sequence. It seems that bash completion only suggests completions for normal targets, e.g.
target_name:
#$@
and not for generic targets. Is there any way to make bash completion complete all the targets, even though they are not made explicit as the example above? To be more spesific, lets say I define a list of target names, and do something like this:
list=target1 target2
$(list):
#$@
Is there some way to make these targets available for bash completion? Or, even more advanced, say I have two lists and I want the targets to be made of all possible combinations of the elements of the two lists. Can I also have these targets available for bash completion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
-q
阻止 Make 实际运行任何内容,而-p
要求它转储其数据库。然后你需要做的就是编写并注册一个完成函数< /a> (示例)。
The
-q
prevents Make from actually running anything, and the-p
asks it to dump its database.Then all you need to do is write and register a completion function (example).
AFAIK,没有可行的解决方案。
此命令:
将扩展您的 makefile 目标。
您可以尝试将其添加到您的
/etc/bash_competion
中,但我认为它需要进一步调试以应对更复杂的情况。There is no working solution, AFAIK.
This command:
will expand your makefile targets.
You may try to add it into your
/etc/bash_competion
, but I think it will need further debugging to cope with more complex situations.