Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 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. |
Eric Andersen | af4ac77 | 2001-02-01 22:43:49 +0000 | [diff] [blame] | 8 | # |
| 9 | # TODO: some time it might be nice to list absolute and |
| 10 | # differential object sizes for each option... |
| 11 | # |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 12 | |
| 13 | $logfile = "multibuild.log"; |
| 14 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 15 | # How to handle all the CONFIG_FEATURE_FOO lines |
Eric Andersen | af4ac77 | 2001-02-01 22:43:49 +0000 | [diff] [blame] | 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 | |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 20 | # Support building from pristine source |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 21 | $make_opt = "-f $ARGV[0]/Makefile CONFIG_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne ""); |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 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 |
| 27 | unlink($logfile); |
| 28 | |
| 29 | # Parse the config file |
| 30 | open(C,"<Config.h.orig") || die; |
| 31 | while (<C>) { |
| 32 | if ($in_trailer) { |
Eric Andersen | af4ac77 | 2001-02-01 22:43:49 +0000 | [diff] [blame] | 33 | 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 Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 38 | $trailer .= $_; |
| 39 | } else { |
| 40 | $in_trailer=1 if /End of Applications List/; |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 41 | if (/^\/*#define CONFIG_([A-Z0-9_]*)/) { |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 42 | push @apps, $1; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | close C; |
| 47 | |
| 48 | # Do the real work ... |
Eric Andersen | af4ac77 | 2001-02-01 22:43:49 +0000 | [diff] [blame] | 49 | $failed_tests=0; |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 50 | for $a (@apps) { |
| 51 | # print "Testing build of applet $a ...\n"; |
| 52 | open (O, ">Config.h") || die; |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 53 | print O "#define CONFIG_$a\n", $trailer; |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 54 | close O; |
| 55 | system("echo -e '\n***\n$a\n***' >>$logfile"); |
Mark Whitley | 056960d | 2001-03-15 22:14:26 +0000 | [diff] [blame] | 56 | # With a fast computer and 1-second resolution on file timestamps, this |
| 57 | # process pushes beyond the limits of what unix make can understand. |
| 58 | # That's why need to weed out obsolete files before restarting make. |
| 59 | $result{$a} = system("rm -f *.o applet_source_list; make $make_opt busybox >>$logfile 2>&1"); |
Eric Andersen | af4ac77 | 2001-02-01 22:43:49 +0000 | [diff] [blame] | 60 | $flag = $result{$a} ? "FAILED!!!" : "ok"; |
| 61 | printf("Applet %-20s: %s\n", $a, $flag); |
| 62 | $total_tests++; |
| 63 | $failed_tests++ if $flag eq "FAILED!!!"; |
| 64 | # pause long enough to let user stop us with a ^C |
Mark Whitley | 056960d | 2001-03-15 22:14:26 +0000 | [diff] [blame] | 65 | select(undef, undef, undef, 0.03); |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | # Clean up our mess |
| 69 | system("mv -f Config.h.orig Config.h"); |
| 70 | |
Eric Andersen | af4ac77 | 2001-02-01 22:43:49 +0000 | [diff] [blame] | 71 | print "$total_tests applets tested, $failed_tests failures\n"; |
Mark Whitley | 1171c2f | 2001-01-04 01:05:55 +0000 | [diff] [blame] | 72 | print "See $logfile for details.\n"; |
| 73 | |