tools/buildbot/bootstrap.pl
author David Anderson <dvander@alliedmods.net>
Thu Aug 08 22:02:42 2013 -0700 (2013-08-08)
changeset 3980 dc7dfcd855dc
parent 3597 3f9fc48ad7e2
child 4083 a3d80595a075
permissions -rwxr-xr-x
More Windows build fix.
     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 	my ($result, $argn);
    47 	$argn = $#ARGV + 1;
    48 	print "Attempting to reconfigure...\n";
    49 	if ($argn > 0 && $^O !~ /MSWin/) {
    50 		$result = `CC=$ARGV[0] CXX=$ARGV[0] python3 ../build/configure.py --enable-optimize`;
    51 	} else {
    52 		if ($^O eq "linux") {
    53 			$result = `CC=gcc-4.4 CXX=gcc-4.4 python3 ../build/configure.py --enable-optimize`;
    54 		} elsif ($^O eq "darwin") {
    55 			$result = `CC=clang CXX=clang python3 ../build/configure.py --enable-optimize`;
    56 		} else {
    57 			$result = `C:\\Python32\\Python.exe ..\\build\\configure.py --enable-optimize`;
    58 		}
    59 	}
    60 	print "$result\n";
    61 	if ($? != 0) {
    62 		die("Could not configure: $!\n");
    63 	}
    64 	open(FILE, '>sentinel');
    65 	print FILE "this is nothing.\n";
    66 	close(FILE);
    67 }
    68 
    69 sub IsNewer
    70 {
    71 	my ($file, $time) = (@_);
    72 
    73 	my @s = stat($file);
    74 	my $mtime = $s[9];
    75 	return $mtime > $time;
    76 }
    77 
    78 exit(0);
    79 
    80