mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-10 06:05:49 +00:00
* 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.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
import os
|
|
import shlex
|
|
|
|
from beast.env.ReadEnvFile import read_env_file
|
|
from beast.util.String import is_string
|
|
from beast.util.Terminal import warn
|
|
|
|
_BAD_VARS_ERROR = """
|
|
the following variables appearing in %s were not understood:
|
|
%s"""
|
|
|
|
def add_user_env(env, dotfile, print=print):
|
|
df = os.path.expanduser(dotfile)
|
|
try:
|
|
with open(df, 'r') as f:
|
|
dotvars = read_env_file(f.read())
|
|
except IOError:
|
|
if os.path.exists(df):
|
|
warn("Dotfile %s exists but can't be read." % dotfile, print)
|
|
dotvars = {}
|
|
|
|
bad_names = []
|
|
for name, value in dotvars.items():
|
|
if name in env:
|
|
if is_string(env[name]):
|
|
env[name] = value
|
|
else:
|
|
env[name] = shlex.split(value)
|
|
else:
|
|
bad_names.append(name)
|
|
if bad_names:
|
|
error = _BAD_VARS_ERROR % (dotfile, '\n '.join(bad_names))
|
|
warn(error, print)
|
|
|
|
for name, default in env.items():
|
|
env[name] = os.environ.get(name, default)
|