[p4perl] integrating perforce with a build system.

Roger Day roger.day at globalgraphics.com
Wed Mar 2 06:19:01 PST 2005

Apologies for raising what seemed an already settled issue, but the project
leader responsible for introducing perforce into GG has raised the
possibility that the clientspec (or workspace) can be changed by the API.
How can I use the perl API to change the clientspec, in particular the
perforce root directory?

                      Tony Smith                                                                                                        
                      <tony at smee.org>          To:       p4perl at perforce.com                                                            
                                               cc:       "Roger Day" <roger.day at globalgraphics.com>                                     
                      21/02/2005 17:30         Subject:  Re: [p4perl] integrating perforce with a build system.                         

On Monday 21 February 2005 13:20, Roger Day wrote:
> Well, I'm almost there
> use P4;
> # Initialisation
> my $p4 = new P4;
> $p4->Init() or die( "Failed to connect to Perforce" );
> $return = $p4->SetCwd("c:\\users\\rday\\perforcews\\");
> print "$return\n";
> $return = $p4->Run("sync","-f","//depot/makedist/...");
> print "@$return\n";
> SetCwd seems to have no effect at all. It's overriden by the client spec.

Right. SetCwd() will only make a difference to how Perforce computes
paths. For example:

    $p4->Run( "sync", "../../makedist/..." );

The client spec is the ultimate arbiter of what goes where.

> Which is crucial to what I'm doing. Do I have to edit the client spec
> time I want to do a checkout?

Not unless you're intending to work with different files. The normal usage
would be to have your client spec map ALL of the files your build system
would work with and then either 'p4 sync' or 'p4 sync-f' to have Perforce
populate the build tree. Then you build as normal.



More information about the p4perl mailing list