sbsv1/abld/e32util/copyfeaturevariants.pl
author kelvzhu
Mon, 13 Sep 2010 13:11:19 +0800
changeset 640 ac0bbc1e5d79
parent 599 fa7a3cc6effd
permissions -rw-r--r--
Merge sysdeftools's addtion
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# copy A.X.aaa to B.X.bbb for all X (32 chars) when given A.aaa B.bbb
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
my $source = shift;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
my $target = shift;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
my $errs = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
# copy invariant
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
use File::Copy;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
if (-f $source)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
	if (copy($source, $target))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
		print "copy $source $target\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
	else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
		print "ERROR: failed copy $source $target\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
		$errs++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
# now think about variants
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
use File::Basename;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
my $srcDir = dirname($source);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
my $srcRoot = basename($source);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
my $srcExt = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
if ($srcRoot =~ /^(.+)\.([^\.]+)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
	$srcRoot = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
	$srcExt = $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
my $tgtRoot = $target;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
my $tgtExt = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
if ($tgtRoot =~ /^(.+)\.([^\.]+)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
	$tgtRoot = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
	$tgtExt = $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
opendir(DIR, $srcDir) or die("ERROR: cannot read directory $srcDir\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
# copy all variants
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
while (my $file = readdir(DIR))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
	if ($file =~ /^$srcRoot\.(\w{32})\.$srcExt$/i)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
		my $from = "$srcDir/$file";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
		my $into = "$tgtRoot.$1.$tgtExt";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
		if (copy($from, $into))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
			print "copy $from $into\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
		else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
			print "ERROR: failed copy $from $into\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
			$errs++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
exit 1 if (!closedir(DIR) || $errs > 0);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
exit 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85