制作类似支持自动删除临时文件和正则表达式模式规则的工具?
我正在搜索类似 make 的构建工具,它支持(除了通常的 make 功能之外):
- 自动删除临时创建的文件(例如在 GNU make 中)
- 规则模式中的正则表达式(例如 烹饪
关于1: 默认情况下,GNU make 会删除临时文件。例如,有以下规则:
%.c: %.y
some-comand
%.o: %.c
some-comand
如果您有一个文件 foo.y 并调用 make foo.o,则 make 派生必须首先创建 foo.c,然后创建 foo.o。准备好后删除临时文件 foo.c。
库克并不支持这一点。
关于2: 使仅支持后缀模式样式规则。例如这样(等效符号):.
%.o: %.c
some-comand
co: some-comand
在模式规则中允许正则表达式当然更强大。伪代码示例:
foo.+bar.o: foo.+bar.c
some-comand
foo\1bar.o: foo(.+)bar.c
some-comand
如果需要 fooXXXbar.o 并且 fooYYYbar.c 存在(或者 make 知道如何创建它),则第一个规则匹配(并且执行其命令)。第二个规则匹配,如果例如 fooXXXbar.o 是需要并且 fooXXXbar.c 存在。
您知道支持这些功能的版本吗?
I am searching a make like build tool that supports (besides usual make features):
- Automatic deletion of temporary created files (like in GNU make for example)
- Regular expressions in rule patterns (like e.g. in Cook
About 1:
By default GNU make deletes temporary files. For example have these rules:
%.c: %.y
some-comand
%.o: %.c
some-comand
If you have a file foo.y and call make foo.o then make derives that is has to create first foo.c and then foo.o. After it is ready it delete the temporary file foo.c.
Cook does not support this.
About 2:
Make just support suffix pattern style rules. For example like this (equivalent notations):
%.o: %.c
some-comand
.c.o:
some-comand
Allowing regular expressions in rules of patterns is of course more powerful. Pseudo-code examples:
foo.+bar.o: foo.+bar.c
some-comand
foo\1bar.o: foo(.+)bar.c
some-comand
The first rule matches (and its command is executed) if for example fooXXXbar.o is needed and fooYYYbar.c exists (or make knows how to create it. The second rule matches, if for example fooXXXbar.o is needed and fooXXXbar.c exists.
Do you know a build that supports these features?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了 GNUMake 之外,我不太熟悉任何构建工具;它不处理正则表达式,但它可以处理这些情况。第二条规则很简单:
第一条规则需要一些努力:
I'm not really familiar with any build tool but GNUMake; it doesn't handle regexes, but it can handle these cases. The second rule is easy:
The first one requires some kludgery:
GNU Make 显然有 1,并且需要 2(其维护者似乎同意),但是有不是它的完整设计,更不用说补丁了。
您可以使用 $(call)、$(eval) 甚至 $(shell) 等函数在 GNU make 中模拟此功能,
和/或生成辅助 Makefile 并包含它们,但结果很难阅读。
GNU Make obviously has 1, and needs 2 (its maintainers seem to agree), but there isn't a full design for it, let alone a patch.
You can emulate this functionality in GNU make by using functions such as $(call), $(eval) or even $(shell),
and/or generating auxiliary Makefiles and including them, but the results are quite hard to read.
.SECONDEXPANSION
扩展可以提供很大帮助。例如:基本上,
$munge
应该返回给定目标的源。您可以定义函数来执行几乎任何操作,甚至可以通过$(shell...)
调用 perl(尽管$shell
会在一定程度上损害性能)。一个简单的可能是:.SECONDEXPANSION
expansion can help quite a lot. For example:Basically,
$munge
should return the source given the target. You can define your function to do practically anything, even calling perl via$(shell...)
(though$shell
hurts performance somewhat). A simple one might be: