deprecated/buildtools/buildsystemtools/BuildClient.pl
changeset 662 60be34e1b006
parent 655 3f65fd25dfd4
equal deleted inserted replaced
654:7c11c3d8d025 662:60be34e1b006
       
     1 # Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Script to Process builds commands sent from the Build Server via TCP/IP
       
    15 # 
       
    16 #
       
    17 
       
    18 use strict;
       
    19 use FindBin;		# for FindBin::Bin
       
    20 use Getopt::Long;
       
    21 
       
    22 # Add the directory contain this perl script into the path to find modules
       
    23 use lib $FindBin::Bin;
       
    24 
       
    25 use BuildClient;
       
    26 
       
    27 # Process the commandline
       
    28 my ($iDataSource, $iConnectWait, $iClientName, $iExitAfter, $iDebug) = ProcessCommandLine();
       
    29 
       
    30 # Create socket to server
       
    31 &BuildClient::Connect($iDataSource, $iConnectWait, $iClientName, $iExitAfter, $iDebug);
       
    32 
       
    33 # ProcessCommandLine
       
    34 #
       
    35 # Inputs
       
    36 #
       
    37 # Outputs
       
    38 # $iDataSource - Reference to array of Hostname:Port combinations to try in sequence
       
    39 # $iConnectWait (How often it polls for a build server)
       
    40 # $iClientName (Client name used to help identify the machine, Must be unique)
       
    41 # $iExitAfter - Number of succesful connections to exit after
       
    42 # $iDebug - Prints Command output to screen to help debug
       
    43 #
       
    44 # Description
       
    45 # This function processes the commandline
       
    46 
       
    47 sub ProcessCommandLine {
       
    48   my ($iHelp, @iDataSource, $iConnectWait, $iDebug);
       
    49   my ($iExitAfter) = -1; #Set default to never exit
       
    50   GetOptions('h' => \$iHelp, 'd=s' => \@iDataSource, 'debug:s' => \$iDebug, 'w=i' => \$iConnectWait, 'c=s' => \$iClientName, 'e=i' => \$iExitAfter);
       
    51 
       
    52   if (($iHelp) || (!defined @iDataSource) || (!defined $iConnectWait) || (!defined $iClientName))
       
    53   {
       
    54     &Usage();
       
    55   } else {
       
    56 		foreach my $iMachine (@iDataSource)
       
    57 		{
       
    58 			&Usage() if ($iMachine !~ /^\S+:\d+/);
       
    59 		}
       
    60     return(\@iDataSource, $iConnectWait, $iClientName, $iExitAfter, $iDebug);
       
    61   }
       
    62 }
       
    63 
       
    64 # Usage
       
    65 #
       
    66 # Output Usage Information.
       
    67 #
       
    68 
       
    69 sub Usage {
       
    70   print <<USAGE_EOF;
       
    71 
       
    72   Usage: BuildClient.pl [options]
       
    73 
       
    74 USAGE_EOF
       
    75 print "  Version: ".&BuildClient::GetClientVersion()."\n";
       
    76 print <<USAGE_EOF;
       
    77 
       
    78   options:
       
    79 
       
    80   -h  help
       
    81   -d  Data Source - format Hostname:Port (e.g. Machine:1234) [Multiple allowed]
       
    82   -w  Seconds to wait between each connection attempt
       
    83   -c  Client name (Used to identify the machine in the logs, Must be unique)
       
    84   -e  Exit after specified number of successful connections [optional]
       
    85       default to never exit
       
    86 USAGE_EOF
       
    87 	exit 1;
       
    88 }