[p4perl] integrating perforce with a build system.

Roger Day roger.day at globalgraphics.com
Mon Feb 21 05:20:43 PST 2005

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.
Which is crucial to what I'm doing. Do I have to edit the client spec every
time I want to do a checkout?


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

Ok, I've found SetCWD("<some folder name>") which i'm assuming will do the
right thing?
O'wise, on talking with a coworker, it appears that sync takes arguments
such that


may do what I want.



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

Is the depot on the server or the client?
How do I tell it the directory on the client I want it synchronised to?

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

Hi Roger,

> I'm looking at integrating perforce with our in-house build scheduling
> system. Our build scripts are written in Perl and I've installed the P4
> win32 perl code and the test examples work. However I'm a newbie to
> perforce.
> Our internal build system creates a fresh set of sources every day timed
> for  midnight. To do this, the build scripts instruct the SCM system to
> download a clean set of sources into an empty directory (the sources
> include the build tools neccessary for building those sources). So
> essentially my problem is for a P4 client (in this case, in the form of
> P4Perl)  to connect to a P4 server and synchronize a given "depot" to a
> given (empty) folder on the file system.  I looked at the P4Perl modules
> but I didn't see any code to hand to do this task. Is there an easy way
> doing this in the perl API?

In Perforce, that's called 'syncing' your workspace with the depot. If you
were using the Perforce command line client you'd run:

 p4 sync

or possibly

 p4 sync -f

to force the sync even if Perforce thinks you already have the files in

In P4Perl that becomes:



 $p4->Sync( "-f" );

Good luck with the integration!



More information about the p4perl mailing list