kernel/eka/rombuild/cptest.pl
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 #
       
     2 # Copyright (c) 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 the License "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 Cwd;
       
    18 use Getopt::Long;
       
    19 my %opts=();
       
    20 my $result = GetOptions (	\%opts,
       
    21 							"iby=s",
       
    22 							"build=s",
       
    23 							"drive=s",
       
    24 							"udir=s",
       
    25 							"kdir=s",
       
    26 							"zip=s",
       
    27 							"verbose"
       
    28 							);
       
    29 
       
    30 
       
    31 if (!$result || !$opts{iby} || !$opts{build}) {
       
    32 	usage();
       
    33 	exit;
       
    34 }
       
    35 my $IbyFileName = $opts{iby};
       
    36 open IBY, $IbyFileName or die "Cannot open IBY file $IbyFileName\n";
       
    37 my $build = $opts{build};
       
    38 my $srcdrv = Cwd::getcwd();
       
    39 $srcdrv=~/(\w\:).*/;
       
    40 $srcdrv=$1;
       
    41 if ($opts{drive}) {
       
    42 	$srcdrv=$opts{drive};
       
    43 }
       
    44 my $udir = $opts{udir};
       
    45 my $kdir = $opts{kdir};
       
    46 my $zip = $opts{zip};
       
    47 my $verbose = $opts{verbose};
       
    48 
       
    49 if ($verbose) {
       
    50 	print "IBY file  : $IbyFileName\n";
       
    51 	print "Build     : $build\n";
       
    52 	print "Drive     : $srcdrv\n";
       
    53 	print "User Dir  : $udir\n";
       
    54 	print "Kernel Dir: $kdir\n";
       
    55 	print "ZIP file  : $zip\n";
       
    56 }
       
    57 
       
    58 while(<IBY>) {
       
    59 	if (/^\s*\/\//) {
       
    60 		print "Comment: $_\n" if ($verbose);
       
    61 		next;
       
    62 	}
       
    63 	/^\s*(\w+)(.*)$/;
       
    64 	my $keyword=$1;
       
    65 	my $rest=$2;
       
    66 	unless ($keyword eq 'file' or $keyword eq 'data' or $keyword eq 'dll' or $keyword eq 'device') {
       
    67 		next;
       
    68 	}
       
    69 	if ($rest=~/^\s*\[\w+\](.*)$/) {
       
    70 		$rest=$1;	# lose [MAGIC]
       
    71 	}
       
    72 	next unless ($rest=~/^\s*\=\s*(.*)$/);
       
    73 	$rest=$1;
       
    74 	my @word=split /\s+/, $rest;
       
    75 	my $source=$word[0];
       
    76 	my $dest=$word[1];
       
    77 	$source=~ s/##BUILD##/$build/g;
       
    78 	$source=~ s/##MAIN##/$udir/g;
       
    79 	$source=~ s/##ASSP##/$kdir/g;
       
    80 	$source=~ s/##KMAIN##/$kdir/g;
       
    81 	$source=~ s/##ELOCLDIR##/$udir/g;
       
    82 	$source=$srcdrv.$source;
       
    83 #	print "$source->$dest\n";
       
    84 	my @destpath=split /(\/|\\)/,$dest;
       
    85 	while ($destpath[0]=~/^\s*$/ or $destpath[0] eq '\\' or $destpath[0] eq '\/') {
       
    86 		shift @destpath;
       
    87 	}
       
    88 	my $npathc=scalar(@destpath);
       
    89 	my $destfilename=pop @destpath;
       
    90 	my $destdirname=join '', @destpath;
       
    91 	if ($destdirname=~/^(.*)\\\s*$/) {
       
    92 		$destdirname=$1;
       
    93 	}
       
    94 	if ($destdirname=~/^\\(.*?)$/) {
       
    95 		$destdirname=$1;
       
    96 	}
       
    97 	print "$source->$destfilename @ $destdirname $npathc\n" if ($verbose);
       
    98 	unless (-d $destdirname) {
       
    99 		system "md $destdirname";
       
   100 	}
       
   101 	if (-e $source) {
       
   102 		system "copy $source $destdirname\\$destfilename >NUL";
       
   103 	} else {
       
   104 		warn "$source not found\n";
       
   105 	}
       
   106 }
       
   107 if ($zip) {
       
   108 	unless ($zip =~ /^(.*?)\.zip$/i) {
       
   109 		$zip .= '.zip';
       
   110 	}
       
   111 	system "del $zip";
       
   112 	system "zip -r $zip *";
       
   113 }
       
   114 
       
   115 exit;
       
   116 
       
   117 # END OF MAIN
       
   118 
       
   119 sub usage {
       
   120 	print <<EOT;
       
   121 
       
   122 perl cptest.pl <options>
       
   123 
       
   124 Copy tests to target directory structure
       
   125 
       
   126 The following options are required:
       
   127   -i, --iby = <IBY file name>
       
   128   -b, --build = <build>         UDEB or UREL
       
   129 
       
   130 The following are optional:
       
   131   -d, --drive = <drive with executables on>
       
   132 
       
   133          Defaults to current drive
       
   134 
       
   135   -u, --udir = <user directory>	  e.g. ARM4, X86
       
   136   -k, --kdir = <kernel directory> e.g. MISA, NX86
       
   137   -z, --zip = <zipfile name>
       
   138   -v, --verbose
       
   139 
       
   140 EOT
       
   141 }
       
   142