summaryrefslogtreecommitdiff
path: root/site_scons/site_tools
diff options
context:
space:
mode:
authorMathew Robinson <mathew@chasinglogic.io>2020-02-27 08:47:46 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-05 18:18:39 +0000
commite41686f5454eb1be76f7dda616ad09c20aff52a2 (patch)
tree4e313b2129c6847e15d72a9dfade057e6a3a3665 /site_scons/site_tools
parent45341f946b829b87ec11567dc2b897af74bc9e07 (diff)
downloadmongo-e41686f5454eb1be76f7dda616ad09c20aff52a2.tar.gz
SERVER-45785 Make PREFIX, PREFIX_*DIR, and DESTDIR work more like regular SCons expansions
Diffstat (limited to 'site_scons/site_tools')
-rw-r--r--site_scons/site_tools/auto_archive.py10
-rw-r--r--site_scons/site_tools/auto_install_binaries.py47
2 files changed, 9 insertions, 48 deletions
diff --git a/site_scons/site_tools/auto_archive.py b/site_scons/site_tools/auto_archive.py
index ff0f5dbee11..cea893baf7c 100644
--- a/site_scons/site_tools/auto_archive.py
+++ b/site_scons/site_tools/auto_archive.py
@@ -166,15 +166,7 @@ def archive_builder(source, target, env, for_signature):
#
# We pass the common_ancestor to tar via -C so that $PREFIX is
# preserved in the tarball.
- dest_dir_elems = env.Dir("$DESTDIR").get_abspath()
- prefix_elems = env.subst("$PREFIX")
-
- # In python slicing a string with [:-0] gives an empty string. So
- # make sure we have a prefix to slice off before trying it.
- if prefix_elems:
- common_ancestor = dest_dir_elems[: -len(prefix_elems)]
- else:
- common_ancestor = dest_dir_elems
+ common_ancestor = env.Dir("$DESTDIR").get_abspath()
archive_type = env["__AUTO_ARCHIVE_TYPE"]
make_archive_script = source[0].get_abspath()
diff --git a/site_scons/site_tools/auto_install_binaries.py b/site_scons/site_tools/auto_install_binaries.py
index fcc67fe4001..1caaf2d285b 100644
--- a/site_scons/site_tools/auto_install_binaries.py
+++ b/site_scons/site_tools/auto_install_binaries.py
@@ -487,44 +487,12 @@ def add_suffix_mapping(env, suffix, role=None):
env[SUFFIX_MAP].update({env.subst(key): value for key, value in suffix.items()})
-def suffix_mapping(env, directory=False, default_role=False):
+def suffix_mapping(env, directory="", default_role=False):
"""Generate a SuffixMap object from source and target."""
+ directory = "$DESTDIR/" + directory
return SuffixMap(directory=directory, default_role=default_role)
-def dest_dir_generator(initial_value=None):
- """Memoized dest_dir_generator"""
- dd = (None, None)
-
- def generator(source, target, env, for_signature):
- nonlocal dd
-
- # SCons does not perform substitution for "sub" Dir calls on a
- # Dir Node. Additionally we need to determine if it's an
- # absolute path here because if it is the sub Dir call will
- # not expand correctly.
- prefix = env.subst("$PREFIX")
- if prefix and prefix[0] == "/":
- prefix = prefix[1:]
-
- if dd[1] is not None and dd[0] == prefix:
- return dd[1]
-
- if initial_value is None:
- dest_dir = env.Dir("#install")
- elif isinstance(initial_value, str):
- dest_dir = env.Dir(initial_value)
- elif isinstance(initial_value, SCons.Node.FS.Dir):
- dest_dir = initial_value
- else:
- raise Exception("initial DESTDIR value must be string or Dir")
-
- dd = (prefix, dest_dir.Dir(prefix))
- return dd[1]
-
- return generator
-
-
def get_auto_installed_files(env, node):
return getattr(node.attributes, INSTALLED_FILES, [])
@@ -573,12 +541,13 @@ def generate(env): # pylint: disable=too-many-statements
# Matches the autoconf documentation:
# https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
- env["DESTDIR"] = dest_dir_generator(env.get("DESTDIR", None))
- env["PREFIX_BINDIR"] = env.get("PREFIX_BINDIR", "$DESTDIR/bin")
- env["PREFIX_LIBDIR"] = env.get("PREFIX_LIBDIR", "$DESTDIR/lib")
- env["PREFIX_SHAREDIR"] = env.get("PREFIX_SHAREDIR", "$DESTDIR/share")
+ env["DESTDIR"] = env.Dir(env.get("DESTDIR", "#install"))
+ env["PREFIX"] = env.get("PREFIX", "")
+ env["PREFIX_BINDIR"] = env.get("PREFIX_BINDIR", "$PREFIX/bin")
+ env["PREFIX_LIBDIR"] = env.get("PREFIX_LIBDIR", "$PREFIX/lib")
+ env["PREFIX_SHAREDIR"] = env.get("PREFIX_SHAREDIR", "$PREFIX/share")
env["PREFIX_DOCDIR"] = env.get("PREFIX_DOCDIR", "$PREFIX_SHAREDIR/doc")
- env["PREFIX_INCLUDEDIR"] = env.get("PREFIX_INCLUDEDIR", "$DESTDIR/include")
+ env["PREFIX_INCLUDEDIR"] = env.get("PREFIX_INCLUDEDIR", "$PREFIX/include")
env[SUFFIX_MAP] = {}
env[ALIAS_MAP] = defaultdict(dict)