0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
my @rootdirs;
|
|
18 |
open PIPE, "dir /b /ad \\ |";
|
|
19 |
while (<PIPE>) {
|
|
20 |
my $dir=$_;
|
|
21 |
# print;
|
|
22 |
chomp $dir;
|
|
23 |
unless (/^epoc32$/i) {
|
|
24 |
$dir="\\".$dir."\\*.bld";
|
|
25 |
push @rootdirs, $dir;
|
|
26 |
}
|
|
27 |
}
|
|
28 |
close PIPE;
|
|
29 |
my %bldfiles;
|
|
30 |
my $dir;
|
|
31 |
foreach $dir (@rootdirs) {
|
|
32 |
# print "$dir\n";
|
|
33 |
open PIPE, "dir /s /b $dir 2>NUL |";
|
|
34 |
while (<PIPE>) {
|
|
35 |
my %bldfileprops;
|
|
36 |
$bldfileprops{'fullname'}=lc $_;
|
|
37 |
/\\(\w+)\.bld$/;
|
|
38 |
my $name=lc $1;
|
|
39 |
$bldfileprops{'name'}=$name;
|
|
40 |
if (defined $bldfiles{$name}) {
|
|
41 |
die "Duplicate build file name $name\n";
|
|
42 |
}
|
|
43 |
$bldfiles{$name}=\%bldfileprops;
|
|
44 |
}
|
|
45 |
close PIPE;
|
|
46 |
}
|
|
47 |
|
|
48 |
my $bld;
|
|
49 |
my @defaults;
|
|
50 |
my @compulsory;
|
|
51 |
foreach $bld (keys %bldfiles) {
|
|
52 |
my $ref=$bldfiles{$bld};
|
|
53 |
my $filename=$$ref{'fullname'};
|
|
54 |
chomp $filename;
|
|
55 |
my @options;
|
|
56 |
my @components;
|
|
57 |
open FILE, $filename or die "Could not open file $filename\n";
|
|
58 |
while (<FILE>) {
|
|
59 |
if (/^\!(\w+)$/) {
|
|
60 |
$$ref{lc $1}=1;
|
|
61 |
} elsif (/^\<option/i) {
|
|
62 |
push @options, $_;
|
|
63 |
} elsif (!/^\s*$/) {
|
|
64 |
push @components, $_;
|
|
65 |
}
|
|
66 |
}
|
|
67 |
close FILE;
|
|
68 |
$$ref{'options'}=\@options;
|
|
69 |
$$ref{'components'}=\@components;
|
|
70 |
if (!$$ref{'explicit'}) {
|
|
71 |
push @defaults, $bld;
|
|
72 |
}
|
|
73 |
if ($$ref{'compulsory'}) {
|
|
74 |
if ($$ref{'explicit'}) {
|
|
75 |
die "File $filename: can't be COMPULSORY and EXPLICIT\n";
|
|
76 |
}
|
|
77 |
push @compulsory, $bld;
|
|
78 |
}
|
|
79 |
}
|
|
80 |
|
|
81 |
my @todo_temp;
|
|
82 |
my @omit;
|
|
83 |
my $i;
|
|
84 |
my $nargs=scalar(@ARGV);
|
|
85 |
if ($nargs==0) {
|
|
86 |
@todo_temp=@defaults;
|
|
87 |
} else {
|
|
88 |
@todo_temp=@compulsory;
|
|
89 |
for ($i=0; $i<$nargs; ++$i) {
|
|
90 |
my $name=lc($ARGV[$i]);
|
|
91 |
if ($name eq '+') {
|
|
92 |
foreach $bld (@defaults) {
|
|
93 |
push @todo_temp, $bld if (!grep {$bld eq $_} @todo_temp);
|
|
94 |
}
|
|
95 |
} elsif ($name=~/^\-(\w+)$/) {
|
|
96 |
if (defined $bldfiles{$1}) {
|
|
97 |
my $ref=$bldfiles{$1};
|
|
98 |
if ($$ref{'compulsory'}) {
|
|
99 |
die "Cannot omit $1\n";
|
|
100 |
}
|
|
101 |
push @omit, $1 if (!grep {$1 eq $_} @omit);
|
|
102 |
} else {
|
|
103 |
die "Unrecognised build $1\n";
|
|
104 |
}
|
|
105 |
} elsif (defined $bldfiles{$name}) {
|
|
106 |
push @todo_temp, $name if (!grep {$name eq $_} @todo_temp);
|
|
107 |
} else {
|
|
108 |
die "Unrecognised build $name\n";
|
|
109 |
}
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|
|
113 |
#print join "\n",@todo_temp;
|
|
114 |
#print "\n";
|
|
115 |
|
|
116 |
my @todo;
|
|
117 |
foreach $bld (@todo_temp) {
|
|
118 |
push @todo, $bld if (!grep {$bld eq $_} @omit);
|
|
119 |
}
|
|
120 |
|
|
121 |
#print join "\n",@todo;
|
|
122 |
#print "\n";
|
|
123 |
|
|
124 |
my @output1;
|
|
125 |
my @output2;
|
|
126 |
my $nvariants=0;
|
|
127 |
foreach $bld (@todo) {
|
|
128 |
my $ref=$bldfiles{$bld};
|
|
129 |
next if ($nargs==0 && $$ref{'explicit'});
|
|
130 |
++$nvariants if (!$$ref{'incremental'});
|
|
131 |
my $optref=$$ref{'options'};
|
|
132 |
my $compref=$$ref{'components'};
|
|
133 |
my $option;
|
|
134 |
my $component;
|
|
135 |
foreach $option (@$optref) {
|
|
136 |
$option=~s/\s+/ /;
|
|
137 |
if (!grep {$_ eq $option} @output1) {
|
|
138 |
push @output1, $option;
|
|
139 |
}
|
|
140 |
}
|
|
141 |
foreach $component (@$compref) {
|
|
142 |
$component=~s/\s+/ /;
|
|
143 |
if (!grep {$_ eq $component} @output2) {
|
|
144 |
push @output2, $component;
|
|
145 |
}
|
|
146 |
}
|
|
147 |
}
|
|
148 |
|
|
149 |
if ($nvariants==0) {
|
|
150 |
die "No variants specified for building\n";
|
|
151 |
}
|
|
152 |
|
|
153 |
@output1=sort @output1;
|
|
154 |
@output2=sort @output2;
|
|
155 |
|
|
156 |
my $output;
|
|
157 |
foreach (@output1) {
|
|
158 |
$output.=$_;
|
|
159 |
}
|
|
160 |
$output.="\n";
|
|
161 |
foreach (@output2) {
|
|
162 |
$output.=$_;
|
|
163 |
}
|
|
164 |
$output.="\n";
|
|
165 |
|
|
166 |
print "\n\n$output";
|
|
167 |
|