summaryrefslogtreecommitdiff
path: root/site_scons
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-03-22 19:06:54 -0400
committerAndrew Morrow <acm@mongodb.com>2015-07-23 19:07:11 -0400
commit92f1bacdb1dbc17919e7a0f77f0d6c5b981933da (patch)
treec3f4a03e330525bcac588072b594fa0552fb528e /site_scons
parent4e2ef9c48e7df15e5e55afcc985f4b501c69e52d (diff)
downloadmongo-92f1bacdb1dbc17919e7a0f77f0d6c5b981933da.tar.gz
SERVER-9564 Expose linking model choice as a build option
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/libdeps.py57
1 files changed, 52 insertions, 5 deletions
diff --git a/site_scons/libdeps.py b/site_scons/libdeps.py
index 971bd0d004b..4c8dbf1b24f 100644
--- a/site_scons/libdeps.py
+++ b/site_scons/libdeps.py
@@ -247,7 +247,48 @@ def libdeps_emitter(target, source, env):
return target, source
-def setup_environment(env):
+def shlibdeps_emitter(target, source, env):
+ """SCons emitter that takes values from the LIBDEPS environment variable and
+ converts them to File node objects, binding correct path information into
+ those File objects.
+
+ Emitters run on a particular "target" node during the initial execution of
+ the SConscript file, rather than during the later build phase. When they
+ run, the "env" environment's working directory information is what you
+ expect it to be -- that is, the working directory is considered to be the
+ one that contains the SConscript file. This allows specification of
+ relative paths to LIBDEPS elements.
+
+ This emitter also adds LIBSUFFIX and LIBPREFIX appropriately.
+
+ NOTE: For purposes of LIBDEPS_DEPENDENTS propagation, only the first member
+ of the "target" list is made a prerequisite of the elements of LIBDEPS_DEPENDENTS.
+ """
+
+ libdep_files = []
+ lib_suffix = env.subst('$SHLIBSUFFIX', target=target, source=source)
+ lib_prefix = env.subst('$SHLIBPREFIX', target=target, source=source)
+ for prereq in env.Flatten([env.get(libdeps_env_var, [])]):
+ full_path = env.subst(str(prereq), target=target, source=source)
+ dir_name = os.path.dirname(full_path)
+ file_name = os.path.basename(full_path)
+ if not file_name.startswith(lib_prefix):
+ file_name = '${SHLIBPREFIX}' + file_name
+ if not file_name.endswith(lib_suffix):
+ file_name += '${SHLIBSUFFIX}'
+ libdep_files.append(env.File(os.path.join(dir_name, file_name)))
+
+ for t in target:
+ # target[0] must be a Node and not a string, or else libdeps will fail to
+ # work properly.
+ __append_direct_libdeps(t, libdep_files)
+
+ for dependent in env.Flatten([env.get('LIBDEPS_DEPENDENTS', [])]):
+ __append_direct_libdeps(env.File(dependent), [target[0]])
+
+ return target, source
+
+def setup_environment(env, emitting_shared=False):
"""Set up the given build environment to do LIBDEPS tracking."""
try:
@@ -269,10 +310,16 @@ def setup_environment(env):
env[libdeps_env_var] = SCons.Util.CLVar()
env[syslibdeps_env_var] = SCons.Util.CLVar()
- env.Append(LIBEMITTER=libdeps_emitter,
- PROGEMITTER=libdeps_emitter,
- SHLIBEMITTER=libdeps_emitter)
- env.Prepend(_LIBFLAGS=' $LINK_LIBGROUP_START $_LIBDEPS $LINK_LIBGROUP_END $_SYSLIBDEPS ')
+ env.Append(LIBEMITTER=libdeps_emitter)
+ if emitting_shared:
+ env.Append(
+ PROGEMITTER=shlibdeps_emitter,
+ SHLIBEMITTER=shlibdeps_emitter)
+ else:
+ env.Append(
+ PROGEMITTER=libdeps_emitter,
+ SHLIBEMITTER=libdeps_emitter)
+ env.Prepend(_LIBFLAGS=' $LINK_WHOLE_ARCHIVE_START $LINK_LIBGROUP_START $_LIBDEPS $LINK_LIBGROUP_END $LINK_WHOLE_ARCHIVE_END $_SYSLIBDEPS ')
for builder_name in ('Program', 'SharedLibrary', 'LoadableModule'):
try:
update_scanner(env['BUILDERS'][builder_name])