Are the new Delphi XE2 autogenerated build numbers linked to 1.1.2000 00:00:00?
Asked Answered
W

1

5

In Delphi XE2 the automatically generated build numbers functionality now uses some kind of date and time generated values, like this:

2.4.4386.838

The last two numbers change each time you build and are based on the current date and time:

Major = 2 (user defined)
Minor = 4 (user defined)
Release = 4386 (number of days since Jan 1 2000)
Build = 838 (number of seconds since 00:00:00)

I guess this new format for Release and Build numbers was borrowed from the .NET implementation which does something very similar. In .net, the last number (Build) is equal to the number of seconds since midnight local time, divided by 2. See this link for details on .net implementation: Determining Build Date the hard way

If this can be relied upon to stay this way, then now we have a better way to determine the compilation time instead of

  1. Using IDE plugins

  2. Using PE Headers hacks

The questions is not how to return to the old autoincrement version numbers functionality.

The questions is does XE2 really use the date and time as I showed above, starting from Jan 1, 2010 and adding days and seconds in Build and Release numbers?

Williwaw answered 3/1, 2012 at 22:17 Comment(14)
The answer you are looking for can be found in TOndrej's answer here: #8437800D
@David the pointed question is about how to do it yourself. My questions is whether Delphi XE2 is now doing this for us and we should get rid of the suggestions exactly mentioned in the question you pointed. I belive my questions is a bit different.Williwaw
I guess I didn't understand the main thrust of your question. Do you think that backing it out of the version resource is easier? Can't see any documentation that says how Build and Release are set? You've discerned this by observation presumably? Do you know what time zone is used? UTC? Local time?D
Where did you get your information about what the build number means? I can't find it anywhere in the docs for XE or XE2.Thremmatology
@Ken - this is eaxctly the question. I have not read it anywhere. Knowing how those work in .NET I simply deduced that those numbers mean something. It would be nice if a Embarcadero developer shades some light on this or maybe a good ASM hacker like Andreas Hausladen (something which I am not) checks what the compiler does in OllyDbg.Williwaw
If you're wanting an "Embarcadero developer" to answer, you should probably be asking in the Embarcadero forums. So what you're basically saying here is that your entire question is based on an assumption about what the build number contains that may or may not be actual fact? Sorry, but voting to close as "not a real question".Thremmatology
@ken in fact it is almost trivially easy to work out what the implementation is and amazingly it contains a howling flaw.D
Seems like I haven't done my googling homework first: QC 100940, forums.embarcadero.com/thread.jspa?threadID=65196, forums.embarcadero.com/thread.jspa?messageID=418504 Seems like Remy Lebeau mentioned "Auto-generate now uses timestamps instead of integers for the Release and Build fields."Williwaw
@David, yep. Saw your answer.Thremmatology
.NET does use the Jan 1, 2000 epoch, not the Unix epoch.Uhland
@Allen my bad. Verison numbers start from Jan 1, 2000 indeed. I was mistaken by the linker timestamps which are Jan 1, 1970 as per codinghorror.com/blog/2005/04/…Williwaw
Ugh, why you are referring to diary while authoritative documentation exists? Anyway, this ridiculous idea should be reposted directly to dailywtfSherwin
@Warren - I have asked exactly what I needed to ask and got a satisfying answer. I do not need the old functionality back. And I never liked the flamish Borland forums-where on contrary I feel deep respect to Allen Bauer and David Heffernan and codinghorror.com. I got exactly what I needed from SO - an answer for my question. Now you feel free to close, moderate, delete, downvote it.Williwaw
Well, I'm wrong sometimes. :-) I retract my earlier statement. I edited your question, to hopefully make what you are asking more clear in English. I hope it helps.Javierjavler
D
7

The encoding cannot be what you think it is. The release and numbers are packed into a single 32 bit DWORD. That means that there are only 16 bits available for all the seconds in a day. There are 86400 seconds in a day which is greater than 216.

Rather oddly the Delphi implementation appears to wrap around when it reaches 216 seconds, ~18.2 hours. So at the moment, it is 22:50 in my time zone (UTC), but the auto generated release number is 16753, or around 4.6 hours. Add back the missing 18.2 hours from the wrap around and bingo, it's 22:50.

It looks like the Visual Studio people got it right, because they took the number of seconds after 00:00 and divided by 2. It would also appear therefore that the Delphi auto generated release numbers will not be monotone increasing with time, will not be unique and so on.

This seems to me to be a bug which I have submitted as QC#102343. Note that the bug was introduced in XE2 update 3. It was not present in previous versions. Note also that the handling of the release number has changed from update 2 to update 3.

D answered 3/1, 2012 at 22:53 Comment(14)
It should be (number of seconds since midnight) div 2. That makes the max 43200, which does fit in 16 bits. If it is wrapping, that is most certainly a bug.Uhland
@Allen hmm, my quick trial looked like it was wrapping as you can see. Do I need to submit a QC or can you take it from here.D
Best that you submit it... then you get the credit and can track it.Uhland
Oh, and before people freak out about the (OMG) only a 2 second resolution!... Please think about it... who can build, make a change, build again within 2 seconds?Uhland
Will do. Tomorrow. It's quite late here in UTC land! ;-) P.S. Great work with XE2, it's a very fine Delphi.D
@allen but if there's any tool that can compile fast enough for 2s turnaround it is delphi!!!D
@David - once you put in your comment the QC number I will mark this question as closed. Allen - very fine release indeed!Williwaw
@David - you may compile it in 2 seconds but I doubt you will be able to prepare the installer, upload on FTP, update the help page, wikis, and post the fuzz about the new release in 2 seconds. My checklist for publishing a new version of my product has more than 30 steps and they all take at least 30 minutes. So "seconds div 2" works fine for me.Williwaw
I took a while to wrap my head around this, but as an "auto" feature, this is actually pretty usable approach (the .net working implementation, not the XE2 slightly busted implementation as per David's bug discovery).... If anybody wants the old auto-incremented build numbers back again, it should be pretty easy to put them back in yourself. I think I will try to do that for a blog post...Javierjavler
@Allen I've submitted a QC report. I discovered that this is actually a regression from update 2 to update 3. It looks like you changed the way the release number is set (perhaps to line up with how things are done in VS/.net) and inadvertently broken the other number. The build number worked fine in update 2 and was (number of seconds since midnight) div 2 as intended. All this should be documented by the way. It doesn't appear to be at the moment.D
What i just need is a way to set build numbers when building from the command line, so I can pull build number from the build tools and put them into the executables without the need resource manipulations scripts (see QC #70564) and map each executable to a given set of file revision in the source control sytem.Rouble
@Idsandon Well, I do this by building my own .rc file with a version resource and a pre-build Perl script to fill it out. I personally think that when you want this level of control it's not unreasonable for you to have to do that. That said, you could set the VerInfo_Keys property with an msbuild command line setting.D
@GadDLord Yeah the 2s thing was a bit of a joke. But the point is that Delphi compiler is astoundingly fast. Try compiling a million lines of C++ code and see how long that takes.D
@idsandon: google for dzprepbuild, that's my solution for IDE and commandlineDelighted

© 2022 - 2024 — McMap. All rights reserved.