Commit b58fea0e authored by Owen Rodley's avatar Owen Rodley Committed by Commit Bot

Allow additional targets to be passed to generate_compdb.py

This is required if this is to replace the codesearch
generate_compilation_database method, as mentioned in
https://crrev.com/c/1114413.

Bug: 396230
Change-Id: I61122bae15bed27463e5b770623fdf8106836aac
Reviewed-on: https://chromium-review.googlesource.com/1124077
Commit-Queue: Owen Rodley <orodley@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572413}
parent 6a0cf168
...@@ -84,11 +84,12 @@ def GetNinjaPath(): ...@@ -84,11 +84,12 @@ def GetNinjaPath():
# FIXME: This really should be a build target, rather than generated at runtime. # FIXME: This really should be a build target, rather than generated at runtime.
def GenerateWithNinja(path): def GenerateWithNinja(path, targets=[]):
"""Generates a compile database using ninja. """Generates a compile database using ninja.
Args: Args:
path: The build directory to generate a compile database for. path: The build directory to generate a compile database for.
targets: Additional targets to pass to ninja.
Returns: Returns:
List of the contents of the compile database. List of the contents of the compile database.
...@@ -96,9 +97,9 @@ def GenerateWithNinja(path): ...@@ -96,9 +97,9 @@ def GenerateWithNinja(path):
# TODO(dcheng): Ensure that clang is enabled somehow. # TODO(dcheng): Ensure that clang is enabled somehow.
# First, generate the compile database. # First, generate the compile database.
json_compile_db = subprocess.check_output([ json_compile_db = subprocess.check_output(
GetNinjaPath(), '-C', path, '-t', 'compdb', 'cc', 'cxx', 'objc', [GetNinjaPath(), '-C', path] + targets +
'objcxx']) ['-t', 'compdb', 'cc', 'cxx', 'objc', 'objcxx'])
return json.loads(json_compile_db) return json.loads(json_compile_db)
......
...@@ -28,11 +28,15 @@ def main(argv): ...@@ -28,11 +28,15 @@ def main(argv):
'-p', '-p',
required=True, required=True,
help='Path to build directory') help='Path to build directory')
parser.add_argument(
'targets',
nargs='*',
help='Additional targets to pass to ninja')
args = parser.parse_args() args = parser.parse_args()
print json.dumps( print json.dumps(
compile_db.ProcessCompileDatabaseIfNeeded( compile_db.ProcessCompileDatabaseIfNeeded(
compile_db.GenerateWithNinja(args.p))) compile_db.GenerateWithNinja(args.p, args.targets))
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment