微软nmake:是否可以从shell命令输出中定义宏
Microsoft nmake: Is it possible to define macros from shell command output?
在使用Microsoft Visual Studio的nmake编写代码时,我正试图将SVN修订信息保存到宏中。
在GNU make中,我做了一些类似的事情:
SVN_REVISION=r$(shell svnversion -n)
所以我得到了例如:SVN_REVISION=r10001
这也可以在微软nmake中实现吗?
提前谢谢。
使用上面提到的技术和递归调用,可以通过以下方式完成:
!IFNDEF MAKE
MAKE=NMAKE
!ENDIF
!IFNDEF SVN_REVISION
! IF [echo off && FOR /F "usebackq" %i IN (`svnrevision -n`) DO SET SVN_REVISION=%i && $(MAKE) /$(MAKEFLAGS) /nologo /f $(MAKEDIR)Makefile && exit /b ] == 0
! MESSAGE Make completed
! ELSE
! ERROR Error in nmake
! ENDIF
!ELSE
# $(SVN_REVISION) now contains the string returned from the command `svnrevision -n`
!MESSAGE SVN_REVISION is $(SVN_REVISION)
# Put the parts of the makefile that depend on SVN_REVISION here
!ENDIF
#
# To be a valid makefile it must have some rules to perform
all:
@echo;$(SVN_REVISION)
相关文章:
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- C++编译器命令 C++ 不会生成输出
- 使用提升过程获取 shell 命令的标准输出
- cmake add_custom_command + Xcode:多输出 = 多命令调用
- gdb 中的列表命令不输出我编写的代码
- Windows 10命令提示符的输出不正确
- 如何在C++中执行命令并获取命令的返回代码标准输出和标准
- 获取使用p4api运行的Perforce命令的输出
- 执行ls命令并打印输出
- bcdedit 文件输出不起作用,但其他命令可以
- 在结束运行之前获取 c++ 中的 shell 命令输出
- 输出错误命令的条件语句
- 将 Tcl 中的命令输出重定向到文件时,文件以 DOS 格式生成
- 将 Linux system() 调用命令的输出重定向到仅可变的
- popen() 将执行命令的输出写入 cout
- 在 Windows 命令行中运行.exe在使用 2 种相同方式执行时会产生不同的输出
- 在程序中获取 Linux 'dd' 命令的输出时遇到问题C++
- 终端命令输出到 CPP 中的数组
- 试图输出命令行参数会产生一个看似随机的十六进制数