2 #####################################################################
3 # $Id: batch-build.perl,v 1.12 2008/12/11 21:19:38 sshwarts Exp $
4 #####################################################################
6 # Batch build tool for multiple configurations
9 # - show output vs. send it all to nohup. --nohup
10 # - serial or parallel. --parallel
12 # no args: serial, display output
13 # --nohup: serial, output to nohup.out. (Need summary.)
14 # --nohup --parallel: parallel, output to nohup.out
15 # --parallel: parallel, spawn xterm for each
20 Usage: $0 [--nohup] [--parallel]
21 --nohup causes the output of all compiles to go into nohup.out
22 --parallel causes all compiles to be run in parallel
25 --clean erases the build directories and recreates them from scratch
27 Combinations of nohup and parallel:
28 no args: serial compile, output goes to stdout
29 --nohup: serial compile, output goes into individual nohup.out files
30 --nohup --parallel: parallel compile, output goes to individual nohup.out files
31 --parallel: parallel compile, spawn an xterm for each configuration
51 # create all the configurations that we should test. The first argument
52 # is the configuration name, which must be a valid directory name. To be
53 # safe, don't put spaces, slashes, ".", or ".." in here.
55 add_configuration
('normal',
57 add_configuration
('dbg',
62 add_configuration
('plug',
64 add_configuration
('plug-d',
65 '--enable-plugins --enable-debugger');
66 add_configuration
('plug-allgui',
67 '--enable-plugins --with-all-libs');
68 add_configuration
('plug-allgui-d',
69 '--enable-plugins --with-all-libs --enable-debugger');
70 add_configuration
('plug-smp',
71 '--enable-plugins --enable-smp');
72 add_configuration
('plug-smp-d',
73 '--enable-plugins --enable-smp --enable-debugger');
74 add_configuration
('plug-x86-64',
75 '--enable-plugins --enable-x86-64');
76 add_configuration
('plug-wx',
77 '--enable-plugins --with-wx');
81 add_configuration
('alldev',
82 '--enable-ne2000 --enable-pci --enable-port-e9-hack --enable-cdrom --enable-iodebug');
83 add_configuration
('ne2000',
85 add_configuration
('pci',
87 add_configuration
('port-e9-hack',
88 '--enable-port-e9-hack');
89 add_configuration
('cdrom',
91 add_configuration
('gdbstub',
93 add_configuration
('iodebug',
98 # test with various gui options
99 add_configuration
('wx',
101 add_configuration
('wx-d',
102 '--with-wx --enable-debugger');
103 add_configuration
('sdl',
105 add_configuration
('sdl-d',
106 '--with-sdl --enable-debugger');
107 add_configuration
('term',
109 add_configuration
('term-d',
110 '--with-term --enable-debugger');
111 add_configuration
('rfb',
113 add_configuration
('rfb-d',
114 '--with-rfb --enable-debugger');
115 add_configuration
('nogui',
117 add_configuration
('nogui-d',
118 '--with-nogui --enable-debugger');
122 # test with various cpu options
123 add_configuration
('i386',
124 '--enable-cpu-level=3 --disable-mmx');
125 add_configuration
('i486',
126 '--enable-cpu-level=4 --disable-mmx');
127 add_configuration
('i586',
128 '--enable-cpu-level=5');
129 add_configuration
('i686',
130 '--enable-cpu-level=6');
131 add_configuration
('large-pages',
132 '--enable-large-pages');
133 add_configuration
('pae',
135 add_configuration
('repeat',
136 '--enable-repeat-speedups');
137 add_configuration
('globalpg',
138 '--enable-global-pages');
139 add_configuration
('icache',
141 add_configuration
('cpuall',
142 '--enable-large-pages --enable-pae --enable-global-pages --enable-all-optimizations');
147 add_configuration
('smp',
149 add_configuration
('smp-d',
150 '--enable-smp --enable-debugger');
151 add_configuration
('smp-wx',
152 '--enable-smp --with-wx');
153 add_configuration
('smp-wx-d',
154 '--enable-smp --with-wx --enable-debugger');
159 add_configuration
('64bit',
161 add_configuration
('64bit-d',
162 '--enable-x86-64 --enable-debugger');
163 add_configuration
('64bit-wx',
164 '--enable-x86-64 --with-wx');
165 add_configuration
('64bit-wx-d',
166 '--enable-x86-64 --with-wx --enable-debugger');
170 # test SSE configurations
171 add_configuration
('sse1',
173 add_configuration
('sse2',
175 add_configuration
('sse3',
177 add_configuration
('sse4',
179 add_configuration
('sse2-dbg',
180 '--enable-sse=2 --enable-debugger');
181 add_configuration
('sse2-x86-64-wx-d',
182 '--enable-sse=2 --enable-x86-64 --with-wx --enable-debugger');
188 foreach my $arg (@ARGV) {
189 if ($arg eq '--clean') {
191 } elsif ($arg eq '--nohup') {
193 } elsif ($arg eq '--parallel') {
200 # this script may be run from various directories, and this affects
201 # the path to the configure command. Try to figure out where the configure
202 # command is found, and set up the build.sh scripts accordingly. If it
203 # can't be found, spit out an error now instead of later.
204 my @configurepath_tries = ("configure", "../configure", "../../configure");
206 foreach my $trypath (@configurepath_tries) {
208 print "Found configure at $configurepath.\n" if $DEBUG;
209 $configurepath = $trypath;
212 if (!defined $configurepath) {
214 ERROR I could not locate the configure script. This script is intended
215 to be run from the bochs main directory or a subdirectory of it. Examples:
216 1) cd $BOCHS; ./build/batch-build.perl
217 2) cd $BOCHS/build; ./batch-build.perl
219 Here are the places that I tried to find the configure script:
221 foreach (@configurepath_tries) {
231 for (my $i=0; $i <= $#config_names; $i++) {
232 my $name = "build-$config_names[$i]";
233 my $options = $config_opts[$i];
234 die if (!defined $name || !defined $options);
235 print "Compiling '$name' with opts '$options'\n" if $DEBUG;
237 my $rmcmd = "rm -rf $name";
238 print "Removing directory $name\n";
242 if (! -d
$name) { mkdir $name, 0755; }
243 $maybe_nohup = $nohup?
"nohup" : "";
244 open (BUILD
, ">$name/build.sh");
245 print BUILD
<<BUILD_EOF;
247 echo Running the configure script
248 export CFLAGS='-g -O2 -Wall'
249 export CXXFLAGS='-g -O2 -Wall'
250 $maybe_nohup ../$configurepath $options
251 if test $? != 0; then
252 echo Configure failed.
257 if test $? != 0; then
263 chmod 0755, "$name/build.sh";
264 $gotodir = "cd $name";
265 $startcmd = "nice $maybe_nohup ./build.sh";
266 $header = <<HEADER_EOF;
267 ====================================================================
268 Configuration name: $name
269 Directory: $pwd/$name
270 Config Options: $options
271 ====================================================================
275 if ($parallel && !$nohup) {
276 # special case for parallel without nohup. If you're not careful,
277 # all output from all compiles will go into the window at once, which
278 # is impossible to read. Also very hard to kill them until they have
279 # run their course. Instead, start each compile in a different xterm!
280 # What's even more useful is that after the compile stops it goes into
281 # a bash shell so that you can fix things, run the make again, etc.
283 # To do this, put the start command in a little shell script called
284 # xterm-init.sh. Start the xterm with "-e xterm-init.sh" so that it
285 # runs the script as it starts.
287 open (XTI, ">$name/xterm-init.sh");
298 chmod 0755, "$name/xterm-init.sh";
299 $geometry = "-geom +$x+$y";
302 $startcmd = "xterm -title $name -name $name $geometry -e ./xterm-init.sh";
305 $cmd = "$gotodir && $startcmd";
306 $cmd .= "&" if $parallel;
307 print "Executing '$cmd'\n" if $DEBUG;
312 print "batch-build script is done.\n";
315 sub add_configuration
{
316 my ($name, $opts) = @_;
317 push @config_names, $name;
318 push @config_opts, $opts;