mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
SERVER-49036 expand response files for generating the compdb from ninja
This commit is contained in:
parent
3e71740b94
commit
5fe923a0aa
@ -3902,6 +3902,13 @@ if get_option('ninja') != 'disabled':
|
||||
else:
|
||||
ninja_builder = Tool("ninja_next")
|
||||
ninja_builder.generate(env)
|
||||
|
||||
ninjaConf = Configure(env, help=False, custom_tests = {
|
||||
'CheckNinjaCompdbExpand': env.CheckNinjaCompdbExpand,
|
||||
})
|
||||
env['NINJA_COMPDB_EXPAND'] = ninjaConf.CheckNinjaCompdbExpand()
|
||||
ninjaConf.Finish()
|
||||
|
||||
|
||||
# idlc.py has the ability to print it's implicit dependencies
|
||||
# while generating, Ninja can consume these prints using the
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user