Patch from Larry Doolittle to cross things in multibuild.pl
[oweals/busybox.git] / tests / multibuild.pl
1 #!/usr/bin/perl
2
3 # multibuild.pl
4 # Tests BusyBox-0.48 (at least) to see if each applet builds
5 # properly on its own.  The most likely problems this will
6 # flush out are those involving preprocessor instructions in
7 # utility.c.
8 #
9 # TODO: some time it might be nice to list absolute and 
10 # differential object sizes for each option...
11 #
12
13 $logfile = "multibuild.log";
14
15 # How to handle all the BB_FEATURE_FOO lines
16 if ($ARGV[0] eq "-all" ) { shift(@ARGV); $choice="all"; }
17 if ($ARGV[0] eq "-none") { shift(@ARGV); $choice="none"; }
18 # neither means, leave that part of Config.h alone
19
20 # Support building from pristine source
21 $make_opt = "-f $ARGV[0]/Makefile BB_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne "");
22 make_opt .= " CROSS=arm-linux-";
23
24 # Move the config file to a safe place
25 -e "Config.h.orig" || 0==system("mv -f Config.h Config.h.orig") || die;
26
27 # Clear previous log file, if any
28 unlink($logfile);
29
30 # Parse the config file
31 open(C,"<Config.h.orig") || die;
32 while (<C>) {
33         if ($in_trailer) {
34                 if (!$in_olympus) {
35                         s/^\/\/#/#/ if ($choice eq "all" && !/USE_DEVPS_PATCH/);
36                         s/^#/\/\/#/ if ($choice eq "none");
37                 }
38                 $in_olympus=1 if /End of Features List/;
39                 $trailer .= $_;
40         } else {
41                 $in_trailer=1 if /End of Applications List/;
42                 if (/^\/*#define BB_([A-Z0-9_]*)/) {
43                         push @apps, $1;
44                 }
45         }
46 }
47 close C;
48
49 # Do the real work ...
50 $failed_tests=0;
51 for $a (@apps) {
52         # print "Testing build of applet $a ...\n";
53         open (O, ">Config.h") || die;
54         print O "#define BB_$a\n", $trailer;
55         close O;
56         system("echo -e '\n***\n$a\n***' >>$logfile");
57         # todo: figure out why the "rm -f *.o" is needed
58         $result{$a} = system("rm -f *.o; make $make_opt busybox >>$logfile 2>&1");
59         $flag = $result{$a} ? "FAILED!!!" : "ok";
60         printf("Applet %-20s: %s\n", $a, $flag);
61         $total_tests++;
62         $failed_tests++ if $flag eq "FAILED!!!";
63         # pause long enough to let user stop us with a ^C
64         select(undef, undef, undef, 0.05);
65 }
66
67 # Clean up our mess
68 system("mv -f Config.h.orig Config.h");
69
70 print "$total_tests applets tested, $failed_tests failures\n";
71 print "See $logfile for details.\n";
72