Skip to content

Commit

Permalink
Sanity checks for compiler versions
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov committed Jun 14, 2014
1 parent f527290 commit 84b77ad
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
20 changes: 13 additions & 7 deletions BinaryBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys
import urllib2
import logging
import copy
import copy, re

from collections import namedtuple
from functools import wraps, partial
Expand Down Expand Up @@ -60,13 +60,19 @@ def get_platform(pkg=None):
else:
raise PackageError(pkg, message)

def get_gcc_version():
p = subprocess.Popen(["gcc","--version"], stdout=subprocess.PIPE)
out, err = p.communicate()
def get_prog_version(prog):
try:
p = subprocess.Popen([prog,"--version"], stdout=subprocess.PIPE)
out, err = p.communicate()
except:
raise Exception("Could not find: " + prog)
if p.returncode != 0:
raise Exception("Checking GCC version caused errors")
out = out.split('\n')[0]
return float(out[out.find(')')+2:out.rfind('.')])
raise Exception("Checking " + prog + " version caused errors")

m = re.match("^.*?(\d+\.\d+)", out)
if not m:
raise Exception("Could not find " + prog + " version")
return float(m.group(1))

class PackageError(Exception):
def __init__(self, pkg, message):
Expand Down
6 changes: 3 additions & 3 deletions auto_build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ ulimit -v unlimited 2>/dev/null
ulimit -u unlimited 2>/dev/null

# These are needed for centos-32-5 and 64-5
if [ -f /usr/bin/gcc44 ] && [ -f /usr/bin/g++44 ]; then
if [ -f /usr/bin/gcc44 ] && [ -f /usr/bin/g++44 ] && \
[ -f /usr/bin/gfortran44 ]; then
rm -f gcc; ln -s /usr/bin/gcc44 gcc
rm -f g++; ln -s /usr/bin/g++44 g++
rm -f gfortran; ln -s /usr/bin/gfortran44 gfortran
export PATH=$(pwd):$PATH
fi

which gcc; which git; gcc --version; python --version

rm -fv ./BaseSystem*bz2
rm -fv ./StereoPipeline*bz2

Expand Down
14 changes: 13 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from Packages import *

from BinaryBuilder import Package, Environment, PackageError, die, info,\
get_platform, findfile, run, get_gcc_version, logger, warn, \
get_platform, findfile, run, get_prog_version, logger, warn, \
binary_builder_prefix
from BinaryDist import fix_install_paths

Expand Down Expand Up @@ -189,6 +189,8 @@ def write_done(done, done_file):
os.environ["PATH"] = P.join(opt.build_root, 'install/bin') + \
os.pathsep + os.environ["PATH"]

MIN_CC_VERSION = 4.4

# -Wl,-z,now ?
build_env = Environment(
CC = opt.cc,
Expand Down Expand Up @@ -223,6 +225,12 @@ def write_done(done, done_file):
if version.StrictVersion(version_string) < "3.1":
die('Your Clang compiler is older than 3.1. It is our experience that older versions of clang could not compile Vision Workbench and Stereo Pipeline correctly. Please change your compiler choice.')

if arch.os == 'linux':
ver1 = get_prog_version(build_env['CC'])
ver2 = get_prog_version(build_env['CXX'])
if ver1 < MIN_CC_VERSION or ver2 < MIN_CC_VERSION:
die('Expecting gcc and g++ version >= ' + str(MIN_CC_VERSION))

if arch.os == 'linux':
build_env.append('LDFLAGS', '-Wl,-O1 -Wl,--enable-new-dtags -Wl,--hash-style=both')
build_env.append_many(ALL_FLAGS, '-m%i' % arch.bits)
Expand Down Expand Up @@ -268,6 +276,7 @@ def write_done(done, done_file):
if not P.exists(compiler_dir):
os.makedirs(compiler_dir)

# Deal with the Fortran compiler
try:
findfile(build_env['F77'], build_env['PATH'])
except Exception:
Expand All @@ -282,6 +291,9 @@ def write_done(done, done_file):
break
except Exception:
pass
ver = get_prog_version(build_env['F77'])
if ver < MIN_CC_VERSION:
die('Expecting ' + build_env['F77'] + ' version >= ' + str(MIN_CC_VERSION))

print("%s" % build_env['PATH'])

Expand Down

0 comments on commit 84b77ad

Please sign in to comment.