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