diff -r 000000000000 -r 83f4b4db085c toolsandutils/productionbldtools/exportipr.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolsandutils/productionbldtools/exportipr.pl Tue Feb 02 01:39:43 2010 +0200 @@ -0,0 +1,537 @@ +#! /usr/bin/perl +# Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# This script scans a directory and determines the category of all exported +# files which would be produced if all bld.inf files present were built. +# Note that EPOCROOT needs to be set for this to resolve the destination of +# the exports correctly in most cases. +# +# + +use KitStandardLocations; +my $localEpocRoot = "$OutputDir\\generic\\"; +$pathToE32Variant = $localEpocRoot."epoc32\\tools"; +unshift (@INC, $pathToE32Variant); # add this to the @INC list of library paths + +# set up environment for E32Variant initialisation & preserve old value +my $oldEpocRoot = $ENV{EPOCROOT}; +$ENV{EPOCROOT} = $localEpocRoot; +require E32Variant; +# restore environment +$ENV{EPOCROOT} = $oldEpocRoot; + + +$noSource = 0; # Set to 1 to run with only .inf files and DISTRIBUTION.POLICY files present +$noMissing = 0; # Set to 1 to ignore errors about missing source files (only valid if $noSource is 0, obviously) - to ignore broken bld.inf files + +# Discriminate between '-options' and 'parameters' +my @parms = grep(!/^-/,@ARGV); +my @options = grep(/^-/,@ARGV); + +$bldinf = 0; +$restrict = 0; +$cats = {}; +$export = 0; +$zorcdrive = 0; +my $sourceRoot; +my $option; +my $path; +my $script; + +# Parse options first +my $index=0; +while ($index < scalar(@ARGV)) + { + $option = $ARGV[$index]; + + if (lc($option) =~ /^-c/) + { + # Categories - record each category entered + if (lc($option) eq "-c") + { + $index++; + if ($index < scalar(@ARGV)) + { + $option = $ARGV[$index]; + } + else + { + die "Option '-c' has missing parameters\n"; + } + + if ($option =~ /^-/) + { + die "Option '-c' has missing parameters\n"; + } + } + else + { + $option =~ s/^-c//i; + } + + foreach my $char (split(//,$option)) + { + if ($char =~ /[ABCDEFGXIOT]/) + { + $cats->{lc($char)} = 1; + } + else + { + die "Category $char from '$option' is not a valid IPR category\n"; + } + } + } + elsif (lc($option) eq "-bldinf") + { + # Report bldinfs + $bldinf = 1; + } + elsif (lc($option) eq "-export") + { + # Include export restricted files + $export = 1; + } + elsif (lc($option) eq "-restricted") + { + # Include only export restricted files + $restrict = 1; + } + elsif (lc($option) =~ /^-src/) + { + # Source path + if (lc($option) eq "-src") + { + $index++; + if ($index < scalar(@ARGV)) + { + $option = $ARGV[$index]; + } + else + { + die "Option '-src' is missing its parameter\n"; + } + + if ($option =~ /^-/) + { + die "Option '-src' is missing its parameter\n"; + } + } + else + { + $option =~ s/^-src//i; + } + + $sourceRoot = $option; + } + elsif (lc($option) =~ /^-genbuild/) + { + # Genbuild compatible script + if (lc($option) eq "-genbuild") + { + $index++; + if ($index < scalar(@ARGV)) + { + $option = $ARGV[$index]; + } + else + { + die "Option '-genbuild' is missing its parameter\n"; + } + + if ($option =~ /^-/) + { + die "Option '-genbuild' is missing its parameter\n"; + } + } + else + { + $option =~ s/^-genbuild//i; + } + + $script = $option; + } + elsif (lc($option) =~ /^-/) + { + help(); + print "\nOption \"$option\" not recognised.\n"; + exit(0); + } + else + { + if (defined($path)) + { + die "Only one path can be scanned at a time (not '$path' and '$option')\n"; + } + else + { + $path = $option; + } + } + + $index++; + } + +if ($export && $restrict) + { + # -restricted overrides -export + $export = 0; + } + +if (!defined ($sourceRoot)) + { + help(); + print "\nexportipr.pl expects a source path to the source tree as a parameter\n"; + exit(0); + } + +if (defined($path) && defined($script)) + { + help(); + print "\nexportipr.pl can only scan a path or parse a script, not both\n"; + exit(0); + } + +# read in macros defined in this build +my $variantMacros = ""; +foreach my $macro (E32Variant::Variant_GetMacroList()) + { + $macro =~ s/\s+$//; # strip trailing spaces + $variantMacros = $variantMacros . " -D" . $macro ; + } + +if (defined($script)) + { + parse($script, $sourceRoot, $variantMacros); + } +else + { + $path =~ s/[\/\\]+$//; + + scan($path, $sourceRoot, $variantMacros); + } + +exit(1); + +# Recursively check a path for bld.inf files and process them. +sub scan($$$) + { + my ($aPath, $aRoot, $variantMacros) = @_; + + opendir(DIR, $aRoot."/".$aPath) or die "Path $aRoot/$aPath not found!\n"; + + foreach my $entry (readdir(DIR)) + { + if (($entry ne ".") and ($entry ne "..")) + { + if (-d $aRoot."/".$aPath."/".$entry) + { scan($aPath."/".$entry, $aRoot, $variantMacros); } + elsif (lc($entry) eq "bld.inf") + { + getExports($aPath."/".$entry, $aRoot, $variantMacros); + } + } + } + + closedir(DIR); + } + +# Scan a genbuild script file for bld.inf files and process them. +sub parse($$$) + { + my ($aScript, $aRoot, $variantMacros) = @_; + + open(SCRIPT, $aScript) or die "Genbuild script '$aScript' not found\n"; + + foreach my $line (