This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Build counter

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.

  • This would normally be handled by a version/revision control system such as SCCS, SourceSafe, etc.

    uVision provides Pre-configured template files for: Intersolv PVCS,
    Microsoft SourceSafe, and MKS Source Integrity.
    (See the description of the SVCS menu in the Getting Started guide).

  • We use the custom translator feature to call an app to modify constants
    in an include file.

  • I should have thought of that myself. Now I'm going to do it in my project. Thank you for the idea.

  • Just to let you know, when we installed version 2.06 I had to rename the build# include file. We had build.h but I was forced to change it because uVision wouldn't let me pick a custom translator for .h files. I now call it build.rev.

  • I have written a little DOS application that searches in a file (file name is calling parameter) for "buildnr" and then determines, if there is some #define or db or = structure. If so, it modifies that file (counts up the buildnr string) and backs up the old file.

    This DOS program can be called by my developement environment (that came with my ICE) automatically after linking. This way, I am counting up my build counter every time I link the project.

    I usually create an include file (*.h) or (*.inc) that holds that buildnr definition. This way, I prevent that the file is still open and the counter programm cannot access it. (I don't open that little file in my environment).

    If anybody is interested in that buildcnt.exe, just ask, I will e-mail it.

    Sven

  • 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
    
    
    '===========================================================
    '===========================================================
    

    This program works by reading the contents of sNumberFile. This file MUST exist. It contains the last build number. For testing I created the file using notepad and entered "1" without the quotes.

    The current build number is incremented and written back to sNumberFile.

    sBuildFile is created using the NEW build number. The contents of this file are "#define Build_No xxx".

    Hopefully, this will help someone.

    Jon

  • We use a file called compileinfo.h which is 'touched' each time we compile for our release target.

    char *CompileTime = __TIME__;
    
    char *CompileDate = __DATE__;
    

    The target options/Output tab has the following setting to run the external program 'touch':

    touch "compileinfo.h"

    We use the 'touch' program supplied with the mingw tools.

    In our code we have the line:

      printf( "Compiled on %s at %s\n", CompileDate, CompileTime );
    

    which, when the program comes to life, prints the date and time that the program was compiled. Having the compileinfo.i as a separate file (i.e. not just touching the main source file) is necessary on our system to avoid CVS thinking that the main source file has been altered.

    I like Jon's method though, thanks for the script!

  • 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?