sbsv1/abld/e32util/epocmbm.pl
author jjkang
Fri, 25 Jun 2010 19:56:45 +0800
changeset 604 b33dd54aaa52
parent 599 fa7a3cc6effd
permissions -rw-r--r--
add cpptoolsplat
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2001-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
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
use Cwd;		# for cwd
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
use File::Basename;	# for basename()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
use FindBin;		# for FindBin::Bin
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
my $PerlBinPath;	# fully qualified pathname of the directory containing this script
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
my $epocroot;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
# establish the path to the Perl binaries
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
BEGIN {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
	require 5.005_03;		# check user has a version of perl that will cope
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
	$PerlBinPath = $FindBin::Bin;	# X:/epoc32/tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
	$PerlBinPath =~ s/\//\\/g;	# X:\epoc32\tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
use lib $PerlBinPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
use lockit_info;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
sub print_usage
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
	print <<USAGE_EOF;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
Usage:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
  epocmbm [-h headerfile] [-o outputfile] [-b "bitmaps"] [-l "TargetPath:CWDir"]  
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
Compile the bitmaps to an EPOC MBM image file.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
   -b	  -- list of bitmaps Eg., "-b/c8\\full path\\bmp1... /c8\\full path\\bmp2.."
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
   -l     -- if specified, captures all source to \\epoc32\\localisation\\...
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
USAGE_EOF
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
#-----------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
# Process commandline arguments
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 $opt_o="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
my $opt_h="";	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
my $opt_l="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
my $opt_b="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
my $opt_v=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
my $errors = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
while (@ARGV)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
	my $arg = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
	if ($arg =~ /^-o(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
		$opt_o =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
	if ($arg =~ /^-h(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
		$opt_h =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
	if ($arg =~ /^-b(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
		$opt_b =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
		}	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
	if ($arg =~ /^-l(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
		$opt_l =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
		next;
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
	if($arg =~ /^-/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
		print "Unknown arg: $arg\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
		$errors++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
if ($errors || $opt_b eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
	print_usage();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
	exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
my $headerfile=$opt_h;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
if ($opt_b ne "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
	$opt_h = "\/h\"$headerfile\"" if ($headerfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
	print "* bmconv /q $opt_h $opt_o $opt_b\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
	system("bmconv /q $opt_h $opt_o $opt_b");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
	if ($? != 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
		print "* BMCONV failed\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
		exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111
if ($opt_l ne "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   112
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   113
	my ($Resrc, $FileType) = split(/\./, basename($opt_o));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   114
	&Lockit_SrcFile($Resrc, "", $opt_l, $FileType, $opt_b, $Resrc.".$FileType"); # ""
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   115
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   116
exit 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   117
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   118
sub Epocroot_Check
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   119
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   120
	$epocroot = $ENV{EPOCROOT};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   121
	die "ERROR: Must set the EPOCROOT environment variable\n" if (!defined($epocroot));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   122
	$epocroot =~ s-/-\\-go;	# for those working with UNIX shells
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   123
	die "ERROR: EPOCROOT must not include a drive letter\n" if ($epocroot =~ /^.:/);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   124
	die "ERROR: EPOCROOT must be an absolute path without a drive letter\n" if ($epocroot !~ /^\\/);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   125
	die "ERROR: EPOCROOT must not be a UNC path\n" if ($epocroot =~ /^\\\\/);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   126
	die "ERROR: EPOCROOT must end with a backslash\n" if ($epocroot !~ /\\$/);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   127
	die "ERROR: EPOCROOT must specify an existing directory\n" if (!-d $epocroot);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   128
	$epocroot=~ s-\\$--;		# chop trailing \\
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   129
	}