|
1 #!/usr/bin/perl |
|
2 # Copyright (c) 2010 Symbian Foundation Ltd |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of the License "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Mike Kinghan, mikek@symbian.org for Symbian Foundation Ltd - initial contribution. |
|
10 |
|
11 # Script to remove all files created by building Raptor" |
|
12 |
|
13 use strict; |
|
14 use usage; |
|
15 use perl_run; |
|
16 use File::Spec; |
|
17 use File::Path 'remove_tree'; |
|
18 use set_epocroot; |
|
19 |
|
20 usage(\@ARGV,"This script removes all files created by building Raptor"); |
|
21 my $any_old_targ = File::Spec->catfile("buildtoolguides","romtoolsguide"); |
|
22 my $build_log = perl_slurp("build_target.pl $any_old_targ --what 2> ". File::Spec->devnull()); |
|
23 $build_log =~ /<info>Environment HOSTPLATFORM_DIR=(\S*)<\/info>/; |
|
24 my $host_platform_dir = $1; |
|
25 die "*** Error: Can't determine HOSTPLATFORM_DIR ***", unless ($host_platform_dir); |
|
26 set_epocroot(); |
|
27 my $epocroot = $ENV{'EPOCROOT'}; |
|
28 my $abs_host_platform_dir = File::Spec->catfile("$epocroot","build","sbsv2","raptor","$host_platform_dir"); |
|
29 if (-d $abs_host_platform_dir) { |
|
30 print ">>> Clean Raptor\n"; |
|
31 perl_run("clean_raptor.pl") and die $!; |
|
32 print ">>> Delete the HOSTPLATFORM_DIR\n"; |
|
33 print ">>> HOSTPLATFORM_DIR = \"$abs_host_platform_dir\"\n"; |
|
34 my $remove_tree_err; |
|
35 remove_tree($abs_host_platform_dir, { verbose => 1, error => \$remove_tree_err }); |
|
36 if (@$remove_tree_err) { |
|
37 print "*** Error(s) while deleting HOSTPLATFORM_DIR ***\n"; |
|
38 for my $diag (@$remove_tree_err) { |
|
39 my ($file, $message) = %$diag; |
|
40 if ($file eq '') { |
|
41 print "+++ General error: $message\n"; |
|
42 } else { |
|
43 print "+++ Error unlinking \"$file\": $message\n"; |
|
44 } |
|
45 } |
|
46 exit 1; |
|
47 } |
|
48 } |
|
49 print ">>> OK\n"; |
|
50 exit 0; |
|
51 |