tools/buildbot/bootstrap.pl
author David Anderson <danderson@mozilla.com>
Wed Jul 25 23:28:38 2012 -0700 (2012-07-25)
changeset 97 3fba7cae702c
parent 95 4d7366431a6c
child 98 8fadbee09053
permissions -rwxr-xr-x
Debug instrumentation.
     1 #!/usr/bin/perl
     2 # vim: set ts=2 sw=2 tw=99 noet: 
     3 
     4 use strict;
     5 use Cwd;
     6 use File::Basename;
     7 use File::Path;
     8 
     9 my ($myself, $path) = fileparse($0);
    10 chdir($path);
    11 
    12 require 'helpers.pm';
    13 
    14 #Go back above build dir
    15 chdir(Build::PathFormat('../../..'));
    16 
    17 #Get the source path.
    18 our ($root) = getcwd();
    19 
    20 my $reconf = 0;
    21 
    22 #Create output folder if it doesn't exist.
    23 if (!(-d 'OUTPUT')) {
    24 	$reconf = 1;
    25 } else {
    26 	if (-f 'OUTPUT/sentinel') {
    27 		my @s = stat('OUTPUT/sentinel');
    28 		my $mtime = $s[9];
    29 		my @files = ('build/pushbuild.txt', 'build/AMBuildScript', 'build/product.version');
    30 		my ($i);
    31 		for ($i = 0; $i <= $#files; $i++) {
    32 			if (IsNewer($files[$i], $mtime)) {
    33 				$reconf = 1;
    34 				last;
    35 			}
    36 		}
    37 	} else {
    38 		$reconf = 1;
    39 	}
    40 }
    41 
    42 if ($reconf) {
    43 	rmtree('OUTPUT');
    44 	mkdir('OUTPUT') or die("Failed to create output folder: $!\n");
    45 	chdir('OUTPUT');
    46 
    47 	print "Attempting to reconfigure...\n";
    48 
    49 	my ($os, $bits, $mode);
    50 	$os = $ARGV[0];
    51 	$bits = $ARGV[1];
    52 	$mode = $ARGV[2];
    53 
    54 	my ($prefix, $python);
    55 	if ($^O eq "darwin") {
    56 		$prefix = 'CC="ccache clang" CXX="ccache clang++" ';
    57 		$python = 'python3';
    58 	} elsif ($^O eq "linux") {
    59 		$prefix = 'CC="ccache gcc-4.4" CXX="ccache g++-4.4" ';
    60 		$python = 'python3';
    61 	} elsif ($^O =~ /MSWin/) {
    62 		$prefix = '';
    63 		$python = "C:\\Python31\\Python.exe";
    64 	}
    65 
    66 	my ($cmdstring);
    67 	$cmdstring = $prefix .
    68 							 $python . ' ' .
    69 							 Build::PathFormat('../build/configure.py') . ' ';
    70 
    71 	if ($mode eq 'release') {
    72 		$cmdstring .= '--enable-optimize ';
    73 	} else {
    74 		$cmdstring .= '--enable-debug ';
    75 	}
    76 
    77 	if ($bits eq '32') {
    78 		$cmdstring .= '--arch=x86 ';
    79 	} else {
    80 		$cmdstring .= '--arch-x64 ';
    81 	}
    82 
    83 	my ($result);
    84 	print "-> $cmdstring\n";
    85 	$result = `$cmdstring`;
    86 
    87 	print "$result\n";
    88 	if ($? != 0) {
    89 		die("Could not configure: $!\n");
    90 	}
    91 	open(FILE, '>sentinel');
    92 	print FILE "this is nothing.\n";
    93 	close(FILE);
    94 }
    95 
    96 sub IsNewer
    97 {
    98 	my ($file, $time) = (@_);
    99 
   100 	my @s = stat($file);
   101 	my $mtime = $s[9];
   102 	return $mtime > $time;
   103 }
   104 
   105 exit(0);
   106 
   107