1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tools/buildbot/bootstrap.pl Wed Jul 25 23:24:42 2012 -0700
1.3 @@ -0,0 +1,106 @@
1.4 +#!/usr/bin/perl
1.5 +# vim: set ts=2 sw=2 tw=99 noet:
1.6 +
1.7 +use strict;
1.8 +use Cwd;
1.9 +use File::Basename;
1.10 +use File::Path;
1.11 +
1.12 +my ($myself, $path) = fileparse($0);
1.13 +chdir($path);
1.14 +
1.15 +require 'helpers.pm';
1.16 +
1.17 +#Go back above build dir
1.18 +chdir(Build::PathFormat('../../..'));
1.19 +
1.20 +#Get the source path.
1.21 +our ($root) = getcwd();
1.22 +
1.23 +my $reconf = 0;
1.24 +
1.25 +#Create output folder if it doesn't exist.
1.26 +if (!(-d 'OUTPUT')) {
1.27 + $reconf = 1;
1.28 +} else {
1.29 + if (-f 'OUTPUT/sentinel') {
1.30 + my @s = stat('OUTPUT/sentinel');
1.31 + my $mtime = $s[9];
1.32 + my @files = ('build/pushbuild.txt', 'build/AMBuildScript', 'build/product.version');
1.33 + my ($i);
1.34 + for ($i = 0; $i <= $#files; $i++) {
1.35 + if (IsNewer($files[$i], $mtime)) {
1.36 + $reconf = 1;
1.37 + last;
1.38 + }
1.39 + }
1.40 + } else {
1.41 + $reconf = 1;
1.42 + }
1.43 +}
1.44 +
1.45 +if ($reconf) {
1.46 + rmtree('OUTPUT');
1.47 + mkdir('OUTPUT') or die("Failed to create output folder: $!\n");
1.48 + chdir('OUTPUT');
1.49 +
1.50 + print "Attempting to reconfigure...\n";
1.51 +
1.52 + my ($os, $bits, $mode);
1.53 + $os = $ARGV[0];
1.54 + $bits = $ARGV[1];
1.55 + $mode = $ARGV[2];
1.56 +
1.57 + my ($prefix, $python);
1.58 + if ($^O eq "darwin") {
1.59 + $prefix = 'CC="ccache clang" CXX="ccache clang++" ';
1.60 + $python = 'python3';
1.61 + } elsif ($^O eq "linux") {
1.62 + $prefix = 'CC="ccache gcc-4.4" CXX="ccache g++-4.4" ';
1.63 + $python = 'python3';
1.64 + } elsif ($^O =~ /MSWin/) {
1.65 + $prefix = '';
1.66 + $python = "C:\\Python31\\Python.exe";
1.67 + }
1.68 +
1.69 + my ($cmdstring);
1.70 + $cmdstring = $prefix .
1.71 + $python . ' ' .
1.72 + Build::PathFormat('../build/configure.py') . ' ';
1.73 +
1.74 + if ($mode eq 'release') {
1.75 + $cmdstring .= '--enable-optimize ';
1.76 + } else {
1.77 + $cmdstring .= '--enable-debug ';
1.78 + }
1.79 +
1.80 + if ($bits eq '32') {
1.81 + $cmdstring .= '--arch=x86 ';
1.82 + } else {
1.83 + $cmdstring .= '--arch-x64 ';
1.84 + }
1.85 +
1.86 + my ($result);
1.87 + $result = `$cmdstring`;
1.88 +
1.89 + print "$result\n";
1.90 + if ($? != 0) {
1.91 + die("Could not configure: $!\n");
1.92 + }
1.93 + open(FILE, '>sentinel');
1.94 + print FILE "this is nothing.\n";
1.95 + close(FILE);
1.96 +}
1.97 +
1.98 +sub IsNewer
1.99 +{
1.100 + my ($file, $time) = (@_);
1.101 +
1.102 + my @s = stat($file);
1.103 + my $mtime = $s[9];
1.104 + return $mtime > $time;
1.105 +}
1.106 +
1.107 +exit(0);
1.108 +
1.109 +