toolsandutils/productionbldtools/BuildKit.pm
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 #!perl
       
     2 
       
     3 # package.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 # Version Info:
       
    19 # Version 001: initial version
       
    20 # Version 002: Typhoon: InstallCustKit.pl added for CustKit 
       
    21 # Version 003: Typhoon: calls GenerateLicenseeBuild.exe before building
       
    22 # Version 004: Typhoon: auto-generates packages before building; 
       
    23 # produces differences between this report & previous build's
       
    24 # calls script to produce CustKit as ZIPs
       
    25 # Version 005: Typhoon: calls docplugintool script 
       
    26 # Version 006: Typhoon: Master Codeline
       
    27 # Version 007: Master Codeline
       
    28 # 
       
    29 #
       
    30 
       
    31 package BuildKit;
       
    32 
       
    33 use Cwd;
       
    34 use File::Basename;
       
    35 use File::Path;
       
    36 
       
    37 use KitStandardLocations;
       
    38 use KitPlatformSpecific;
       
    39 use SupplementalKits;
       
    40 
       
    41 
       
    42 
       
    43 # ------------------------------ Global variables ----------------------------
       
    44 
       
    45 my $Company = "Symbian";
       
    46 
       
    47 
       
    48 my $BuildNumber = $ARGV[0];
       
    49 $Kit_ID = $BuildNumber;
       
    50 
       
    51 my $pkgSrcDefDevKitDir = "$DevKitPath\\$SrcDefDir";
       
    52 my $pkgSrcDefCustKitDir ="$CustKitPath\\$SrcDefDir";
       
    53 
       
    54 my $outputDevKitDir =       "$ProductPath\\_PACKAGES\\DevKit_CD";
       
    55 my $outputCustKitDir =      "$ProductPath\\_PACKAGES\\CustKit_Extra_CD";
       
    56 my $outputCustKitZipsDir =  "$ProductPath\\_PACKAGES\\CustKit_Zips";
       
    57 my $outputInternalZipsDir = "$ProductPath\\generated";
       
    58 
       
    59 my $sourceListDevKit =  "DevKit.srcdef";
       
    60 my $sourceListCustKit = "CustKit.srcdef";
       
    61 
       
    62 my $buildPkg =     "$OutputDir\\generic\\epoc32\\tools\\buildpkg";
       
    63 my $createPkgSrc = "$OutputDir\\generic\\epoc32\\tools\\createpkgsrc";
       
    64 my $diff =         "$OutputDir\\generic\\epoc32\\gcc\\bin\\diff";
       
    65 
       
    66 my $scriptFile =     "InstallCustKit.pl";
       
    67 my $scriptHelpFile = "ReadMe_First.txt";
       
    68 
       
    69 # ----------------- Start of main() ------------------------
       
    70 
       
    71 sub BuildKit()
       
    72 {
       
    73 	# build the Symbian supplied packages
       
    74 	buildPkgSet(\@KitPlatformSpecific::SymbianPkgs);
       
    75 
       
    76 	# create the packages etc. for the DevKit
       
    77 	createDistrib($outputDevKitDir, $pkgSrcDefDevKitDir."\\".$sourceListDevKit);
       
    78 
       
    79 	SupplementalKits::SupplementalKits();
       
    80 }
       
    81 
       
    82 
       
    83 
       
    84 # function builds a set of packages
       
    85 # function returns true if all the packages in the set were built correctly
       
    86 sub buildPkgSet()
       
    87 {
       
    88     my ($packageSet)=@_ ;
       
    89     my $success = 1;
       
    90 
       
    91     # loop through all the packages in the package set
       
    92     foreach my $packageDef (@$packageSet)
       
    93     {
       
    94 		# build this package using the buildpkg tool
       
    95 
       
    96 		print "Building package ".$packageDef->[1]."\n";
       
    97 
       
    98 		my $srcRootArg = "";
       
    99 		my $srcroot = $packageDef->[0];
       
   100 
       
   101 		#check if the source root is empty
       
   102 		if(!($srcroot eq ""))
       
   103 		{
       
   104 		    # the source root argument
       
   105 		    $srcRootArg = " -s ".$srcroot;
       
   106 		}
       
   107 
       
   108 		my $command = $buildPkg." -v -f -o ".$packageDef->[2]." -b ".$BuildNumber." -k ".$Kit_ID.$srcRootArg." ".$packageDef->[1];
       
   109 		$success &= !system($command);
       
   110 	}
       
   111 	return $success;
       
   112 }
       
   113 
       
   114 
       
   115 
       
   116 
       
   117 # function collates the distribution directory contents
       
   118 sub createDistrib()
       
   119 {
       
   120     my $DistribDir = $_[0] ;
       
   121     my $PkgSrcList = $_[1];
       
   122     print "Creating distribution directory in $DistribDir\n";
       
   123 
       
   124     # create the package source for the CustKit
       
   125     createSrc($DistribDir, $PkgSrcList);
       
   126 
       
   127     # add the KSA files to make the kit installable
       
   128     addKSA($DistribDir);
       
   129 
       
   130     # create the setup.ini file for the kit
       
   131     createSetupIni($DistribDir);
       
   132 }
       
   133 
       
   134 
       
   135 
       
   136 
       
   137 
       
   138 # function creates a package source
       
   139 sub createSrc()
       
   140 {
       
   141     chdir($_[0]);
       
   142     
       
   143     my $pkgSrcDefFile = $_[1] ;
       
   144 
       
   145     print "  creating package source using list in $pkgSrcDefFile \n";
       
   146 
       
   147     # read source definition file
       
   148     open (FILE, "<$pkgSrcDefFile") or die "Couldn't open file $pkgSrcDefFile ";
       
   149     my @pkgList = <FILE>;
       
   150     close(FILE);
       
   151     
       
   152     # remove previous copy
       
   153     unlink ($pkgSrcDefFile);
       
   154     
       
   155     # write file with build number
       
   156     open (FILE, ">$pkgSrcDefFile") or die "Couldn't open file $pkgSrcDefFile";
       
   157     foreach $file (@pkgList)
       
   158     {
       
   159     	$file =~ s/%version%/$BuildNumber/g ;
       
   160     	print FILE $file ;
       
   161     }
       
   162     close(FILE);
       
   163 
       
   164     # build the package source XML
       
   165     my $command = $createPkgSrc." -s ".$pkgSrcDefFile ;
       
   166     system($command);
       
   167 }
       
   168 
       
   169 
       
   170 
       
   171 
       
   172 # function amends setup.ini file created by the KSA
       
   173 sub createSetupIni()
       
   174 {
       
   175     chdir($_[0]);
       
   176     print "  amending setup.ini file\n";
       
   177 
       
   178 
       
   179     # create setup.ini file
       
   180     open (FILE, ">>setup.ini") or die "Couldn't open setup.ini";
       
   181 
       
   182     print FILE "[Symbian]\n";
       
   183     print FILE "KitID=$Kit_ID\n";
       
   184     print FILE "TargetDirectory=Symbian";
       
   185 
       
   186     close(FILE);
       
   187 }
       
   188 
       
   189 
       
   190 
       
   191 
       
   192 # function creates adds the KSA files to the Kit
       
   193 sub addKSA()
       
   194 {
       
   195     chdir($_[0]);
       
   196     print "  copying KSA\n";
       
   197 
       
   198     system("copy $OutputDir\\generic\\epoc32\\ksa\\autorun.inf");
       
   199     system("copy $OutputDir\\generic\\epoc32\\ksa\\data1.cab");
       
   200     system("copy $OutputDir\\generic\\epoc32\\ksa\\data1.hdr");
       
   201     system("copy $OutputDir\\generic\\epoc32\\ksa\\data2.cab");
       
   202     system("copy $OutputDir\\generic\\epoc32\\ksa\\ikernel.ex_");
       
   203     system("copy $OutputDir\\generic\\epoc32\\ksa\\layout.bin");
       
   204     system("copy $OutputDir\\generic\\epoc32\\ksa\\Setup.exe");
       
   205     system("copy $OutputDir\\generic\\epoc32\\ksa\\setup.inx");
       
   206     system("copy $OutputDir\\generic\\epoc32\\ksa\\setup.ini");
       
   207     system("copy $OutputDir\\generic\\epoc32\\ksa\\ReadMe.*");
       
   208 }
       
   209 
       
   210