[p4] Adding a Changelist # to C++ code...?

Jeff A. Bowles jab at pobox.com
Fri Feb 29 16:15:02 PST 2008

He's using "ant" conventions, because anyone who can will use "ant" for Java
But it's a really easy substitution, to instead run a very simple script
that runs "sed" (or perl or ...) to replace @change.list.number@ with the
exact "p4 changes -m1 -s submitted //depot/codelinename/..." answer.

The question itself, is easy to put into the wrong category.

It's really a "how do I generate this extra file at build-time to include in
the release" question.  Take your build-nerd aside and show him/her this
thread, couched in this language.

  - Jeff Bowles

ps. I spoke about this at the Perforce 1999 (or was it 2000?) User
Conference.  I had two versions of that file - the official-build was
created at build-time, but the checked-in version in development builds had
a different hard-coded string.  (Something about how it was built from a
development workspace, so the binary wasn't official.)

On Tue, Feb 26, 2008 at 12:42 AM, Troughton, Robert <rtroughton at midway.com>

> Hi,
> Thanks for the reply - this sounds like exactly what we need. What do I
> do with the code that you pseudo'd, though...? Is there somewhere that I
> can compile this such that our server will do this?
> Sorry... I've not done much work with Perforce other than using the
> commandline tools for various simple scripts...
> Regards
> Robert
> -----Original Message-----
> From: perforce-user-bounces at perforce.com
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of Slava Imeshev
> Sent: 26 February 2008 07:03
> To: perforce-user at perforce.com
> Subject: Re: [p4] Adding a Changelist # to C++ code...?
> > So then I started to wonder whether it could be done
> > server-side, e.g. with a submit trigger.  At submit time, you
> > know (1) the changelist number, and (2) that you are "cleanly
> > synced".  I have a feeling, though, that it's not possible to
> > edit a file in a trigger and "p4 submit" it.  Or is it?
> >
> > Is there a server side solution to this?
> Yes, there is, and it is trivial. This case is handled routinely on the
> server side by a build
> management system. At the build time the build/release management system
> supplies the change list
> number that it used to do p4 sync to the build script that in turn
> generates a version file from a
> template. Using pseudo-code:
> class Version {
>    int changeListNumber() {
>      return "@change.list.number@";
>    }
>  String version() {
>     return "MyProduct V.2.0." + changeListNumber();
> }
> Token @change.list.number@ is replaced with the change list number at
> the build time. The result
> is compiled and packaged. This, by the way, is the only way to assign
> the factual build change
> list number to the product version.
> Hope this helps.
> Regards,
> Slava Imeshev
> www.viewtier.com
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user

Jeff Bowles - jeff.a.bowles at gmail.com

More information about the perforce-user mailing list