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