summaryrefslogtreecommitdiff
path: root/site_scons
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2018-03-03 08:08:08 -0500
committerAndrew Morrow <acm@mongodb.com>2018-03-06 09:57:57 -0500
commit5dfa372b25b1a26bb12e09fdb029ff219b0f5343 (patch)
tree2c23324cb72eae116c4a03a72141d0a9716884d8 /site_scons
parent80625c63d47a1d9306958d7ea95154d12c10cade (diff)
downloadmongo-5dfa372b25b1a26bb12e09fdb029ff219b0f5343.tar.gz
SERVER-32117 Minimal hygienic build to support mobile dev
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/site_tools/auto_install_binaries.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/site_scons/site_tools/auto_install_binaries.py b/site_scons/site_tools/auto_install_binaries.py
new file mode 100644
index 00000000000..6416a5214c5
--- /dev/null
+++ b/site_scons/site_tools/auto_install_binaries.py
@@ -0,0 +1,83 @@
+import SCons
+
+def exists(env):
+ return True
+
+def generate(env):
+
+ env.Tool('install')
+
+ suffix_map = {
+ '.dylib' : 'lib',
+ '.so' : 'lib',
+ }
+
+ def tag_install(env, target, source, **kwargs):
+ prefixDir = env.Dir('$INSTALL_DIR')
+
+ actions = []
+ targetDir = prefixDir.Dir(target)
+
+ actions = SCons.Script.Install(
+ target=targetDir,
+ source=source,
+ )
+ for s in map(env.Entry, env.Flatten(source)):
+ setattr(s.attributes, "aib_install_actions", actions)
+
+ tags = kwargs.get('INSTALL_ALIAS', [])
+ if tags:
+ env.Alias(tags, actions)
+
+ return actions
+
+ env.AddMethod(tag_install, 'Install')
+
+ def auto_install_emitter(target, source, env):
+ for t in target:
+ tentry = env.Entry(t)
+ # We want to make sure that the executor information stays
+ # persisted for this node after it is built so that we can
+ # access it in our install emitter below.
+ tentry.attributes.keep_targetinfo = 1
+ tsuf = tentry.get_suffix()
+ auto_install_location = suffix_map.get(tsuf)
+ if auto_install_location:
+ tentry_install_tags = env.get('INSTALL_ALIAS', [])
+ setattr(tentry.attributes, 'INSTALL_ALIAS', tentry_install_tags)
+ install = env.Install(auto_install_location, tentry, INSTALL_ALIAS=tentry_install_tags)
+ return (target, source)
+
+ def add_emitter(builder):
+ base_emitter = builder.emitter
+ new_emitter = SCons.Builder.ListEmitter([base_emitter, auto_install_emitter])
+ builder.emitter = new_emitter
+
+ target_builders = ['Program', 'SharedLibrary', 'LoadableModule', 'StaticLibrary']
+ for builder in target_builders:
+ builder = env['BUILDERS'][builder]
+ add_emitter(builder)
+
+ def scan_for_transitive_install(node, env, path=()):
+ results = []
+ install_sources = node.sources
+ for install_source in install_sources:
+ is_executor = install_source.get_executor()
+ is_targets = is_executor.get_all_targets()
+ for is_target in is_targets:
+ grandchildren = is_target.children()
+ for grandchild in grandchildren:
+ actions = getattr(grandchild.attributes, "aib_install_actions", None)
+ if actions:
+ results.extend(actions)
+ results = sorted(results, key=lambda t: str(t))
+ return results
+
+ from SCons.Tool import install
+ base_install_builder = install.BaseInstallBuilder
+ assert(base_install_builder.target_scanner == None)
+
+ base_install_builder.target_scanner = SCons.Scanner.Scanner(
+ function=scan_for_transitive_install,
+ path_function=None,
+ )