uh_parser/truclean.pl
author Maciej Seroka <maciejs@symbian.org>
Wed, 07 Jul 2010 12:42:22 +0100
changeset 278 247cb9582bd0
parent 271 822b287b5899
child 284 09f57a9bad07
permissions -rw-r--r--
Updated scripts for filtering BC reports
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
236
08436a227940 Add author information. Reviewed descriptions
Dario Sestito <darios@symbian.org>
parents: 176
diff changeset
    11
# Dario Sestito <darios@symbian.org>
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
#
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Description:
236
08436a227940 Add author information. Reviewed descriptions
Dario Sestito <darios@symbian.org>
parents: 176
diff changeset
    14
# Clean environment by removing releaseable files based on info.tsv
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
use strict;
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
use Getopt::Long;
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
258
b9b02349bd48 Change default releaseablesdir to \build_info\logs\releaseables
Dario Sestito <darios@symbian.org>
parents: 236
diff changeset
    19
my $RELEASEABLES_DIR_DEFAULT = "\\build_info\\logs\\releaseables";
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
my $releaseablesdir = "";
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
my $packageexpr = '';
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    23
my $dryrun = 0;
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
my $help = 0;
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
GetOptions((
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
	'packageexpr:s' => \$packageexpr,
258
b9b02349bd48 Change default releaseablesdir to \build_info\logs\releaseables
Dario Sestito <darios@symbian.org>
parents: 236
diff changeset
    27
	'releaseablesdir:s' => \$releaseablesdir,
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    28
	'dryrun!' => \$dryrun,
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
	'help!' => \$help
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
));
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    32
$help = 1 if (!$packageexpr);
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
if ($help)
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
{
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    36
	print <<_EOH;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    37
truclean
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    38
Performs a 'clean' build step, based on the releaseables information, i.e. the
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    39
list of artifacts produced during a PDK build.
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    40
This cleaning step ensures all the build artifacts produced by the build are
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    41
actually removed even if the source code has changed since the PDK build. 
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    42
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    43
Usage: truclean.pl -p PACKAGE_EXPR [-r RELEASABLES_DIR] [-d]
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    44
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    45
Options:
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    46
  -h, --help            Show this help message and exit
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    47
  -p PACKAGE_EXPR       Clean (remove) build artifacts belonging to the package
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    48
                        or packages indicated by PACKAGE_EXPR.
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    49
                        PACKAGE_EXPR is the path (wildcards allowed) of the
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    50
                        package, e.g. 'sf/app/camera' or 'sf/mw/*' or '*/*/*'.
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    51
                        If the first directory level is not specified then 'sf'
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    52
                        is assumed. 
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    53
  -r RELEASABLES_DIR    Use RELEASEABLES_DIR as root of the releaseable files
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    54
                        (default is $RELEASEABLES_DIR_DEFAULT).
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    55
  -d                    Dry run (Do not remove files for real)
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    56
_EOH
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
	exit(0);
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
}
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
258
b9b02349bd48 Change default releaseablesdir to \build_info\logs\releaseables
Dario Sestito <darios@symbian.org>
parents: 236
diff changeset
    60
$releaseablesdir = $RELEASEABLES_DIR_DEFAULT if (!$releaseablesdir);
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    62
$packageexpr =~ s,\\,/,g;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    63
$packageexpr =~ s,//,/,g;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    64
$packageexpr =~ s,^/,,;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    65
if (-d "$releaseablesdir/sf")
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
{
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    67
	$packageexpr = "sf/$packageexpr" if ($packageexpr =~ m,^(adaptation|app|mw|os|tools),);
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
}
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    70
my @targetfiles = grep {-f$_} glob("$releaseablesdir/$packageexpr/info.tsv");
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    71
print join("\n", @targetfiles);
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    72
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    73
for my $targetfile (@targetfiles)
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
{
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    75
	print "Processing $targetfile...\n";
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    76
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    77
	open(FILE, $targetfile);
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    78
	while (<FILE>)
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
	{
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    80
		my $line = $_;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    81
		
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    82
		if ($line =~ m,([^\t]*)\t([^\t]*)\t([^\t]*),)
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
		{
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    84
			my $file = $1;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    85
			my $type = $2;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    86
			my $config = $3;
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
			
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    88
			if (-f $file)
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
			{
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    90
				print "removing file: '$file'\n";
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    91
				unlink($file) if (!$dryrun);
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
			}
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
			else
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    94
			{
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    95
				print "WARNING: file '$file' doesn't exist.\n";
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
			}
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
		}
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    98
		else
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    99
		{
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
   100
			print "WARNING: line '$line' doesn't match the expected tab-separated pattern\n";
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
   101
		}
176
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
	}
271
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
   103
	close(FILE);
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
   104
}