summaryrefslogtreecommitdiff
path: root/site_scons
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2017-06-15 13:50:28 -0400
committerGabriel Russell <gabriel.russell@mongodb.com>2017-06-23 12:45:55 -0400
commit0019d153b92ddb6a588f12d70007ddae0b7b653c (patch)
tree3cc21e586bc4e061d0fa18411ad050f002a80678 /site_scons
parent763891dbeee9c3a3080410e916a4f1f081751d5f (diff)
downloadmongo-0019d153b92ddb6a588f12d70007ddae0b7b653c.tar.gz
SERVER-29338 Switch to use Value node instead of Node class in compiledb tool
Also use .write() and .read() methods on same to store entry information Signed-off-by: Gabriel Russell <gabriel.russell@mongodb.com>
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/site_tools/compilation_db.py45
1 files changed, 39 insertions, 6 deletions
diff --git a/site_scons/site_tools/compilation_db.py b/site_scons/site_tools/compilation_db.py
index c452736fb00..161ac6061ea 100644
--- a/site_scons/site_tools/compilation_db.py
+++ b/site_scons/site_tools/compilation_db.py
@@ -42,19 +42,39 @@ if SCons.Util.case_sensitive_suffixes('.c', '.C'):
# We make no effort to avoid rebuilding the entries. Someday, perhaps we could and even
# integrate with the cache, but there doesn't seem to be much call for it.
-class __CompilationDbNode(SCons.Node.Node):
- def __init__(self):
- SCons.Node.Node.__init__(self)
+class __CompilationDbNode(SCons.Node.Python.Value):
+ def __init__(self, value):
+ SCons.Node.Python.Value.__init__(self, value)
self.Decider(changed_since_last_build_node)
+
def changed_since_last_build_node(node, target, prev_ni):
+ """ Dummy decider to force alwasy building"""
return True
+
def makeEmitCompilationDbEntry(comstr):
+ """
+ Effectively this creates a lambda function to capture:
+ * command line
+ * source
+ * target
+ :param comstr: unevaluated command line
+ :return: an emitter which has captured the above
+ """
user_action = SCons.Action.Action(comstr)
+
def EmitCompilationDbEntry(target, source, env):
+ """
+ This emitter will be added to each c/c++ object build to capture the info needed
+ for clang tools
+ :param target: target node(s)
+ :param source: source node(s)
+ :param env: Environment for use building this node
+ :return: target(s), source(s)
+ """
- dbtarget = __CompilationDbNode()
+ dbtarget = __CompilationDbNode(source)
entry = env.__COMPILATIONDB_Entry(
target=dbtarget,
@@ -76,7 +96,18 @@ def makeEmitCompilationDbEntry(comstr):
return EmitCompilationDbEntry
+
def CompilationDbEntryAction(target, source, env, **kw):
+ """
+ Create a dictionary with evaluated command line, target, source
+ and store that info as an attribute on the target
+ (Which has been stored in __COMPILATION_DB_ENTRIES array
+ :param target: target node(s)
+ :param source: source node(s)
+ :param env: Environment for use building this node
+ :param kw:
+ :return: None
+ """
command = env['__COMPILATIONDB_UACTION'].strfunction(
target=env['__COMPILATIONDB_UTARGET'],
@@ -89,13 +120,14 @@ def CompilationDbEntryAction(target, source, env, **kw):
"file": str(env['__COMPILATIONDB_USOURCE'][0])
}
- setattr(target[0], '__COMPILATION_DB_ENTRY', entry)
+ target[0].write(entry)
+
def WriteCompilationDb(target, source, env):
entries = []
for s in __COMPILATION_DB_ENTRIES:
- entries.append(getattr(s, '__COMPILATION_DB_ENTRY'))
+ entries.append(s.read())
with open(str(target[0]), 'w') as target_file:
json.dump(entries, target_file,
@@ -103,6 +135,7 @@ def WriteCompilationDb(target, source, env):
indent=4,
separators=(',', ': '))
+
def ScanCompilationDb(node, env, path):
return __COMPILATION_DB_ENTRIES