One can often see "build number" in about boxes of different applications for PC. Wouldn't it be nice if uVision had some sort of 'build counter'? It would help in tracing version numbers and show the amount of work spent for writing software.
I wrote a little VBS program to do the same thing. Here it is:
'=========================================================== '=========================================================== Const sNumberFile = "c:\numfile.txt" Const sBuildFile = "c:\buildno.txt" '=========================================================== '=========================================================== Function Read_File (Filename) Dim objFSO Dim objTextStream Dim s Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Set objTextStream = objFSO.OpenTextFile(FileName,1,False) s = Trim (objTextStream.ReadAll) objTextStream.Close Set objTextStream = Nothing Set objFSO = Nothing Read_File = s End Function '=========================================================== '=========================================================== Function Write_File (FileName, Contents) Dim objFSO Dim objTextStream Dim s Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Set objTextStream = objFSO.CreateTextFile (FileName, True) objTextStream.WriteLine(Contents) objTextStream.Close Set objTextStream = Nothing Set objFSO = Nothing Write_File = 1 End Function '=========================================================== '=========================================================== Dim s s = Read_File (sNumberFile) s = Int(s) + 1 Write_File sNumberFile, s s = "#define Build_No " & s & vbCrLf & vbCrLf Write_File sBuildFile, s '=========================================================== '===========================================================
We use a file called compileinfo.h which is 'touched' each time we compile for our release target.
char *CompileTime = __TIME__; char *CompileDate = __DATE__;
printf( "Compiled on %s at %s\n", CompileDate, CompileTime );
Rather than adding an external 'touch' command, could you not just set the 'Always Build' option for this file in this Target? I do this with a timestamp.c in every Target of every project - I haven't tried it with just one Target of a project. Is there any particular reason to restrict it to just one Target of a project, though?