Added buildbot scripts.
authorDavid Anderson <danderson@mozilla.com>
Wed Jul 25 23:24:42 2012 -0700 (2012-07-25)
changeset 954d7366431a6c
parent 94 b2862e8a8ae0
child 96 9d341206620f
Added buildbot scripts.
tools/buildbot/bootstrap.pl
tools/buildbot/helpers.pm
tools/buildbot/startbuild.pl
     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 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/buildbot/helpers.pm	Wed Jul 25 23:24:42 2012 -0700
     2.3 @@ -0,0 +1,156 @@
     2.4 +#!/usr/bin/perl
     2.5 +
     2.6 +use strict;
     2.7 +use Cwd;
     2.8 +
     2.9 +package Build;
    2.10 +
    2.11 +our $SVN = "/usr/bin/svn";
    2.12 +our $SVN_USER = 'dvander';
    2.13 +our $SVN_ARGS = '';
    2.14 +
    2.15 +sub HgRevNum
    2.16 +{
    2.17 +	my ($path) = (@_);
    2.18 +	my ($cd, $text, $rev);
    2.19 +
    2.20 +	$cd = Cwd::cwd();
    2.21 +	chdir($path);
    2.22 +	$text = `hg identify -n`;
    2.23 +	chdir($cd);
    2.24 +
    2.25 +	chomp $text;
    2.26 +	if ($text =~ /^(\d+)/)
    2.27 +	{
    2.28 +		return $1;
    2.29 +	}
    2.30 +
    2.31 +	return 0;
    2.32 +}
    2.33 +
    2.34 +sub SvnRevNum
    2.35 +{
    2.36 +	my ($str)=(@_);
    2.37 +			
    2.38 +	my $data = Command('svnversion -c ' . $str);
    2.39 +	if ($data =~ /(\d+):(\d+)/)
    2.40 +	{
    2.41 +		return $2;
    2.42 +	} elsif ($data =~ /(\d+)/) {
    2.43 +		return $1;
    2.44 +	} else {
    2.45 +		return 0;
    2.46 +	}
    2.47 +}
    2.48 +
    2.49 +sub ProductVersion
    2.50 +{
    2.51 +	my ($file) = (@_);
    2.52 +	my ($version);
    2.53 +	open(FILE, $file) or die "Could not open $file: $!\n";
    2.54 +	$version = <FILE>;
    2.55 +	close(FILE);
    2.56 +	chomp $version;
    2.57 +	return $version;
    2.58 +}
    2.59 +
    2.60 +sub Delete
    2.61 +{
    2.62 +	my ($str)=(@_);
    2.63 +	if ($^O =~ /MSWin/)
    2.64 +	{
    2.65 +		Command("del /S /F /Q \"$str\"");
    2.66 +		Command("rmdir /S /Q \"$str\"");
    2.67 +	} else {
    2.68 +		Command("rm -rf $str");
    2.69 +	}
    2.70 +	return !(-e $str);
    2.71 +}
    2.72 +
    2.73 +sub Copy
    2.74 +{
    2.75 +	my ($src,$dest)=(@_);
    2.76 +	if ($^O =~ /MSWin/)
    2.77 +	{
    2.78 +		Command("copy \"$src\" \"$dest\" /y");
    2.79 +	} else {
    2.80 +		Command("cp \"$src\" \"$dest\"");
    2.81 +	}
    2.82 +	return (-e $dest);
    2.83 +}
    2.84 +
    2.85 +sub Move
    2.86 +{
    2.87 +	my ($src,$dest)=(@_);
    2.88 +	if ($^O =~ /MSWin/)
    2.89 +	{
    2.90 +		Command("move \"$src\" \"$dest\"");
    2.91 +	} else {
    2.92 +		Command("mv \"$src\" \"$dest\"");
    2.93 +	}
    2.94 +	return (-e $dest);
    2.95 +}
    2.96 +
    2.97 +sub Command
    2.98 +{
    2.99 +	my($cmd)=(@_);
   2.100 +	print "$cmd\n";
   2.101 +	return `$cmd`;
   2.102 +}
   2.103 +
   2.104 +sub PathFormat
   2.105 +{
   2.106 +	my ($str)=(@_);
   2.107 +	if ($^O =~ /MSWin/)
   2.108 +	{
   2.109 +		$str =~ s#/#\\#g;
   2.110 +	} else {
   2.111 +		$str =~ s#\\#/#g;
   2.112 +	}
   2.113 +	return $str;
   2.114 +}
   2.115 +
   2.116 +sub SVN_Remove
   2.117 +{
   2.118 +	my ($file)=(@_);
   2.119 +	my ($path, $name);
   2.120 +	if ($^O =~ /MSWin/)
   2.121 +	{
   2.122 +		($path, $name) = ($file =~ /(.+)\/([^\/]+)$/);
   2.123 +	} else {
   2.124 +		($path, $name) = ($file =~ /(.+)\\([^\\]+)$/);
   2.125 +	}
   2.126 +	my $dir = Cwd::cwd();
   2.127 +	chdir($path);
   2.128 +	Command($SVN . ' ' . $SVN_ARGS . ' delete ' . $name);
   2.129 +	chdir($dir);
   2.130 +}
   2.131 +
   2.132 +sub SVN_Add
   2.133 +{
   2.134 +	my ($file)=(@_);
   2.135 +	my ($path, $name);
   2.136 +	if ($^O =~ /MSWin/)
   2.137 +	{
   2.138 +		($path, $name) = ($file =~ /(.+)\/([^\/]+)$/);
   2.139 +	} else {
   2.140 +		($path, $name) = ($file =~ /(.+)\\([^\\]+)$/);
   2.141 +	}
   2.142 +	my $dir = Cwd::cwd();
   2.143 +	chdir($path);
   2.144 +	Command($SVN . ' ' . $SVN_ARGS . ' add ' . $name);
   2.145 +	chdir($dir);
   2.146 +}
   2.147 +
   2.148 +sub GetBuildType
   2.149 +{
   2.150 +	my ($file)=(@_);
   2.151 +	my ($type);
   2.152 +	open(TYPE, $file) or die("Could not open file: $!\n");
   2.153 +	$type = <TYPE>;
   2.154 +	close(TYPE);
   2.155 +	chomp $type;
   2.156 +	return $type;
   2.157 +}
   2.158 +
   2.159 +return 1;
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/buildbot/startbuild.pl	Wed Jul 25 23:24:42 2012 -0700
     3.3 @@ -0,0 +1,27 @@
     3.4 +#!/usr/bin/perl
     3.5 +# vim: set ts=2 sw=2 tw=99 noet: 
     3.6 +
     3.7 +use File::Basename;
     3.8 +
     3.9 +my ($myself, $path) = fileparse($0);
    3.10 +chdir($path);
    3.11 +
    3.12 +require 'helpers.pm';
    3.13 +
    3.14 +chdir('../../../OUTPUT');
    3.15 +
    3.16 +if ($^O eq "linux" || $^O eq "darwin") {
    3.17 +	system("python3 build.py 2>&1");
    3.18 +} else {
    3.19 +	system("C:\\Python31\\python.exe build.py 2>&1");
    3.20 +}
    3.21 +
    3.22 +if ($? != 0)
    3.23 +{
    3.24 +	die "Build failed: $!\n";
    3.25 +}
    3.26 +else
    3.27 +{
    3.28 +	exit(0);
    3.29 +}
    3.30 +