mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Improvements to scons build for beast.
* Common code extracted to Python directories. * Read ~/.scons file for scons environment defaults. * Override scons settings with shell environment variables. * New "tags" for debug, nodebug, optimize, nooptimize builds. * Universal platform detection. * Default value of environment variables set through prefix dictionaries. * Check for correct Boost value and fail otherwise. * Extract git describe --tags into a preprocesor variable, -DTIP_BRANCH * More colors - blue for unchanged defaults, green for changed defaults, red for error. * Contain unit tests for non-obvious stuff. * Check to see that boost libraries have been built. * Right now, we accept both .dylib and .a versions but it'd be easy to enforce .a only.
This commit is contained in:
committed by
Vinnie Falco
parent
4a3176e3a0
commit
6b0cec1189
61
python/beast/util/Boost.py
Normal file
61
python/beast/util/Boost.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
ROOT_ENV_VARIABLE = 'BOOST_ROOT'
|
||||
MINIMUM_VERSION = 1, 55, 0
|
||||
VERSION_FILE = 'boost', 'version.hpp'
|
||||
LIBRARY_PATH_SEGMENT = 'stage', 'lib'
|
||||
VERSION_MATCHER = re.compile(r'#define\s+BOOST_VERSION\s+(\d+)')
|
||||
|
||||
CANT_OPEN_VERSION_FILE_ERROR = """Unable to open boost version file %s.
|
||||
You have set the environment variable BOOST_ROOT to be %s.
|
||||
Please check to make sure that this points to a valid installation of boost."""
|
||||
|
||||
CANT_UNDERSTAND_VERSION_ERROR = (
|
||||
"Didn't understand version string '%s' from file %s'")
|
||||
VERSION_TOO_OLD_ERROR = ('Your version of boost, %s, is older than the minimum '
|
||||
'required, %s.')
|
||||
|
||||
def _text(major, minor, release):
|
||||
return '%d.%02d.%02d' % (major, minor, release)
|
||||
|
||||
def _raw_boost_path():
|
||||
try:
|
||||
path = os.environ[ROOT_ENV_VARIABLE]
|
||||
if path:
|
||||
return os.path.normpath(path)
|
||||
except KeyError:
|
||||
pass
|
||||
raise KeyError('%s environment variable is not set.' % ROOT_ENV_VARIABLE)
|
||||
|
||||
def _get_version_number(path):
|
||||
version_file = os.path.join(path, *VERSION_FILE)
|
||||
try:
|
||||
with open(version_file) as f:
|
||||
for line in f:
|
||||
match = VERSION_MATCHER.match(line)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
try:
|
||||
return int(version)
|
||||
except ValueError:
|
||||
raise Exception(CANT_UNDERSTAND_VERSION_ERROR %
|
||||
(version, version_file))
|
||||
except IOError:
|
||||
raise Exception(CANT_OPEN_VERSION_FILE_ERROR % (version_file, path))
|
||||
|
||||
def _validate_version(v):
|
||||
version = v // 100000, (v // 100) % 100, v % 100
|
||||
if version < MINIMUM_VERSION:
|
||||
raise Exception(VERSION_TOO_OLD_ERROR % (
|
||||
_text(*version), _text(*MINIMUM_VERSION)))
|
||||
|
||||
def _boost_path():
|
||||
path = _raw_boost_path()
|
||||
_validate_version(_get_version_number(path))
|
||||
return path
|
||||
|
||||
CPPPATH = _boost_path()
|
||||
LIBPATH = os.path.join(CPPPATH, *LIBRARY_PATH_SEGMENT)
|
||||
Reference in New Issue
Block a user