uh_parser/truclean.pl
author andy simpson <andrews@symbian.org>
Fri, 15 Oct 2010 16:47:51 +0100
changeset 326 c0fb460d1a21
parent 311 09f57a9bad07
permissions -rw-r--r--
add id for s^4 kits
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
177
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:
258
08436a227940 Add author information. Reviewed descriptions
Dario Sestito <darios@symbian.org>
parents: 177
diff changeset
    11
# Dario Sestito <darios@symbian.org>
177
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:
258
08436a227940 Add author information. Reviewed descriptions
Dario Sestito <darios@symbian.org>
parents: 177
diff changeset
    14
# Clean environment by removing releaseable files based on info.tsv
177
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
281
b9b02349bd48 Change default releaseablesdir to \build_info\logs\releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    19
my $RELEASEABLES_DIR_DEFAULT = "\\build_info\\logs\\releaseables";
177
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 = '';
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    23
my $dryrun = 0;
177
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,
281
b9b02349bd48 Change default releaseablesdir to \build_info\logs\releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    27
	'releaseablesdir:s' => \$releaseablesdir,
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    28
	'dryrun!' => \$dryrun,
177
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
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    32
$help = 1 if (!$packageexpr);
177
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
{
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    36
	print <<_EOH;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    37
truclean
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
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: 281
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: 281
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: 281
diff changeset
    42
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
diff changeset
    44
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    45
Options:
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
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: 281
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: 281
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: 281
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: 281
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: 281
diff changeset
    52
                        is assumed. 
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
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: 281
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: 281
diff changeset
    56
_EOH
177
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
281
b9b02349bd48 Change default releaseablesdir to \build_info\logs\releaseables
Dario Sestito <darios@symbian.org>
parents: 258
diff changeset
    60
$releaseablesdir = $RELEASEABLES_DIR_DEFAULT if (!$releaseablesdir);
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
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: 281
diff changeset
    64
$packageexpr =~ s,^/,,;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    65
if (-d "$releaseablesdir/sf")
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
{
311
09f57a9bad07 Add 'adapt' to the list of layers to match for heuristical pacakge attribution and for truclean
Dario Sestito <darios@symbian.org>
parents: 297
diff changeset
    67
	$packageexpr = "sf/$packageexpr" if ($packageexpr =~ m,^(adaptation|adapt|app|mw|os|tools),);
177
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
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
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: 281
diff changeset
    72
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    73
for my $targetfile (@targetfiles)
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
{
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
diff changeset
    76
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
diff changeset
    78
	while (<FILE>)
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
	{
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    80
		my $line = $_;
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    81
		
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    82
		if ($line =~ m,([^\t]*)\t([^\t]*)\t([^\t]*),)
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
		{
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
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: 281
diff changeset
    86
			my $config = $3;
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
			
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    88
			if (-f $file)
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
			{
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
diff changeset
    91
				unlink($file) if (!$dryrun);
177
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
			{
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    95
				print "WARNING: file '$file' doesn't exist.\n";
177
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
		}
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    98
		else
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
    99
		{
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
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: 281
diff changeset
   101
		}
177
6d3c3db11e72 Add Raptor uh parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
	}
297
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
   103
	close(FILE);
822b287b5899 Truclean to take account of new /sf/ directory level in the releaseables
Dario Sestito <darios@symbian.org>
parents: 281
diff changeset
   104
}