sbsv1_os/e32toolp/e32util/epocmbm.pl
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 # Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 #
       
    15 
       
    16 use strict;
       
    17 use Cwd;		# for cwd
       
    18 use File::Basename;	# for basename()
       
    19 use FindBin;		# for FindBin::Bin
       
    20 my $PerlBinPath;	# fully qualified pathname of the directory containing this script
       
    21 
       
    22 my $epocroot;
       
    23 
       
    24 # establish the path to the Perl binaries
       
    25 BEGIN {
       
    26 	require 5.005_03;		# check user has a version of perl that will cope
       
    27 	$PerlBinPath = $FindBin::Bin;	# X:/epoc32/tools
       
    28 	$PerlBinPath =~ s/\//\\/g;	# X:\epoc32\tools
       
    29 }
       
    30 
       
    31 use lib $PerlBinPath;
       
    32 use lockit_info;
       
    33 
       
    34 sub print_usage
       
    35 	{
       
    36 	print <<USAGE_EOF;
       
    37 
       
    38 Usage:
       
    39   epocmbm [-h headerfile] [-o outputfile] [-b "bitmaps"] [-l "TargetPath:CWDir"]  
       
    40 
       
    41 Compile the bitmaps to an EPOC MBM image file.
       
    42    -b	  -- list of bitmaps Eg., "-b/c8\\full path\\bmp1... /c8\\full path\\bmp2.."
       
    43    -l     -- if specified, captures all source to \\epoc32\\localisation\\...
       
    44 
       
    45 USAGE_EOF
       
    46 	}
       
    47 
       
    48 
       
    49 #-----------------------------------------------
       
    50 # Process commandline arguments
       
    51 #
       
    52 
       
    53 my $opt_o="";
       
    54 my $opt_h="";	
       
    55 my $opt_l="";
       
    56 my $opt_b="";
       
    57 my $opt_v=0;
       
    58 
       
    59 my $errors = 0;
       
    60 while (@ARGV)
       
    61 	{
       
    62 	my $arg = shift @ARGV;
       
    63 	if ($arg =~ /^-o(.*)$/)
       
    64 		{
       
    65 		$opt_o =$1;
       
    66 		next;
       
    67 		}
       
    68 	if ($arg =~ /^-h(.*)$/)
       
    69 		{
       
    70 		$opt_h =$1;
       
    71 		next;
       
    72 		}
       
    73 	if ($arg =~ /^-b(.*)$/)
       
    74 		{
       
    75 		$opt_b =$1;
       
    76 		next;
       
    77 		}	
       
    78 	if ($arg =~ /^-l(.*)$/)
       
    79 		{
       
    80 		$opt_l =$1;
       
    81 		next;
       
    82 		}
       
    83 
       
    84 	if($arg =~ /^-/)
       
    85 		{
       
    86 		print "Unknown arg: $arg\n";
       
    87 		$errors++;
       
    88 		next;
       
    89 		}
       
    90 	}
       
    91 
       
    92 if ($errors || $opt_b eq "")
       
    93 	{
       
    94 	print_usage();
       
    95 	exit 1;
       
    96 	}
       
    97 
       
    98 my $headerfile=$opt_h;
       
    99 
       
   100 if ($opt_b ne "")
       
   101 	{
       
   102 	$opt_h = "\/h\"$headerfile\"" if ($headerfile ne "");
       
   103 	print "* bmconv /q $opt_h $opt_o $opt_b\n" if ($opt_v);
       
   104 	system("bmconv /q $opt_h $opt_o $opt_b");
       
   105 	if ($? != 0)
       
   106 		{
       
   107 		print "* BMCONV failed\n";
       
   108 		exit 1;
       
   109 		}
       
   110 	}
       
   111 
       
   112 if ($opt_l ne "")
       
   113 	{
       
   114 	my ($Resrc, $FileType) = split(/\./, basename($opt_o));
       
   115 	&Lockit_SrcFile($Resrc, "", $opt_l, $FileType, $opt_b, $Resrc.".$FileType"); # ""
       
   116 		}
       
   117 exit 0;
       
   118 
       
   119 sub Epocroot_Check
       
   120 	{
       
   121 	$epocroot = $ENV{EPOCROOT};
       
   122 	die "ERROR: Must set the EPOCROOT environment variable\n" if (!defined($epocroot));
       
   123 	$epocroot =~ s-/-\\-go;	# for those working with UNIX shells
       
   124 	die "ERROR: EPOCROOT must not include a drive letter\n" if ($epocroot =~ /^.:/);
       
   125 	die "ERROR: EPOCROOT must be an absolute path without a drive letter\n" if ($epocroot !~ /^\\/);
       
   126 	die "ERROR: EPOCROOT must not be a UNC path\n" if ($epocroot =~ /^\\\\/);
       
   127 	die "ERROR: EPOCROOT must end with a backslash\n" if ($epocroot !~ /\\$/);
       
   128 	die "ERROR: EPOCROOT must specify an existing directory\n" if (!-d $epocroot);
       
   129 	$epocroot=~ s-\\$--;		# chop trailing \\
       
   130 	}