blob: 858da360fb6f31fcba2b810f06f7aaf5ea9ddf93 [file] [log] [blame]
Mark Whitley1171c2f2001-01-04 01:05:55 +00001#!/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.
Eric Andersenaf4ac772001-02-01 22:43:49 +00008#
9# TODO: some time it might be nice to list absolute and
10# differential object sizes for each option...
11#
Mark Whitley1171c2f2001-01-04 01:05:55 +000012
13$logfile = "multibuild.log";
14
Eric Andersenaf4ac772001-02-01 22:43:49 +000015# How to handle all the BB_FEATURE_FOO lines
16if ($ARGV[0] eq "-all" ) { shift(@ARGV); $choice="all"; }
17if ($ARGV[0] eq "-none") { shift(@ARGV); $choice="none"; }
18# neither means, leave that part of Config.h alone
19
Mark Whitley1171c2f2001-01-04 01:05:55 +000020# Support building from pristine source
21$make_opt = "-f $ARGV[0]/Makefile BB_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne "");
22
23# Move the config file to a safe place
24-e "Config.h.orig" || 0==system("mv -f Config.h Config.h.orig") || die;
25
26# Clear previous log file, if any
27unlink($logfile);
28
29# Parse the config file
30open(C,"<Config.h.orig") || die;
31while (<C>) {
32 if ($in_trailer) {
Eric Andersenaf4ac772001-02-01 22:43:49 +000033 if (!$in_olympus) {
34 s/^\/\/#/#/ if ($choice eq "all" && !/USE_DEVPS_PATCH/);
35 s/^#/\/\/#/ if ($choice eq "none");
36 }
37 $in_olympus=1 if /End of Features List/;
Mark Whitley1171c2f2001-01-04 01:05:55 +000038 $trailer .= $_;
39 } else {
40 $in_trailer=1 if /End of Applications List/;
Matt Kraai201dc0d2001-01-29 19:00:48 +000041 if (/^\/*#define BB_([A-Z0-9_]*)/) {
Mark Whitley1171c2f2001-01-04 01:05:55 +000042 push @apps, $1;
43 }
44 }
45}
46close C;
47
48# Do the real work ...
Eric Andersenaf4ac772001-02-01 22:43:49 +000049$failed_tests=0;
Mark Whitley1171c2f2001-01-04 01:05:55 +000050for $a (@apps) {
51 # print "Testing build of applet $a ...\n";
52 open (O, ">Config.h") || die;
53 print O "#define BB_$a\n", $trailer;
54 close O;
55 system("echo -e '\n***\n$a\n***' >>$logfile");
56 # todo: figure out why the "rm -f *.o" is needed
57 $result{$a} = system("rm -f *.o; make $make_opt busybox >>$logfile 2>&1");
Eric Andersenaf4ac772001-02-01 22:43:49 +000058 $flag = $result{$a} ? "FAILED!!!" : "ok";
59 printf("Applet %-20s: %s\n", $a, $flag);
60 $total_tests++;
61 $failed_tests++ if $flag eq "FAILED!!!";
62 # pause long enough to let user stop us with a ^C
63 select(undef, undef, undef, 0.05);
Mark Whitley1171c2f2001-01-04 01:05:55 +000064}
65
66# Clean up our mess
67system("mv -f Config.h.orig Config.h");
68
Eric Andersenaf4ac772001-02-01 22:43:49 +000069print "$total_tests applets tested, $failed_tests failures\n";
Mark Whitley1171c2f2001-01-04 01:05:55 +000070print "See $logfile for details.\n";
71