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-- |
176 | 1 |
# Copyright (c) 2009 Symbian Foundation Ltd |
2 |
# This component and the accompanying materials are made available |
|
3 |
# under the terms of the License "Eclipse Public License v1.0" |
|
4 |
# which accompanies this distribution, and is available |
|
5 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
6 |
# |
|
7 |
# Initial Contributors: |
|
8 |
# Symbian Foundation Ltd - initial contribution. |
|
9 |
# |
|
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 | 12 |
# |
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 | 15 |
|
16 |
use strict; |
|
17 |
use Getopt::Long; |
|
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 | 20 |
|
21 |
my $releaseablesdir = ""; |
|
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 | 24 |
my $help = 0; |
25 |
GetOptions(( |
|
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 | 29 |
'help!' => \$help |
30 |
)); |
|
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 | 33 |
|
34 |
if ($help) |
|
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 | 57 |
exit(0); |
58 |
} |
|
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 | 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 | 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 | 68 |
} |
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 | 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 | 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 | 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 | 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 | 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 | 92 |
} |
93 |
else |
|
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 | 96 |
} |
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 | 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 |
} |