toolsandutils/productionbldtools/SupplementalKits.pm
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 #!perl
       
     2 
       
     3 # SupplementalKits.pl
       
     4 
       
     5 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     6 # All rights reserved.
       
     7 # This component and the accompanying materials are made available
       
     8 # under the terms of "Eclipse Public License v1.0"
       
     9 # which accompanies this distribution, and is available
       
    10 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    11 #
       
    12 # Initial Contributors:
       
    13 # Nokia Corporation - initial contribution.
       
    14 #
       
    15 # Contributors:
       
    16 #
       
    17 # Description:
       
    18 #
       
    19 
       
    20 
       
    21 package SupplementalKits;
       
    22 
       
    23 
       
    24 use File::Path;
       
    25 use FindBin;                # where does this script live?
       
    26 #use lib $FindBin::Bin;      # use this directory for libraries, to find...
       
    27 use KitStandardLocations;
       
    28 
       
    29 
       
    30 
       
    31 my $PlatformProductToolsDir = $FindBin::Bin;
       
    32 $PlatformProductToolsDir =~ s/common/$Platform/i;    # change "common" to platform name in path to tools directory
       
    33 unshift (@INC, $PlatformProductToolsDir);            # add this to the @INC list of library paths
       
    34 require KitPlatformSpecific;                         # and read the platform-specific definitions
       
    35 require $BuildBaseName."_supplementary";
       
    36 
       
    37 my $scriptFileSupplementaryKits = "InstallSupplementaryKit.pl";
       
    38 
       
    39 
       
    40 
       
    41 # ------------------------------------- main routine -----------------------------------
       
    42 
       
    43 sub SupplementalKits()
       
    44 {
       
    45 	# set up environment & preserve old values
       
    46 	my $OutputDirWithoutDrive = $OutputDir;
       
    47 	$OutputDirWithoutDrive =~ s/^\w:(.*)$/$1/i;
       
    48 	my $oldEpocRoot = $ENV{EPOCROOT};
       
    49 	my $oldPath = $ENV{path};
       
    50 	my $oldOutputDir = $ENV{OUTPUTDIR};
       
    51 	$ENV{EPOCROOT} ="$OutputDirWithoutDrive\\techview\\";
       
    52 	$ENV{path} = "$ENV{EPOCROOT}epoc32\\tools\\;$ENV{EPOCROOT}epoc32\\gcc\\bin\\;".$ENV{path};
       
    53 	$ENV{OUTPUTDIR} = "$ProductPath\\SupplementaryProducts";
       
    54 
       
    55 
       
    56 
       
    57 	# read [emul] tag and replace it in the files
       
    58 	foreach my $package (@replaceEmulPackage)
       
    59 	{
       
    60 		replaceEmul($package);
       
    61 	}
       
    62 
       
    63 
       
    64 	# set up the source directory path for .bin packages
       
    65 	foreach my $package (@addSourcePackage)
       
    66 	{
       
    67 		addSource($package->[0], eval $package->[1]);
       
    68 	}
       
    69 
       
    70 
       
    71 	# create Supplementary products directory
       
    72 	(mkpath ($ENV{OUTPUTDIR}) or print "WARNING: Unable to create directory $ENV{OUTPUTDIR} - $!\n") if (! -d $ENV{OUTPUTDIR});
       
    73 
       
    74 
       
    75 
       
    76 	# main build procedure
       
    77 	foreach my $directory (@requiredSupplementaryKits)
       
    78 	{
       
    79 	print "** Supplemental Kit:  building from $directory\n";
       
    80 		# set up the source directory path for .src packages in this product
       
    81 		chdir ("$SuppKitPath\\$directory\\pkgdef");
       
    82 		foreach my $sourcePackage (<$SuppKitPath\\$directory\\pkgdef\\com.symbian.src.*>)
       
    83 		{
       
    84 			addSource($sourcePackage, $SourceDir);
       
    85 		}
       
    86 		chdir ("$SuppKitPath\\$directory\\group");
       
    87 		system ("bldmake bldfiles");
       
    88 		system ("abld makefile");
       
    89 		system ("abld target tools");
       
    90 	}
       
    91 
       
    92 
       
    93 	# copy Supplementary Products installation script into the right directory
       
    94 	my $ProductToolsDir = $FindBin::Bin;
       
    95 	$ProductToolsDir =~ s|/|\\|g;
       
    96 	system("copy ".$ProductToolsDir."\\".$scriptFileSupplementaryKits." ".$ENV{OUTPUTDIR});
       
    97 
       
    98 
       
    99 
       
   100 	# restore environment & finish
       
   101 	$ENV{EPOCROOT} =  $oldEpocRoot;
       
   102 	$ENV{path} = $oldPath;
       
   103 	$ENV{OUTPUTDIR} = $oldOutputDir;
       
   104 
       
   105 }
       
   106 
       
   107 
       
   108 
       
   109 
       
   110 # ------------------------------------- Sub procedures -----------------------------------
       
   111 
       
   112 
       
   113 # function inserts the leading directory in the src= statement
       
   114 sub addSource()
       
   115 {
       
   116     my $pkgDefFile = $_[0] ;
       
   117     my $srcDir = $_[1] ;
       
   118 
       
   119 
       
   120     # read source definition file
       
   121     open (FILE, "<$pkgDefFile") or print "WARNING: Supplementary Kits: Couldn't read file $pkgDefFile\n";
       
   122     my @pkgList = <FILE>;
       
   123     close(FILE);
       
   124     unlink($pkgDefFile);
       
   125 
       
   126     # write file with replaced src=
       
   127     open (FILE, ">$pkgDefFile") or print "WARNING: Supplementary Kits: Couldn't write file $pkgDefFile\n";
       
   128     foreach $line (@pkgList)
       
   129     {
       
   130 		# insert source directory at start
       
   131 		$line =~ s|src="(\\){0,1}|src="$srcDir\\|gi;
       
   132 
       
   133 		# remove double slashes if present
       
   134 		$line =~ s|\\\\|\\|gi ;
       
   135         
       
   136     	print FILE $line ;
       
   137     }
       
   138     close(FILE);
       
   139 }
       
   140 
       
   141 
       
   142 
       
   143 
       
   144 # function reads [emul] tag and replaces it in the file specified as the parameter
       
   145 sub replaceEmul()
       
   146 {
       
   147     my $emul = "" ;
       
   148     my $pkgDefFile = $_[0] ;
       
   149 
       
   150     # read source definition file
       
   151     open (FILE, "<$pkgDefFile") or print "WARNING: Supplementary Kits: Couldn't read file $pkgDefFile\n";
       
   152     my @pkgList = <FILE>;
       
   153     close(FILE);
       
   154     
       
   155 
       
   156     # look for definition of [emul]
       
   157     foreach $line (@pkgList)
       
   158     {
       
   159         if ( $line =~ m|emul\]\">(.*?)<|i )
       
   160         {
       
   161             $emul = $1;
       
   162 
       
   163             # remove [sdkroot] if present
       
   164             if ( $emul =~ m|\[sdkroot\](.*)|i )
       
   165             {
       
   166                 $emul = $1;
       
   167             }
       
   168             
       
   169             last;
       
   170         }
       
   171     }
       
   172 
       
   173 
       
   174     # if [emul] not defined, enter a default
       
   175     if ($emul EQ "")
       
   176     {
       
   177         $emul = "bin\\TechView";
       
   178     }
       
   179 
       
   180    
       
   181     # write file with replaced emul
       
   182     open (FILE, ">$pkgDefFile") or print "WARNING: Supplementary Kits: Couldn't write file $pkgDefFile\n";
       
   183     foreach $line (@pkgList)
       
   184     {
       
   185         if ($line =~ m|<item|gi)
       
   186         {
       
   187     	    $line =~ s|\[emul\]|$emul|g ;
       
   188         }
       
   189     	print FILE $line ;
       
   190     }
       
   191     close(FILE);
       
   192 }