Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"01-19-11 - Good practices"

13 Comments -

1 – 13 of 13
Blogger castano said...

> Ideally it would have the P4 sync state of the code as well

I did that for a while on the witness, but checking the svn status is sometimes quite slow and that triggered some complains when the game took too long to start. :(

January 19, 2011 at 3:57 PM

Blogger cbloom said...

Were you doing it at run time or build time?

The thing I haven't figured out how to do is to bake the build time & p4 sync number into the program in an elegant way.

You can easily have a BuildTime.cpp file that you echo that info into. The tricky thing is knowing when to generate that. I could easily generate it every time I hit F7, but that would cause linkage to happen even if no other code files changed.

What I want is to be able to hit F7 and have it be a nop if no compiling is needed. But if any compiling is needed, then run my script step to generate BuildTime.cpp and compile that before linkage.

January 19, 2011 at 4:49 PM

Blogger Sam said...

Wouldn't RCS keywords do what you want with regard to the revision number? You just have to change all your files where you want keyword expansion to type text+k.

January 19, 2011 at 6:04 PM

Blogger Tom Forsyth said...

> #define DCTQTableIndex_XX

Ah, perfect. I've always had a nagging feeling there was a trick like this to generate both enums and names, and never got around to figuring out the details. Thanks!

January 19, 2011 at 6:11 PM

Blogger castano said...

At runtime. The thing that I was most concerned with was reproducing bug reports. Ie, when the game crashes on an artist's PC, but not on mine it's usually due to bad local data. This has not happened recently, so I felt it was not worth the load delay, and hopefully we have other messages to diagnose these problems.

I still dump some subversion info and that at least tells us what's the last revision he was sync'd to. We check in our builds, so that gives us the exact binary he was using.

It may actually be worth dumping the extra info in our crash handler, hmm...

January 19, 2011 at 6:21 PM

Blogger cbloom said...

"Wouldn't RCS keywords do what you want with regard to the revision number?"

Eh, while that stuff is cool, I don't think it helps here at all unless there's some mojo I don't know.

What I want is for the EXE to contain a string which describes the exact p4 state to sync to in order to rebuild that same EXE. (If your client is sunc up to some changelist #, this would just be the changelist #, more generally it's a changelist # + a list of deviations from that; see for example http://stackoverflow.com/questions/47007/determining-the-last-changelist-synced-to-in-perforce).

January 19, 2011 at 6:27 PM

Blogger Sam said...

Ah right, yeah I'm not sure of any magic to do that. Hmm, although on the Perforce kb site here they list a keyword $Change$ but don't explain what it is, and after a quick google I couldn't find it explained in any RCS/CVS websites..

January 19, 2011 at 7:01 PM

Blogger Sam said...

Hm it might be possible to do a custom RCS keyword using that method to find the synced changelist in combination with a trigger script as mentioned here.

January 19, 2011 at 7:04 PM

Blogger cbloom said...

Yeah, the real problem though is that there's no way to trigger a script at the right time in VC.

There's no build event for "if you need to compile anything, let me generate another .c and please compile that too".

Actually the same kind of build event would be useful for my old AutoPrefs idea and other automatic-codegen type ideas.

January 19, 2011 at 7:07 PM

Anonymous Anonymous said...

>>> 3. Never leave magic numbers in code.

The worse I've seen is people putting in streaming code a magic constant related to hardware DMA address alignment and size limits, where there were actually #defined constants already available for that! Fuckers...

January 20, 2011 at 11:22 AM

Blogger RCL said...

What I want is for the EXE to contain a string which describes the exact p4 state to sync to in order to rebuild that same EXE. (If your client is sunc up to some changelist #, this would just be the changelist #, more generally it's a changelist # + a list of deviations from that)

Do you mean local changes by those deviations?

It can be done by inserting the custom build step which would dump:

1) p4 CL you last synced to (#have)
2) list of open files (p4 open)
3) diff of every open file (p4 diff )

Dumping such a 'build footprint' should result in a new .cpp file which would contain the above as string literal.

Also, perhaps the footprinting tool should compare the result for identity with existing file and not to overwrite it if not necessary, that would avoid "linking on every F7" problem.

February 12, 2011 at 6:09 PM

Blogger RCL said...

Addendum: I think you may fake a "let me generate a .cpp file if you pressed F7" event by adding a custom-built project (e.g. by make tool) to your solution and making your project depend on that. Haven't tried that though.

February 12, 2011 at 6:13 PM

Blogger cbloom said...

Hi RCL, as I've tried to explain before, getting a dump of the p4 build footprint is not the hard part. It's doing it *if and only if* the build is not fresh that I can't figure out. Otherwise your dump to a cpp file will cause a re-link that's unnecessary.

February 12, 2011 at 7:17 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.