• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright 2023 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import os
8import pathlib
9import sys
10
11_REPO_ROOT = pathlib.Path(__file__).resolve().parents[3]
12_ENTRIES_FILE = _REPO_ROOT / '.gclient_entries'
13
14
15def main():
16  parser = argparse.ArgumentParser()
17  parser.add_argument('--source-filter', required=True)
18  parser.add_argument('--output', required=True)
19  args = parser.parse_args()
20
21  source_filter = args.source_filter
22
23  # Ninja validates that the file exists since it's marked as an input.
24  try:
25    text = _ENTRIES_FILE.read_text()
26    result = {}
27    exec(text, result)
28    entries = result['entries']
29    private_dirs = sorted(d for d, s in entries.items()
30                          if s and source_filter in s)
31  except Exception as e:
32    # Make the test fail rather than the compile step so that failures here do
33    # not prevent other bot functionality.
34    private_dirs = [
35        '# ERROR parsing .gclient_entries',
36        str(e), '', 'File was:', text
37    ]
38
39  pathlib.Path(args.output).write_text('\n'.join(private_dirs) + '\n')
40
41
42if __name__ == '__main__':
43  main()
44