2 #####################################################################
3 # $Id: batch-build.perl,v 1.11 2007/09/20 17:33:31 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
('g2h-tlb',
136 '--enable-guest2host-tlb');
137 add_configuration
('repeat',
138 '--enable-repeat-speedups');
139 add_configuration
('globalpg',
140 '--enable-global-pages');
141 add_configuration
('icache',
143 add_configuration
('cpuall',
144 '--enable-large-pages --enable-pae --enable-global-pages --enable-all-optimizations');
149 add_configuration
('smp',
151 add_configuration
('smp-d',
152 '--enable-smp --enable-debugger');
153 add_configuration
('smp-wx',
154 '--enable-smp --with-wx');
155 add_configuration
('smp-wx-d',
156 '--enable-smp --with-wx --enable-debugger');
161 add_configuration
('64bit',
163 add_configuration
('64bit-d',
164 '--enable-x86-64 --enable-debugger');
165 add_configuration
('64bit-wx',
166 '--enable-x86-64 --with-wx');
167 add_configuration
('64bit-wx-d',
168 '--enable-x86-64 --with-wx --enable-debugger');
172 # test SSE configurations
173 add_configuration
('sse1',
175 add_configuration
('sse2',
177 add_configuration
('sse2-dbg',
178 '--enable-sse=2 --enable-debugger');
179 add_configuration
('sse2-x86-64-wx-d',
180 '--enable-sse=2 --enable-x86-64 --with-wx --enable-debugger');
186 foreach my $arg (@ARGV) {
187 if ($arg eq '--clean') {
189 } elsif ($arg eq '--nohup') {
191 } elsif ($arg eq '--parallel') {
198 # this script may be run from various directories, and this affects
199 # the path to the configure command. Try to figure out where the configure
200 # command is found, and set up the build.sh scripts accordingly. If it
201 # can't be found, spit out an error now instead of later.
202 my @configurepath_tries = ("configure", "../configure", "../../configure");
204 foreach my $trypath (@configurepath_tries) {
206 print "Found configure at $configurepath.\n" if $DEBUG;
207 $configurepath = $trypath;
210 if (!defined $configurepath) {
212 ERROR I could not locate the configure script. This script is intended
213 to be run from the bochs main directory or a subdirectory of it. Examples:
214 1) cd $BOCHS; ./build/batch-build.perl
215 2) cd $BOCHS/build; ./batch-build.perl
217 Here are the places that I tried to find the configure script:
219 foreach (@configurepath_tries) {
229 for (my $i=0; $i <= $#config_names; $i++) {
230 my $name = "build-$config_names[$i]";
231 my $options = $config_opts[$i];
232 die if (!defined $name || !defined $options);
233 print "Compiling '$name' with opts '$options'\n" if $DEBUG;
235 my $rmcmd = "rm -rf $name";
236 print "Removing directory $name\n";
240 if (! -d
$name) { mkdir $name, 0755; }
241 $maybe_nohup = $nohup?
"nohup" : "";
242 open (BUILD
, ">$name/build.sh");
243 print BUILD
<<BUILD_EOF;
245 echo Running the configure script
246 export CFLAGS='-g -O2 -Wall'
247 export CXXFLAGS='-g -O2 -Wall'
248 $maybe_nohup ../$configurepath $options
249 if test $? != 0; then
250 echo Configure failed.
255 if test $? != 0; then
261 chmod 0755, "$name/build.sh";
262 $gotodir = "cd $name";
263 $startcmd = "nice $maybe_nohup ./build.sh";
264 $header = <<HEADER_EOF;
265 ====================================================================
266 Configuration name: $name
267 Directory: $pwd/$name
268 Config Options: $options
269 ====================================================================
273 if ($parallel && !$nohup) {
274 # special case for parallel without nohup. If you're not careful,
275 # all output from all compiles will go into the window at once, which
276 # is impossible to read. Also very hard to kill them until they have
277 # run their course. Instead, start each compile in a different xterm!
278 # What's even more useful is that after the compile stops it goes into
279 # a bash shell so that you can fix things, run the make again, etc.
281 # To do this, put the start command in a little shell script called
282 # xterm-init.sh. Start the xterm with "-e xterm-init.sh" so that it
283 # runs the script as it starts.
285 open (XTI, ">$name/xterm-init.sh");
296 chmod 0755, "$name/xterm-init.sh";
297 $geometry = "-geom +$x+$y";
300 $startcmd = "xterm -title $name -name $name $geometry -e ./xterm-init.sh";
303 $cmd = "$gotodir && $startcmd";
304 $cmd .= "&" if $parallel;
305 print "Executing '$cmd'\n" if $DEBUG;
310 print "batch-build script is done.\n";
313 sub add_configuration
{
314 my ($name, $opts) = @_;
315 push @config_names, $name;
316 push @config_opts, $opts;