|
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 build all tools2 targets with Raptor, except Raptor itself |
|
12 # and any that were broken upstream when last checked. |
|
13 |
|
14 use strict; |
|
15 use perl_run; |
|
16 use set_epocroot; |
|
17 use check_os; |
|
18 my $keepgoing = 0; |
|
19 my @built = (); |
|
20 my @failed = (); |
|
21 my @skipped = (); |
|
22 |
|
23 sub build($) |
|
24 { |
|
25 my $targ = shift; |
|
26 return, if (is_built($targ)); |
|
27 print ">>> Building target $targ\n"; |
|
28 my $rc = perl_run("build_target.pl $targ"); |
|
29 if ($rc) { |
|
30 print "*** Failed to build target $targ ***"; |
|
31 if ($keepgoing) { |
|
32 push(@failed,$targ); |
|
33 } else { |
|
34 exit $rc; |
|
35 } |
|
36 } else { |
|
37 push(@built,$targ); |
|
38 } |
|
39 } |
|
40 |
|
41 sub is_built($) |
|
42 { |
|
43 my $targ = shift; |
|
44 return grep(/$targ/,@built) != 0; |
|
45 } |
|
46 |
|
47 if (@ARGV) { |
|
48 if (grep(/$ARGV[0]/,("-h","--help"))) { |
|
49 print "This script cleans all TOOLS2 targets with Raptor, " . |
|
50 "except Raptor itself and any that were broken upstream when last checked.\n"; |
|
51 print "Valid arguments are -h, --help; -k, --keepgoing, or none.\n"; |
|
52 print "-k, --keepgoing makes the script carry on after a failed clean,\n"; |
|
53 exit 0; |
|
54 } elsif (grep(/$ARGV[0]/,("-k","--keepgoing"))) { |
|
55 $keepgoing = 1; |
|
56 } else { |
|
57 print "Valid arguments are -h, --help; -k, --keepgoing, or none.\n". |
|
58 exit 1; |
|
59 } |
|
60 } |
|
61 set_epocroot(); |
|
62 my $epocroot = $ENV{'EPOCROOT'}; |
|
63 my @targ_lines = perl_slurp("list_targets.pl"); |
|
64 open DEPS,"<deps.txt" or die $!; |
|
65 my @deps = <DEPS>; |
|
66 close DEPS; |
|
67 while (@deps and $deps[0] =~ /^\s*#/) { |
|
68 shift @deps; |
|
69 } |
|
70 foreach my $dep (@deps) { |
|
71 chomp $dep; |
|
72 } |
|
73 my $start_time = time(); |
|
74 foreach my $line (@targ_lines) { |
|
75 chomp $line; |
|
76 next, if ($line =~ /^>>>/); |
|
77 if ($line =~ /(\*\*\*.*\*\*\*)/) { |
|
78 my $reason = $1; |
|
79 my @words = split(/ /,$line); |
|
80 print ">>> Skipping target $words[0]: \"$reason\"\n"; |
|
81 push (@skipped,[$words[0],$reason]); |
|
82 } else { |
|
83 foreach my $dep (@deps) { |
|
84 my ($targ,$prereq) = split(/ /,$dep); |
|
85 if (os_is_windows()) { |
|
86 $targ =~ s/\./\\/g; |
|
87 $prereq =~ s/\./\\/g; |
|
88 } else { |
|
89 $targ =~ s/\./\//g; |
|
90 $prereq =~ s/\./\//g; |
|
91 } |
|
92 next, unless ($targ eq $line); |
|
93 build($prereq); |
|
94 } |
|
95 build($line); |
|
96 } |
|
97 } |
|
98 if (@built) { |
|
99 if (@failed == 0) { |
|
100 print ">>> Built all eligible targets:-\n"; |
|
101 } else { |
|
102 print ">>> Built eligible targets:-\n"; |
|
103 } |
|
104 foreach my $targ (@built) { |
|
105 print "+++ $targ\n"; |
|
106 } |
|
107 } |
|
108 if (@failed) { |
|
109 print ">>> Failed to build eligible targets:-\n"; |
|
110 foreach my $targ (@failed) { |
|
111 print "+++ $targ\n"; |
|
112 } |
|
113 } |
|
114 if (@skipped) { |
|
115 print ">>> Skipped targets:-\n"; |
|
116 foreach my $skipped (@skipped) { |
|
117 print "+++ " . $skipped->[0] . ' ' . $skipped->[1] . "\n"; |
|
118 } |
|
119 } |
|
120 my $end_time = time(); |
|
121 use integer; |
|
122 my $elapsed_time = $end_time - $start_time; |
|
123 my $hours = $elapsed_time / 3600; |
|
124 $elapsed_time -= ($hours * 3600); |
|
125 my $mins = $elapsed_time / 60; |
|
126 my $secs = ($elapsed_time - ($mins * 60)); |
|
127 print ">>> Runtime "; |
|
128 print "$hours hrs ", if ($hours); |
|
129 print "$mins mins $secs secs\n"; |
|
130 exit 0; |
|
131 |