imgtools/imaker/src/s60ibymacros.pm
changeset 586 bfc226f3f18c
equal deleted inserted replaced
582:dbec85ee2eeb 586:bfc226f3f18c
       
     1 # Copyright (c) 2006 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 the License "Symbian Foundation License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # S60 specific IBY file macro handling
       
    15 #
       
    16 
       
    17 package s60ibymacros;
       
    18 
       
    19 BEGIN
       
    20   {
       
    21   use Exporter ();
       
    22   our ( $VERSION, @ISA, @EXPORT );
       
    23   # set the version for version checking
       
    24   $VERSION     = 1.00;
       
    25 
       
    26   @ISA         = qw( Exporter );
       
    27   @EXPORT      = qw( &s60ibymacros_info &DoS60IbyModifications );
       
    28   }
       
    29 
       
    30 my %s60ibymacros_infostruct =
       
    31   (
       
    32   name => "s60ibymacros",
       
    33   invocation => "InvocationPoint1",
       
    34   single => "s60ibymacros::DoS60IbyModifications"
       
    35   );
       
    36 
       
    37 my @newobydata;
       
    38 
       
    39 sub s60ibymacros_info
       
    40   {
       
    41   return \%s60ibymacros_infostruct;
       
    42   }
       
    43 
       
    44 sub DoS60IbyModifications
       
    45   {
       
    46   my $obydata = shift;
       
    47 
       
    48   undef @newobydata;
       
    49   foreach $line (@{$obydata})
       
    50     {
       
    51     if ($line =~ /^\s*REM/i)
       
    52       {
       
    53       # Ignore REM statements, to avoid processing "REM __SCALABLE_IMAGE( ... )"
       
    54       push @newobydata, $line;
       
    55       }
       
    56     elsif( ! ( HandleIconMacros($line) || HandleCenrepMacros($line) ) )
       
    57       {
       
    58       push @newobydata, $line;
       
    59       }
       
    60     }
       
    61   @{$obydata} = @newobydata;
       
    62   }
       
    63 
       
    64 sub HandleCenrepMacros
       
    65   {
       
    66   my $line = shift;
       
    67   if ( $line =~ m/^.*__CENREP_TXT_FILES\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/i )
       
    68   # __CENREP_TXT_FILES(dataz_, source dir, target dir)
       
    69     {
       
    70     my $sourcepath="$1\\$2";
       
    71     my $targetpath=$3;
       
    72     my $s60extras_export_list_filename = "$sourcepath"."\\s60extras_export_list.txt";
       
    73 
       
    74     open(DH, $s60extras_export_list_filename);
       
    75     my @dlist = <DH>;
       
    76     chop @dlist;
       
    77     close(DH);
       
    78 
       
    79     my $cenreptxtfile;
       
    80     foreach $cenreptxtfile (@dlist)
       
    81       {
       
    82       if ($cenreptxtfile =~ /^\S+\.txt/)
       
    83         {
       
    84         push @newobydata, "data=$sourcepath\\$cenreptxtfile $targetpath\\$cenreptxtfile\n";
       
    85         }
       
    86       }
       
    87     return 1;
       
    88     }
       
    89   }
       
    90 
       
    91 sub HandleIconMacros
       
    92   {
       
    93   my $line = shift;
       
    94   if ( $line =~ m/^.*__SCALABLE_IMAGE\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/i )
       
    95   # __SCALABLE_IMAGE(emulator directory, file rom dir, dataz_, resource rom dir,
       
    96   #                  filename, resource filename)
       
    97     {
       
    98       
       
    99     my $sourcepath="$1\\$2";
       
   100     my $targetpath=$3;
       
   101     my $filename=$4;
       
   102 
       
   103     if( -e "$sourcepath\\$filename.mbm" )
       
   104       {
       
   105       push @newobydata, "AUTO-BITMAP=$sourcepath\\$filename.mbm $targetpath\\$filename.mbm\n";
       
   106       }
       
   107     if( -e "$sourcepath\\$filename.mif" )
       
   108       {
       
   109       push @newobydata, "data=$sourcepath\\$filename.mif $targetpath\\$filename.mif\n";
       
   110       }
       
   111     elsif( ! -e "$sourcepath\\$filename.mbm ")
       
   112       {
       
   113       print STDERR "* Invalid image file name: $sourcepath\\$filename.mbm or .mif\n";
       
   114       }
       
   115     return 1;
       
   116     }
       
   117   }
       
   118 
       
   119 1;  # Return a true value from the file