1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/tools/perl/BuildOrbiter/BuildOrbiter.pl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,104 @@
1.4 +#
1.5 +# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +# All rights reserved.
1.7 +# This component and the accompanying materials are made available
1.8 +# under the terms of "Eclipse Public License v1.0"
1.9 +# which accompanies this distribution, and is available
1.10 +# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +#
1.12 +# Initial Contributors:
1.13 +# Nokia Corporation - initial contribution.
1.14 +#
1.15 +# Contributors:
1.16 +#
1.17 +# Description:
1.18 +#
1.19 +
1.20 +use File::Copy;
1.21 +use Getopt::Long;
1.22 +use Cwd;
1.23 +use Archive::Zip;
1.24 +use Archive::Zip::Tree;
1.25 +
1.26 +sub Usage()
1.27 + {
1.28 + print <<USAGE_EOF;
1.29 +Usage
1.30 +perl buildorbiter.pl --in=FileNameIn --out=FileNameOut --help
1.31 +
1.32 + --in=FileNameIn : Input oby file name
1.33 +
1.34 + --out=FileNameOut : Output zip file name
1.35 +
1.36 + --help : This help
1.37 +USAGE_EOF
1.38 + exit( 0 )
1.39 + }
1.40 +
1.41 +sub main()
1.42 + {
1.43 + my $help='';
1.44 + my $input="";
1.45 + my $output="";
1.46 +
1.47 + GetOptions(
1.48 + 'in=s' => \$input,
1.49 + 'out=s' => \$output,
1.50 + 'help' => \$help
1.51 + );
1.52 +
1.53 + if($help or ($input eq "") or ($output eq "") )
1.54 + {
1.55 + Usage();
1.56 + exit(0);
1.57 + }
1.58 +
1.59 + my $curdir = cwd;
1.60 + $_ = $curdir;
1.61 + s/\//\\/g;
1.62 + $curdir = $_;
1.63 +
1.64 + my $theEpocRoot=$ENV{EPOCROOT};
1.65 + my @epocdir = "$theEpocRoot.\\epoc32";
1.66 +
1.67 + open FH, "$input" || die "Couldn't open $input file for Reading: $!\n";
1.68 +
1.69 + while ( <FH> )
1.70 + {
1.71 + chomp; # no newline
1.72 + s/#.*//; # no comments
1.73 + s/^\s+//; # no leading white
1.74 + s/\s+$//; # no trailing white
1.75 + next unless length; # anything left?
1.76 + if ( /(^file|^data)\s*=\s*(\S+)\s+(\S+)/ )
1.77 + {
1.78 + my $inputFile=$2;
1.79 +
1.80 + $inputFile =~ m/(\S*)(\\|\/)(\S+)$/;
1.81 +
1.82 + my $dir=$curdir.$1;
1.83 + unless ( -d $dir )
1.84 + {
1.85 + system("mkdir $dir");
1.86 + }
1.87 + printf "Copying: $inputFile\n";
1.88 + copy($inputFile, $dir) or die "File cannot be copied.";
1.89 + }
1.90 + }
1.91 + close FH;
1.92 +
1.93 + my $zip = Archive::Zip->new();
1.94 + if ( $input =~ m/(\S*)(\\|\/)(\S+)$/ )
1.95 + {
1.96 + $zip->addFile("$input", $3);
1.97 + }
1.98 + else
1.99 + {
1.100 + $zip->addFile("$input");
1.101 + }
1.102 + $zip->addTree("epoc32", "epoc32");
1.103 + die 'write error' if $zip->writeToFileNamed( "$output" ) != AZ_OK;
1.104 + printf "Completed\n";
1.105 + }
1.106 +
1.107 +main();