diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2020-06-29 18:44:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-06 04:15:02 +0000 |
commit | fa7f6842d53431ef679a587ba20b62cbe49d871c (patch) | |
tree | bc6b38e189a95c4b5adc0070740c53c7eeb341e0 /site_scons | |
parent | 344d765b59512c4dd5defa135044e3617162a17c (diff) | |
download | mongo-fa7f6842d53431ef679a587ba20b62cbe49d871c.tar.gz |
SERVER-49036 expand response files for generating the compdb from ninja
(cherry picked from commit 5fe923a0aa312044062df044eb4eaa47951f70ec)
Diffstat (limited to 'site_scons')
-rw-r--r-- | site_scons/site_tools/ninja_next.py | 28 |
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 d1d18b92973..3d9c8dd1de5 100644 --- a/site_scons/site_tools/ninja_next.py +++ b/site_scons/site_tools/ninja_next.py @@ -19,6 +19,7 @@ import importlib import io import shutil import shlex +import textwrap from glob import glob from os.path import join as joinpath @@ -748,8 +749,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 '' ) }, ) @@ -1108,6 +1109,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): """ @@ -1231,6 +1253,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") |