diff -r 22486c9c7b15 -r 378360dbbdba srctools/distillsrc/distillsrc.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srctools/distillsrc/distillsrc.pl Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,99 @@ +#!/bin/perl -w +# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "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: +# distillsrc.pl - compiles a list of source used in .mrp files, and deletes +# any unused source +# +# + +use strict; +use FindBin; +use Getopt::Long; +use File::Spec; + +use lib $FindBin::Bin; +use distillsrc; + +my $errorLevel = 0; + +# Distillsrc is to continue on error rather than die. A warning handler is used +# so that we can still exit with an error level. +$SIG{__WARN__} = sub {warn @_; + $errorLevel = 1}; + +sub dieHelp() + { + print < \$config, "file=s" => \@files, "mrp=s" => \@mrps, "srcroot|r=s" => \$srcroot, "srcpath|s=s" => \$srcpath, "srcprefix|p=s" => \$srcprefix, "platform|l=s" => \$platform, "dummy" => \$dummy, "help" => \$help, "nocheck|n" => \$nocheckcase); + +if ($help) + { + dieHelp(); + } + + +my $distiller=New CDistillSrc($srcroot, $srcpath, $srcprefix, $platform, !$nocheckcase); + +if (!defined($distiller)) + { + dieHelp(); + } + +if (!($distiller->LoadMrps($config, \@files, \@mrps))) + { + exit 1; # Couldn't read all the mrps - don't start deleting source based on incomplete data + } + +$distiller->Print(0); + +# Run through the source tree, matching every file against the source items. Anything that doesn't, delete it (or warn, if we're doing a dummy run). + +$distiller->DistillSrc($dummy); + +exit $errorLevel;