summaryrefslogtreecommitdiff
path: root/site_scons
diff options
context:
space:
mode:
authorDaniel Moody <daniel.moody@mongodb.com>2020-06-29 18:44:25 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-02 21:19:39 +0000
commit5fe923a0aa312044062df044eb4eaa47951f70ec (patch)
tree5076689dd0fd54da06f006c13b1c4bca91d17395 /site_scons
parent3e71740b94b2ecbb8ed1f4c1b85e5a5ec3536061 (diff)
downloadmongo-5fe923a0aa312044062df044eb4eaa47951f70ec.tar.gz
SERVER-49036 expand response files for generating the compdb from ninja
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/site_tools/ninja_next.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/site_scons/site_tools/ninja_next.py b/site_scons/site_tools/ninja_next.py
index 17d3fcff6a0..cedad091877 100644
--- a/site_scons/site_tools/ninja_next.py
+++ b/site_scons/site_tools/ninja_next.py
@@ -28,6 +28,7 @@ import importlib
import io
import shutil
import shlex
+import textwrap
from glob import glob
from os.path import join as joinpath
@@ -757,8 +758,8 @@ class NinjaState:
pool="console",
implicit=[ninja_file],
variables={
- "cmd": "ninja -f {} -t compdb CC CXX > compile_commands.json".format(
- ninja_file
+ "cmd": "ninja -f {} -t compdb {}CC CXX > compile_commands.json".format(
+ ninja_file, '-x ' if self.env.get('NINJA_COMPDB_EXPAND') else ''
)
},
)
@@ -1117,6 +1118,27 @@ def ninja_contents(original):
return wrapper
+def CheckNinjaCompdbExpand(env, context):
+ """ Configure check testing if ninja's compdb can expand response files"""
+
+ context.Message('Checking if ninja compdb can expand response files... ')
+ ret, output = context.TryAction(
+ action='ninja -f $SOURCE -t compdb -x CMD_RSP > $TARGET',
+ extension='.ninja',
+ text=textwrap.dedent("""
+ rule CMD_RSP
+ command = $cmd @$out.rsp > fake_output.txt
+ description = Building $out
+ rspfile = $out.rsp
+ rspfile_content = $rspc
+ build fake_output.txt: CMD_RSP fake_input.txt
+ cmd = echo
+ pool = console
+ rspc = "test"
+ """))
+ result = '@fake_output.txt.rsp' not in output
+ context.Result(result)
+ return result
def ninja_stat(_self, path):
"""
@@ -1240,6 +1262,8 @@ def generate(env):
else:
env.Append(CCFLAGS=["-MMD", "-MF", "${TARGET}.d"])
+ env.AddMethod(CheckNinjaCompdbExpand, "CheckNinjaCompdbExpand")
+
# Provide a way for custom rule authors to easily access command
# generation.
env.AddMethod(get_shell_command, "NinjaGetShellCommand")