Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft nmake: Is it possible to define macros from shell command output?

I am trying to save my SVN revision info into a macro while making my code by Microsoft Visual Studio's nmake.

In GNU make, I do something like:

SVN_REVISION=r$(shell svnversion -n)

so I get for example: SVN_REVISION=r10001

Is this possible to do in Microsoft nmake too?

Thank you in advance.

like image 219
KinoP Avatar asked Nov 12 '14 02:11

KinoP


1 Answers

Using the techniques mentioned along with a recursive call to make, it can be done this way:

!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)
like image 94
Brian Tompsett - 汤莱恩 Avatar answered Nov 14 '22 21:11

Brian Tompsett - 汤莱恩