.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
Build number
Old
  (#1)
koraX
Member
 
koraX's Avatar
 
Status: Offline
Posts: 145
Join Date: Jan 2004
Location: Slovak Republic
Default Build number - 30-07-2004

What is the best way to record build number of your program in MSVC ?

I think build number stands for how many times you have build your project. It is stated in some programs, like version 3.4, build 1234. IMHO it is better than date, 'cause it is automatical and it is also good for you to not lost in your project.

So anyb knows how to do it ? Or is there some option in MSVC which does that for you ? I once made some program which increased some number in file, and was executed everytime i pressed build in MSVC. But i think there is a better way to do it.


kXBot
koraX's utils
- see my homepage for other projects (OpenGL CSG Editor, FAT16 Sim, NNetwork Sim, ...)
  
Reply With Quote
Re: Build number
Old
  (#2)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: Build number - 30-07-2004

"I once made some program which increased some number in file, and was executed everytime i pressed build in MSVC. But i think there is a better way to do it."

I think that is the only way to have an automated build version number. Visual Studio doesn't have this as a built in feature.

You could make a batch file that creates a .h file with the version number in it, then include that .h file in your source code when building the executable. The problem with this is that MSVC will always want to rebuild the executable each time that .h file it changed (because the date of the .h file is more recent than the date of the .exe file since the custom build steps only run AFTER the .exe file has been generated). You will need to set the date of the .h file back to BEFORE the date of the .exe (or the .cpp files). You can create a little utility that generates this .h file and sets the modification date/time back to something in the past (before the .cpp and .exe files).

botman
  
Reply With Quote
Re: Build number
Old
  (#3)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Build number - 31-07-2004

or use this one, which is adapted from the Quake source code:
Code:
unsigned short CGeneral::GetBuildNumber()
{
   const char *date = __DATE__;

   char *mon[12] =
   { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
   unsigned char mond[12] = 
   { 31,    28,    31,    30,    31,    30,    31,    31,    30,    31,    30,    31 };

   int m = 0, d = 0, y = 0;

   for (m = 0; m < 11; m++) {
      if (strncmp(&date[0], mon[m], 3) == 0)
         break;
      d += mond[m];
   }

   d += atoi( &date[4] ) - 1;
   y = atoi( &date[7] ) - 2000;

   unsigned short usBuildNumber = d + (int)((y - 1) * 365.25);

   // Is it a leap year?
   if ((y % 4) == 0 && m > 1) {
      usBuildNumber += 1;
   }

   return usBuildNumber - 1267;
}
  
Reply With Quote
Re: Build number
Old
  (#4)
koraX
Member
 
koraX's Avatar
 
Status: Offline
Posts: 145
Join Date: Jan 2004
Location: Slovak Republic
Default Re: Build number - 02-08-2004

I made my own program which will increase build number and store date and time of the last build in xml file. It also has history of all builds.

Program also creates .h file, so you can use build number/date/time in your program. It supports multi-project workspace/solution and several configurations (debug/release)

It can be easily implemented in MSVC .NET, because .NET has pre-build setup. So it will launch before compiling, so no problems with time attributes for .h file. You just have to compile it and add this to pre-build line of your program :
$(SolutionDir)buildnum.exe $(SolutionDir)build.xml $(SolutionName) $(ProjectName) $(ConfigurationName) ..\path\to\h\build.h

program is very simple, one .cpp file. Download it here

It is also using my XML parser, so it is good as an example for it.


resulting xml file can look like this :
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<kXBot>
	<kXBotdll>
		<debug>
			<latest>
				<build>4</build>
				<date>02.08.2004</date>
				<time>13:49</time>
			</latest>
			<history>
				<build date="02.08.2004" time="13:49">4</build>
				<build date="01.08.2004" time="11:33">3</build>
				<build date="31.07.2004" time="23:10">2</build>
				<build date="31.07.2004" time="15:14">1</build>
			</history>
		</debug>
		<release>
			<latest>
				<build>2</build>
				<date>02.08.2004</date>
				<time>14:00</time>
			</latest>
			<history>
				<build date="02.08.2004" time="14:00">2</build>
				<build date="01.08.2004" time="10:11">1</build>
			</history>
		</release>
	</kXBotdll>
</kXBot>
and .h file :
Code:
// koraXs build number logger 1.0
// Copyright (c) 2004, Jozef Wagner, http://neuron.tuke.sk/~wagner jowag@szm.sk

// This file is automatically generated, do not edit !

#define BUILD_NUMBER 2
#define BUILD_DATE "02.08.2004"
#define BUILD_TIME "14:00"
btw the code tag in this forum is somewhat broken, it adds one space at the begining, so first line is shifted


kXBot
koraX's utils
- see my homepage for other projects (OpenGL CSG Editor, FAT16 Sim, NNetwork Sim, ...)

Last edited by koraX; 02-08-2004 at 20:21..
  
Reply With Quote
Re: Build number
Old
  (#5)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Build number - 02-08-2004

euhm, i just manually update the build number. This is because i do not want it to be increased everytime i compile (build) something. THis is insane, sometimes i fix something and hit build to verify...


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Build number
Old
  (#6)
koraX
Member
 
koraX's Avatar
 
Status: Offline
Posts: 145
Join Date: Jan 2004
Location: Slovak Republic
Default Re: Build number - 02-08-2004

I did that too but my lazyness caused that I quite early lost track of my program versions, as I backup them a lot.

And I usually code in debug mode and switch to release when I think I done everything I wanted


kXBot
koraX's utils
- see my homepage for other projects (OpenGL CSG Editor, FAT16 Sim, NNetwork Sim, ...)

Last edited by koraX; 02-08-2004 at 20:20..
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com