回显到 Makefile 中的同一行
我正在尝试在 Windows XP 中使用 git describe 为 GIT 创建一个 version.c 文件。为此,我在 makefile 中调用 gitdescribe ,如下所示:
@echo #include "version.h" > $(path)/version.c
@echo const char * build_ver = ^" >> $(path)/version.c
git describe >> $(path)/version.c
我的问题是我无法使用 echo 打印到同一行,因此我可以获得类似的内容: const char * build_ver = "v1.1-4-g00a6d8f"
我已经看到了一些从 git 获取版本号的其他方法,但是使用 awk 或 perl 并不是真正的选择,因为我不能假设它们将安装在特定系统。
我尝试将它分配给一个变量,但它抱怨 createProcess。
我将不胜感激任何帮助。
I am trying to create a version.c file for GIT using git describe in Windows XP. For this I am calling git describe in my makefile as follows:
@echo #include "version.h" > $(path)/version.c
@echo const char * build_ver = ^" >> $(path)/version.c
git describe >> $(path)/version.c
My problem is that I haven't been able to use echo to print to the same line so I can get something like:
const char * build_ver = "v1.1-4-g00a6d8f"
I have seen some other ways to get the version number from git, but using awk or perl is not really an option since I can't assume they will be installed on a particular system.
I've tried assigning it to a variable but it complains about createProcess.
I'd appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 man 1 echo:您可能正在寻找
-n开关。
如果您的 echo 不支持,请尝试 printf。
编辑:由于您似乎都不可用,请尝试在同一行上回显所有内容;类似于:
编辑 2:适用于 Linux / GNU make 的示例 makefile:
$ cat foo.make
$ make -f foo.make
const char *build_ver = "2008.07.01-102166-1620-g89db338";
See man 1 echo: you're probably looking for the
-n
switch.If your echo doesn't support that, try printf.
EDIT: since neither seem to be available to you, try echoing everything on the same line; something like:
EDIT 2: sample makefile that works on Linux / GNU make:
$ cat foo.make
$ make -f foo.make
const char *build_ver = "2008.07.01-102166-1620-g89db338";
这是我使用的一些代码的示例,它类似地为您创建带有构建时间和 git 版本的 ac 文件。这还包括将“gitdescribe”输出获取到bat文件变量中的技巧。
Here's an example of some code that I use that similarly creates a c file for you with build time and git version. This also includes the trick to get the "git describe" output into a bat file variable.