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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With