summaryrefslogtreecommitdiff
path: root/tests/multibuild.pl
blob: 46d52ab56a8f1193957bcec7948d2b09fab5d8e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl

# multibuild.pl
# Tests BusyBox-0.48 (at least) to see if each applet builds
# properly on its own.  The most likely problems this will
# flush out are those involving preprocessor instructions in
# utility.c.
#
# TODO: some time it might be nice to list absolute and 
# differential object sizes for each option...
#

$logfile = "multibuild.log";

# How to handle all the BB_FEATURE_FOO lines
if ($ARGV[0] eq "-all" ) { shift(@ARGV); $choice="all"; }
if ($ARGV[0] eq "-none") { shift(@ARGV); $choice="none"; }
# neither means, leave that part of Config.h alone

# Support building from pristine source
$make_opt = "-f $ARGV[0]/Makefile BB_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne "");
make_opt .= " CROSS=arm-linux-";

# Move the config file to a safe place
-e "Config.h.orig" || 0==system("mv -f Config.h Config.h.orig") || die;

# Clear previous log file, if any
unlink($logfile);

# Parse the config file
open(C,"<Config.h.orig") || die;
while (<C>) {
	if ($in_trailer) {
		if (!$in_olympus) {
			s/^\/\/#/#/ if ($choice eq "all" && !/USE_DEVPS_PATCH/);
			s/^#/\/\/#/ if ($choice eq "none");
		}
		$in_olympus=1 if /End of Features List/;
		$trailer .= $_;
	} else {
		$in_trailer=1 if /End of Applications List/;
		if (/^\/*#define BB_([A-Z0-9_]*)/) {
			push @apps, $1;
		}
	}
}
close C;

# Do the real work ...
$failed_tests=0;
for $a (@apps) {
	# print "Testing build of applet $a ...\n";
	open (O, ">Config.h") || die;
	print O "#define BB_$a\n", $trailer;
	close O;
	system("echo -e '\n***\n$a\n***' >>$logfile");
	# todo: figure out why the "rm -f *.o" is needed
	$result{$a} = system("rm -f *.o; make $make_opt busybox >>$logfile 2>&1");
	$flag = $result{$a} ? "FAILED!!!" : "ok";
	printf("Applet %-20s: %s\n", $a, $flag);
	$total_tests++;
	$failed_tests++ if $flag eq "FAILED!!!";
	# pause long enough to let user stop us with a ^C
	select(undef, undef, undef, 0.05);
}

# Clean up our mess
system("mv -f Config.h.orig Config.h");

print "$total_tests applets tested, $failed_tests failures\n";
print "See $logfile for details.\n";