# This module contains all code for checking API versions for the # VSS to Perforce converter. # # $Id: //public/perforce/utils/vsstop4/main/convert.pm#16 $ # require 5.0; package utils; # This package use Exporter; use vars qw(@ISA @EXPORT); use convert; @ISA = qw(Exporter); @EXPORT = qw(p4api p4exec p4errors_get p4errors_print log_ss_version); # Checks sub p4api { #my $p4perl_version_reqd = "P4PERL/NTX86/2014.1"; my $p4perl_version_reqd = "P4PERL/NTX64/2018.2"; my $usage = "\nP4Perl module (P4) is required for the converter to run. Please use version $p4perl_version_reqd. Download strawberry-perl-5.28.2.1-64bit.msi from http://strawberryperl.com/releases.html \n"; # Check that P4 Module is installed eval{require P4; import P4;}; if ($@) { print $usage; exit(1); } my $ver = P4::Identify(); convert::sum_log("P4Perl version: $ver\n"); if ($ver !~ /\s*$p4perl_version_reqd/) { print $usage; print "****** Wrong P4Perl version installed - $ver is what you have - please uninstall and install $p4perl_version_reqd instead!"; exit(1); } my $p4 = new P4; $p4->SetApiLevel(57); # Lock to 2005.1 format - see http://answers.perforce.com/articles/KB/3197 $p4->SetProg("vsstop4"); return $p4; } sub p4exec { my ($p4, $cmd, $errorexit) = @_; $errorexit = 0 if (!defined($errorexit)); my $result = $p4->Run(split(' ', $cmd)); p4errors_print($p4, $cmd, $errorexit); return $result; } sub p4errors_print { my ($p4, $msg, $errorexit) = @_; $errorexit = 0 if (!defined($errorexit)); if ($p4->ErrorCount()) { my $output = "**p4errors - $msg:\n"; print $output; convert::log($output); foreach my $e ($p4->Errors()){ print "$e\n" if $errorexit;; convert::log("$e\n"); } exit(4) if $errorexit; } } sub p4errors_get { my @result; if ($p4->ErrorCount()) { foreach my $e ($p4->Errors()){ push @result, "$e\n"; } } return join("\n", @result); } sub log_ss_version { my $output = convert::run("ss about $convert::ss_options"); convert::log($output); convert::sum_log($output); } 1;