releasing/cbrtools/perl/InstCol2
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 602 3145852acc89
permissions -rw-r--r--
Specify extenal tool with path
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
#!perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use FindBin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use lib "$FindBin::Bin";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use File::Find;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use File::Copy;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use Getopt::Long;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use EnvDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
# Globals.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
my $verbose = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
my $dummyRun = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
my $interactive = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
my $force = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
my $wins = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
my $wincw = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
my $udeb = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
my $urel = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
my $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
my %affectedExtentions;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
# Constants.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
my %searchPath = (
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
		   wins => {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
			    udeb => '\\epoc32\\release\\wins\\udeb\\z',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
			    urel => '\\epoc32\\release\\wins\\urel\\z'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
			    },
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
		   wincw => {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
			    udeb => '\\epoc32\\release\\wincw\\udeb\\z',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
			    urel => '\\epoc32\\release\\wincw\\urel\\z'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
			    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
		 );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
my $KBinCompareChunkSize = 16 * 1024;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
# Main.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
ProcessCommandLine();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
my $files = FindFiles();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
CopyFiles($files);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
# Subs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
  Getopt::Long::Configure ('bundling');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
  my $extention;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  my $winsOnly = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
  my $wincwOnly = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
  my $udebOnly = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
  my $urelOnly = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  GetOptions('h' => \$help, 'f' => \$force, 'n' => \$dummyRun, 'i' => \$interactive, 'w' => \$winsOnly, 'c' => \$wincwOnly, 'd' => \$udebOnly, 'r' => \$urelOnly, 'v+' => \$verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
    Usage(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
  $extention = lc(shift @ARGV);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
  $comp = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  unless ($extention and ($extention eq 'cl' or $extention eq 'bw')) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
    print "Error: Invalid colour discription\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  unless (scalar (@ARGV) == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
    print "Error: Invalid number of arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  if ($winsOnly and $wincwOnly) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
    print "Error: -w and -c options are mutually exclusive\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  if ($udebOnly and $urelOnly) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
    print "Error: -d and -r options are mutually exclusive\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
  if ($winsOnly) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
    $wincw = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
  if ($wincwOnly) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
    $wins = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
  if ($udebOnly) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
    $urel = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  if ($urelOnly) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
    $udeb = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  %affectedExtentions = (
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
			  ".a$extention" => '.aif',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
			  ".i$extention" => '.ini',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
			  ".m$extention" => '.mbm'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
			 );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
  Utils::PrintDeathMessage($exitCode, "\nUsage: instcol2 [options] cl | bw [<component>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
-f  force a copy of everything (i.e. instcol behaviour)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
-n  dummy run (list what would be done, but doesn't do anything)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
-i  interactive mode (ask before copying each file)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
-w  WINS emulator only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
-c  WINCW emulator only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
-d  UDEB builds only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
-r  UREL builds only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
-v  verbose output (-vv very verbose)\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
sub FindFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
  my @files;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
  if ($comp) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
    FindCompFiles($comp, \@files);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
    if ($wins) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
      if ($udeb) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
	DoFindFiles($searchPath{wins}->{udeb}, \@files);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
      if ($urel) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
	DoFindFiles($searchPath{wins}->{urel}, \@files);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
    if ($wincw) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
      if ($udeb) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
	DoFindFiles($searchPath{wincw}->{udeb}, \@files);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
      if ($urel) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
	DoFindFiles($searchPath{wincw}->{urel}, \@files);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
  return \@files;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
sub FindCompFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
  my $files = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
  my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
  my $envDb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
  unless ($envDb->Version($comp)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
    print "Error: \"$comp\" is not currently installed\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
  my $info = $envDb->ListBins($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
  shift @$info; # Get rid of title.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
  foreach my $line (@$info) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
    unless ($line->[0] =~ /^\\epoc32\\data/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
      my $extention = lc (Extention($line->[0]));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
      if ($extention and ($line->[1] ne EnvDb::STATUS_STRING_MISSING) and exists $affectedExtentions{$extention}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
	push (@$files, lc($line->[0]));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
sub DoFindFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
  my $path = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
  my $files = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
  my $processFileSub = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
    if (-f $File::Find::name) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
      my $thisFile = lc($File::Find::name);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
      my $extention = Extention($thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
      if ($extention) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
	if (exists $affectedExtentions{$extention}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
	  Utils::TidyFileName(\$thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
	  push (@$files, $thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
  if (-e $path) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
    find($processFileSub, $path);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
sub CopyFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
  my $files = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
  foreach my $thisFile (@$files) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
    (my $path, my $name, my $ext) = Utils::SplitFileName($thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
    my $newExt = $affectedExtentions{$ext};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
    my $newName = Utils::ConcatenateDirNames($path, "$name$newExt");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
    CopyFile($thisFile, $newName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
sub CopyFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
  my $from = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
  my $to = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
  unless ($force) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
    if (-e $to) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
      (my $fromMtime, my $fromSize) = Utils::FileModifiedTimeAndSize($from);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
      (my $toMtime, my $toSize) = Utils::FileModifiedTimeAndSize($to);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
      if ($fromMtime == $toMtime) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
	print "Last modified times of \"$from\" and \"$to\" are identical\n" if ($verbose > 2);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
	return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
      if ($fromSize == $toSize) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
	if (BinaryCompare($from, $to, $fromSize)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
	  print "Binary content of \"$from\" and \"$to\" are identical\n" if ($verbose > 2);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
	  return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
	  print "Binary content of \"$from\" and \"$to\" are different\n" if ($verbose > 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
	print "Sizes of \"$from\" and \"$to\" are different\n" if ($verbose > 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
      print "\"$to\" does not exist\n" if ($verbose > 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
  if ($interactive) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
    print "Copy \"$from\" to \"$to\"? [y] ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
    my $response = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
    chomp $response;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
    unless ($response =~ /^y$/i or not $response) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
      return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
  if ($verbose) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
    print "Copying \"$from\" to \"$to\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
  unless ($dummyRun) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
    copy ($from, $to) or die "Error: Couldn't copy \"$from\" to \"$to\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
sub BinaryCompare {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
  my $file1 = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
  my $file2 = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
  my $size = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
  my $identical = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
  open (FILE1, $file1) or die "Error: Couldn't open \"$file1\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
  open (FILE2, $file2) or die "Error: Couldn't open \"$file2\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
  binmode (FILE1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
  binmode (FILE2);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
  my $bytesCompared = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
  while ($bytesCompared < $size) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
    my $buf1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
    my $buf2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
    my $bytesRead1 = read (FILE1, $buf1, $KBinCompareChunkSize);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
    my $bytesRead2 = read (FILE2, $buf2, $KBinCompareChunkSize);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
    unless ($bytesRead1 eq $bytesRead2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
      die "Error: Problem binary comparing \"$file1\" with \"$file2\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
    $bytesCompared += $bytesRead1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
    if ($buf1 ne $buf2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
      $identical = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
      last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
  close (FILE1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
  close (FILE2);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
  return $identical;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
sub Extention {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
  my $fileName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
  (my $ext) = $fileName =~ /(\.[^\.]*)$/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
  return $ext;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
InstCol2 - A more controlled instcol.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
  instcol2 [options] cl | bw [<component>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
  -f  force a copy of everything (i.e. instcol behaviour)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
  -n  dummy run (list what would be done, but doesn't do anything)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
  -i  interactive mode (ask before copying each file)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
  -w  WINS emulator only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
  -c  WINCW emulator only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
  -d  UDEB builds only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
  -r  UREL builds only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
Symbian tools C<instcol> may be used to configure the emulator to be either colour or monochrome. Files with the extentions F<.aif>, F<.ini>, F<.mbm> are often provided in both colour and monochrome variants. The last two characters of the extention are replaced with F<cl> for colour, or F<bw> for monochrome. To install a particular variant, C<instcol> simply copies files with the required colour variant extention to files with the emulator required extention. For example, F<eikon.mcl> would be copied to a file named F<eikon.mbm> if the emulator were to be configured for colour.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
This emulator configuration technique has the unfortunate side effect of making development environments dirty from the point of view of the release tools. It is hoped that this problem will eventually disappear, if support for multiple colour variants of the emulator is dropped. In the meantime, C<InstCol2> was written to provide a higher degree of control over changes made to development environments than that offered by C<instcol>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
C<InstCol2> only copies files if it really has to. A copy will only occur if:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
The emulator required extention (F<.aif>, F<.ini> or F<.mbm>) copy of a particular file does not exist.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
The emulator required extention copy for a particular file has a last modified time of less than the required colour variant of the file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
The emulator required exetention copy for a particular file contains different binary data to the required colour varaint of the file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
=head1 EXAMPLES
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
 instcol2 -wd cl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
Installs the colour variants for the WINS UDEB emulator.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
 instcol2 -cr bw alaunch
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
Installs the monochrome variants for the WINCW UREL emulator for the component C<alaunch>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
 Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
=cut