haitest/bspsvs/tools/perl/BuildOrbiter/BuildOrbiter.pl
changeset 0 cec860690d41
equal deleted inserted replaced
-1:000000000000 0:cec860690d41
       
     1 #
       
     2 # Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 #
       
    16 
       
    17 use File::Copy;
       
    18 use Getopt::Long;
       
    19 use Cwd;
       
    20 use Archive::Zip;
       
    21 use Archive::Zip::Tree;
       
    22 
       
    23 sub Usage()
       
    24 	{
       
    25 	print <<USAGE_EOF;
       
    26 Usage
       
    27 perl buildorbiter.pl --in=FileNameIn --out=FileNameOut --help
       
    28 
       
    29     --in=FileNameIn             : Input oby file name
       
    30 
       
    31     --out=FileNameOut           : Output zip file name
       
    32 
       
    33     --help                      : This help
       
    34 USAGE_EOF
       
    35 	exit( 0 )
       
    36 	}
       
    37 
       
    38 sub main()
       
    39 	{
       
    40 	my	$help='';
       
    41 	my	$input="";
       
    42 	my	$output="";
       
    43 
       
    44 	GetOptions(
       
    45 		'in=s'		=> \$input,
       
    46 		'out=s'		=> \$output,
       
    47 		'help' 		=> \$help
       
    48 	);
       
    49 
       
    50 	if($help or ($input eq "") or ($output eq "") )
       
    51 		{
       
    52 		Usage();
       
    53 		exit(0);
       
    54 		}
       
    55 
       
    56 	my	$curdir = cwd;
       
    57 	$_ = $curdir;
       
    58 	s/\//\\/g;
       
    59 	$curdir = $_;
       
    60 
       
    61 	my	$theEpocRoot=$ENV{EPOCROOT};
       
    62 	my	@epocdir = "$theEpocRoot.\\epoc32";
       
    63 
       
    64 	open FH, "$input" || die "Couldn't open $input file for Reading: $!\n";
       
    65 
       
    66 	while ( <FH> )
       
    67 		{
       
    68 		chomp;                  # no newline
       
    69 		s/#.*//;                # no comments
       
    70 		s/^\s+//;               # no leading white
       
    71 		s/\s+$//;               # no trailing white
       
    72 		next unless length;     # anything left?
       
    73 		if ( /(^file|^data)\s*=\s*(\S+)\s+(\S+)/ )
       
    74 			{
       
    75 			my	$inputFile=$2;
       
    76 
       
    77 			$inputFile =~ m/(\S*)(\\|\/)(\S+)$/;
       
    78 
       
    79 			my	$dir=$curdir.$1;
       
    80 			unless ( -d $dir )
       
    81 				{
       
    82 				system("mkdir $dir");
       
    83 				}
       
    84 			printf "Copying: $inputFile\n";
       
    85 			copy($inputFile, $dir) or die "File cannot be copied.";
       
    86 			}
       
    87 		}
       
    88 	close FH;
       
    89 
       
    90 	my	$zip = Archive::Zip->new();
       
    91 	if ( $input =~ m/(\S*)(\\|\/)(\S+)$/ )
       
    92 		{
       
    93 		$zip->addFile("$input", $3);
       
    94 		}
       
    95 	else
       
    96 		{
       
    97 		$zip->addFile("$input");
       
    98 		}
       
    99 	$zip->addTree("epoc32", "epoc32");
       
   100 	die 'write error' if $zip->writeToFileNamed( "$output" ) != AZ_OK;
       
   101 	printf "Completed\n";
       
   102 	}
       
   103 
       
   104 main();