summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-07-28 15:58:48 -0400
committerColin Walters <walters@verbum.org>2010-07-28 15:58:57 -0400
commitb513e9a8fcc3f910e2aef5c6cfee5755ce4b4f3f (patch)
treefbb888fe858713963b31a8db8b5723a44821dd78
parent6c381c1a8df6f82c72aa27c3548afa2efb175236 (diff)
downloadhomegit-MOVED-TO-GNOME-b513e9a8fcc3f910e2aef5c6cfee5755ce4b4f3f.zip
homegit-MOVED-TO-GNOME-b513e9a8fcc3f910e2aef5c6cfee5755ce4b4f3f.tar.gz
homegit-MOVED-TO-GNOME-b513e9a8fcc3f910e2aef5c6cfee5755ce4b4f3f.tar.xz
Rewrite build in python, have it log by default, fix bugs
Make the prefix matching actually work.
-rwxr-xr-xbin/build83
1 files changed, 48 insertions, 35 deletions
diff --git a/bin/build b/bin/build
index 8bad389..5f1425d 100755
--- a/bin/build
+++ b/bin/build
@@ -1,35 +1,48 @@
-#!/bin/bash
-set -e
-set -x
-root=$INROOT_DIR
-if test -z "$root"; then
- echo "INROOT_DIR not set; run under inroot"
- exit 1
-fi
-if test -d /lib64; then
- libdir=$root/lib64
-else
- libdir=$root/lib
-fi
-configargs="--prefix=$root --libdir=$libdir $@"
-if ! test -x configure; then
- if test -f autogen.sh; then
- inroot $root ./autogen.sh $configargs
- else
- autoreconf -f -i
- inroot $root ./configure $configargs
- fi
-fi
-# We need to rerun configure if the prefix changed
-prefix_matches=yes
-if test -f config.log; then
- previous_prefix=$(grep '^prefix=' config.log | cut -f 2 -d '=')
- if test previous_prefix != $root; then
- prefix_matches=no
- fi
-fi
-if ! test -f Makefile || test x$prefix_matches = xno; then
- inroot $root ./configure $configargs
-fi
-nproc=$(($(grep -c ^processor /proc/cpuinfo) * 2))
-make -j $nproc $MAKEARGS
+#!/usr/bin/python
+
+import os,sys,subprocess
+from multiprocessing import cpu_count
+
+if 'INROOT_DIR' not in os.environ:
+ print "INROOT_DIR not set; run under inroot"
+ sys.exit(1)
+root = os.environ['INROOT_DIR']
+if os.path.isdir('/lib64'):
+ libdir=os.path.join(root, 'lib64')
+else:
+ libdir=os.path.join(root, 'lib')
+configargs=['--prefix=' + root, '--libdir=' + libdir]
+configargs.extend(sys.argv[1:])
+if not os.path.exists('configure'):
+ if os.path.exists('autogen.sh'):
+ args = ['autogen.sh']
+ args.extend(configargs)
+ subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr)
+ else:
+ subprocess.check_call(['autoreconf', '-f', '-i'], stdout=sys.stdout, stderr=sys.stderr)
+ args = ['./configure']
+ args.extend(configargs)
+ subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr)
+prefix_matches=True
+if os.path.exists('config.log'):
+ previous_prefix = None
+ f = open('config.log')
+ for line in f:
+ if line.startswith('prefix=\''):
+ previous_prefix = line[8:-2]
+ break
+ f.close()
+ if previous_prefix != root:
+ print "Reruning configure due to prefix change (%r -> %r)" % (root, previous_prefix)
+ prefix_matches=False
+
+if not os.path.exists('Makefile') or not prefix_matches:
+ args = ['./configure']
+ args.extend(configargs)
+ subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr)
+
+logfile_path = '/tmp/build-%s.log' % (os.path.basename(os.getcwd()),)
+logfile = open(logfile_path, 'w')
+subprocess.Popen(['make', '-j', '%d' % (cpu_count() * 2, )],
+ stdout=logfile, stderr=logfile)
+os.execlp('tail', 'tail', '--lines=2000', '-f', logfile_path)