我正在尝试设置一个 nmake makefile 以自动将我们的 balsamiq 模型文件导出为 png 文件,但恐怕我无法弄清楚如何制定通用规则来执行此操作,而无需明确列出所有文件我要出口。
此页面详细介绍了导出文件的命令行语法,此页面包含一个示例,该示例看起来包含 .obj 文件的通用规则.exe 文件。
到目前为止我尝试过的 makefile 看起来像这样:
.bmml.png:
"C:\Program Files\Balsamiq Mockups\Balsamiq Mockups.exe" export $< $@
但这不起作用。
如果我只是运行 nmake (使用一些过时的 png 文件),nmake 就会这样做:
[C:\Temp] :nmake
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
[C:\Temp] :
如果我要求它构建一个特定文件,它会这样做:
[C:\Temp] :nmake "TestFile.png"
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1073: don't know how to make '"TestFile.png"'
Stop.
[C:\Temp] :
有哪位 nmake 大师可以帮助我解决问题吗?
一个示例 makefile 通过复制 .txt 文件来简单地从 .dat 文件中生成 .dat 文件进行实验,如下所示:
.txt.dat:
copy $< $@
这也没有执行任何操作,所以显然我不明白这种通用规则是如何工作的。 我是否需要在上面指定一个目标,以某种方式列出我想要的文件?
I am attempting to set up an nmake makefile to export our balsamiq mockup files to png files automatically, but I'm afraid I can't make heads nor tails of how to make a generic rule for doing so, without explicitly listing all the files I want exported.
This page details the command line syntax for exporting the files, and this page contains an example which looks like it contains a generic rule for .obj files to .exe files.
The makefile I have tried so far looks like this:
.bmml.png:
"C:\Program Files\Balsamiq Mockups\Balsamiq Mockups.exe" export lt; $@
But this doesn't work.
If I simply run nmake (with some outdated png files), nmake just does this:
[C:\Temp] :nmake
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
[C:\Temp] :
If I ask it to build one specific file, it does this:
[C:\Temp] :nmake "TestFile.png"
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1073: don't know how to make '"TestFile.png"'
Stop.
[C:\Temp] :
Any nmake gurus out there that can set me straight?
An example makefile which simply makes .dat files from .txt files by copying them, to experiment with, looks like this:
.txt.dat:
copy lt; $@
this does nothing as well, so clearly I'm not understanding how such generic rules work. Do I need to specify a goal above that somehow lists the files I want?
发布评论
评论(2)
NMAKE 模式规则很像 GNU make 的老式后缀规则。 就您而言,您一开始就几乎是正确的,但您缺少 .SUFFIXES 声明。 例如:
我认为这只是您解决方案的一部分,因为您还提到希望避免显式列出所有要转换的文件。 不幸的是,我不知道在 NMAKE 中是否有一种非常干净的方法来做到这一点,因为它只扩展依赖项列表中的通配符,而您在依赖项列表中真正想要的并不是已经存在的文件列表(*.bmml文件),但将从这些文件(*.png 文件)创建的文件列表。 尽管如此,我认为你可以通过像这样的递归 NMAKE 调用来实现你的目标:
在这里,NMAKE 会将
all
的 prereq 列表中的*.bmml
扩展到 .bmml 列表中。 bmml 文件放在目录中,然后它将启动一个新的 NMAKE 实例,指定要构建的目标为文件列表,其中所有.bmml
实例替换为.png
。 因此,将它们放在一起:如果我创建文件 Test1.bmml 和 Test2.bmml,然后运行此 makefile,我会得到以下输出:
当然,如果您有很多这样的 .bmml 文件,则可能会运行命令- 行长度限制,所以要小心。 在这种情况下,我建议要么明确列出源文件,要么使用功能更强大的 make 工具,例如 GNU make(它以多种形式适用于 Windows)。
NMAKE pattern rules are a lot like GNU make old-school suffix rules. In your case, you had it almost right to begin with, but you were missing the .SUFFIXES declaration. For example:
I think this is only part of your solution though, because you also mentioned wanting to avoid explicitly listing all of the files to be converted. Unfortunately, I don't know of a very clean way to do that in NMAKE, since it only expands wildcards in dependency lists, and what you really want in your dependency list is not the list of files that already exist (the *.bmml files), but the list of files that will be created from those files (the *.png files). Nevertheless, I think you can achieve your goal with a recursive NMAKE invocation like this:
Here, NMAKE will expand
*.bmml
in the prereq list forall
into the list of .bmml files in the directory, and then it will start a new NMAKE instance, specifying the goals to build as that list of files with all instances of.bmml
replaced by.png
. So, putting it all together:If I create files Test1.bmml and Test2.bmml and then run this makefile, I get the following output:
Of course, if you have very many of these .bmml files, you may run afoul of command-line length limitations, so watch out for that. In that case, I recommend either explicitly listing the source files, or using a more capable make tool, like GNU make (which is available for Windows in a variety of forms).
这对你有用吗? 将其放入 MAKEFILE.:
然后运行:
我没有 Balsamiq,所以我无法测试它,但在我的情况下,如果我有以下 MAKEFILE.:
并在文件夹中运行
nmake /A
myFile.txt,它将创建 myFile.dat。Will this work for you? Put this in MAKEFILE.:
Then run:
I don't have Balsamiq so I can't test this but in my case if I have the following MAKEFILE.:
and run
nmake /A
in a folder with myFile.txt, it will create myFile.dat.