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