- add --clean option to make it easy to clean up afterward

- try to find the configure script and set the path correctly, in case
  the script is run from the main directory, build, etc.
- name the build directories build-$name so they don't overwrite anything.
  Now that I have "rm -rf" in my script I wanted to be a little more careful.
This commit is contained in:
Bryce Denney 2002-09-15 14:35:38 +00:00
parent 7a11ed547d
commit fa0dfd7994
1 changed files with 56 additions and 13 deletions

View File

@ -1,4 +1,7 @@
#!/usr/bin/perl
#####################################################################
# $Id: batch-build.perl,v 1.2 2002-09-15 14:35:38 bdenney Exp $
#####################################################################
#
# Batch build tool for multiple configurations
#
@ -11,19 +14,17 @@
# --nohup --parallel: parallel, output to nohup.out
# --parallel: parallel, spawn xterm for each
#
# Testing:
# no args: good
# nohup: good
# parallel: ?
# nohup parallel: ?
sub usage {
print <<EOF;
Usage: $0 [--nohup] [--parallel]
--nohup causes the output of all compiles to go into nohup.out
--parallel causes all compiles to be run in parallel
Usage: $0 --clean
--clean erases the build directories and recreates them from scratch
Combinations of nohup and parallel:
no args: serial compile, output goes to stdout
--nohup: serial compile, output goes into individual nohup.out files
--nohup --parallel: parallel compile, output goes to individual nohup.out files
@ -35,10 +36,12 @@ $DEBUG=0;
$pwd = `pwd`;
chop $pwd;
# create all the configurations that we should test
# create all the configurations that we should test. The first argument
# is the configuration name, which must be a valid directory name. To be
# safe, don't put spaces, slashes, ".", or ".." in here.
add_configuration ('normal',
'');
add_configuration ('debug',
add_configuration ('dbg',
'--enable-debugger');
add_configuration ('smp2',
'--enable-processors=2');
@ -57,10 +60,13 @@ add_configuration ('wx-64bit',
add_configuration ('wx-64bit-d',
'--with-wx --enable-x86-64 --enable-debugger --disable-readline');
$nohup = 0;
$parallel = 0;
my $nohup = 0;
my $parallel = 0;
my $clean = 0;
foreach my $arg (@ARGV) {
if ($arg eq '--nohup') {
if ($arg eq '--clean') {
$clean = 1;
} elsif ($arg eq '--nohup') {
$nohup = 1;
} elsif ($arg eq '--parallel') {
$parallel = 1;
@ -69,18 +75,51 @@ foreach my $arg (@ARGV) {
}
}
# this script may be run from various directories, and this affects
# the path to the configure command. Try to figure out where the configure
# command is found, and set up the build.sh scripts accordingly. If it
# can't be found, spit out an error now instead of later.
my @configurepath_tries = ("configure", "../configure", "../../configure");
my $configurepath;
foreach my $trypath (@configurepath_tries) {
if (-x $trypath) {
print "Found configure at $configurepath.\n" if $DEBUG;
$configurepath = $trypath;
}
}
if (!defined $configurepath) {
print <<EOF;
ERROR I could not locate the configure script. This script is intended
to be run from the bochs main directory or a subdirectory of it. Examples:
1) cd $BOCHS; ./build/batch-build.perl
2) cd $BOCHS/build; ./batch-build.perl
Here are the places that I tried to find the configure script:
EOF
foreach (@configurepath_tries) {
print " $_\n";
}
exit 1;
}
for (my $i=0; $i <= $#config_names; $i++) {
my $name = $config_names[$i];
my $name = "build-$config_names[$i]";
my $options = $config_opts[$i];
die if (!defined $name || !defined $options);
print "Compiling '$name' with opts '$options'\n" if $DEBUG;
if ($clean) {
my $rmcmd = "rm -rf $name";
print "Removing directory $name\n";
system $rmcmd;
next;
}
if (! -d $name) { mkdir $name, 0755; }
$maybe_nohup = $nohup? "nohup" : "";
open (BUILD, ">$name/build.sh");
print BUILD <<BUILD_EOF;
#!/bin/bash
echo Running the configure script
$maybe_nohup ../../configure $options
$maybe_nohup ../$configurepath $options
if test $? != 0; then
echo Configure failed.
exit 1
@ -138,6 +177,10 @@ XTI_EOF
system $cmd;
}
print "\n"x2;
print "batch-build script is done.\n";
exit 0;
sub add_configuration {
my ($name, $opts) = @_;
push @config_names, $name;