srctools/distillsrc/distillsrc.pl
author jjkang
Fri, 25 Jun 2010 19:56:45 +0800
changeset 604 b33dd54aaa52
parent 602 3145852acc89
permissions -rw-r--r--
add cpptoolsplat
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
#!/bin/perl -w
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# distillsrc.pl - compiles a list of source used in .mrp files, and deletes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
# any unused source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use FindBin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use Getopt::Long;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use File::Spec;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use lib $FindBin::Bin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use distillsrc;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
my $errorLevel = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
# Distillsrc is to continue on error rather than die.  A warning handler is used
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
# so that we can still exit with an error level.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
$SIG{__WARN__} = sub {warn @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
                      $errorLevel = 1};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
sub dieHelp()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
	print <<HELP_EOF;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
  Usage: perl distillsrc.pl [-f file] [-m file] [-c file] -r src_root
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
    -s source_path [-p src_prefix] -l platform [-n] [-d] [-h help];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  Options in detail:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
    -file|f file : components.txt file to read (may be more than one)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
    -mrp|m file : additional .mrp file to read (may be more than one)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
    -config|c file : a configuration file to use containing .mrp files to use
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
    -r src_root : The root from which all src statements are based
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
    -s source_path : The path under src_root to the source tree to be processed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
    -p src_prefix : An optional prefix which can be stripped from all src
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
      statements
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
    -l platform : The platform (beech etc), needed in order to locate the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
      correct product directory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
    -n : don't check the case of files in the config file and in .mrps against
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
      the file system
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
    -d : dummy mode
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  Note that the src_prefix in combination with the src_root can be used to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  displace the source tree, if it isn't in it's final location.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
HELP_EOF
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
	exit 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
# Read command line options to find out if we're doing a dummy run, and where the options are
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
my @files = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
my @mrps = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
my $srcroot;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
my $srcprefix;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
my $dummy = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
my $srcpath;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
my $config;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
my $platform;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
my $nocheckcase;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
GetOptions("config=s" => \$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);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
if ($help)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
	dieHelp();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
my $distiller=New CDistillSrc($srcroot, $srcpath, $srcprefix, $platform, !$nocheckcase);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
if (!defined($distiller))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
	dieHelp();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
if (!($distiller->LoadMrps($config, \@files, \@mrps)))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
	exit 1; # Couldn't read all the mrps - don't start deleting source based on incomplete data
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
$distiller->Print(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
# 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).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
$distiller->DistillSrc($dummy);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
exit $errorLevel;