mirror of
https://github.com/boostorg/build.git
synced 2026-02-17 01:32:12 +00:00
Corrected how Boost Build's configuration.py test detects whether the current platform interprets setting an environment variable to an empty string literally or as unsetting that variable.
[SVN r78917]
This commit is contained in:
@@ -237,13 +237,10 @@ def _canSetEmptyEnvironmentVariable():
|
||||
|
||||
"""
|
||||
dummyName = "UGNABUNGA_FOO_BAR_BAZ_FEE_FAE_FOU_FAM"
|
||||
original = os.getenv(dummyName)
|
||||
os.putenv(dummyName, "")
|
||||
result = os.getenv(dummyName) == ""
|
||||
if original is None:
|
||||
os.unsetenv(dummyName)
|
||||
else:
|
||||
os.putenv(dummyName, original)
|
||||
original = os.environ.get(dummyName)
|
||||
_env_set(dummyName, "")
|
||||
result = _getExternalEnv(dummyName) == ""
|
||||
_env_set(dummyName, original)
|
||||
return result
|
||||
|
||||
|
||||
@@ -274,6 +271,45 @@ def _env_set(name, value):
|
||||
os.environ[name] = value
|
||||
|
||||
|
||||
def _getExternalEnv(name):
|
||||
toolsetName = "__myDummyToolset__"
|
||||
|
||||
t = BoostBuild.Tester("toolset=%s" % toolsetName, pass_toolset=False,
|
||||
use_test_config=False)
|
||||
try:
|
||||
# Prepare a dummy toolset so we do not get errors in case the default
|
||||
# one is not found.
|
||||
t.write(toolsetName + ".jam", """\
|
||||
import feature ;
|
||||
feature.extend toolset : %s ;
|
||||
rule init ( ) { }
|
||||
""" % toolsetName)
|
||||
|
||||
# Python version of the same dummy toolset.
|
||||
t.write(toolsetName + ".py", """\
|
||||
from b2.build import feature
|
||||
feature.extend('toolset', ['%s'])
|
||||
def init(): pass
|
||||
""" % toolsetName)
|
||||
|
||||
t.write("jamroot.jam", """\
|
||||
import os ;
|
||||
local names = [ MATCH ^---var-name---=(.*) : [ modules.peek : ARGV ] ] ;
|
||||
for x in $(names)
|
||||
{
|
||||
value = [ os.environ $(x) ] ;
|
||||
ECHO "###" $(x): '$(value)' "###" ;
|
||||
}
|
||||
""")
|
||||
|
||||
t.run_build_system("---var-name---=%s" % name)
|
||||
m = re.search("^### %s: '(.*)' ###$" % name, t.stdout(), re.MULTILINE)
|
||||
if m:
|
||||
return m.group(1)
|
||||
finally:
|
||||
t.cleanup()
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# main()
|
||||
|
||||
Reference in New Issue
Block a user