checkdeps.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. # Copyright 2014 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. import json
  6. import os
  7. import sys
  8. # Add src/testing/ into sys.path for importing common without pylint errors.
  9. sys.path.append(
  10. os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
  11. from scripts import common
  12. def main_run(args):
  13. with common.temporary_file() as tempfile_path:
  14. rc = common.run_command([
  15. os.path.join(common.SRC_DIR, 'buildtools', 'checkdeps', 'checkdeps.py'),
  16. '--json', tempfile_path
  17. ])
  18. with open(tempfile_path) as f:
  19. checkdeps_results = json.load(f)
  20. result_set = set()
  21. for result in checkdeps_results:
  22. for violation in result['violations']:
  23. result_set.add((result['dependee_path'], violation['include_path']))
  24. failures = ['%s: %s' % (r[0], r[1]) for r in result_set]
  25. common.record_local_script_results('checkdeps', args.output, failures, True)
  26. return rc
  27. def main_compile_targets(args):
  28. json.dump([], args.output)
  29. if __name__ == '__main__':
  30. funcs = {
  31. 'run': main_run,
  32. 'compile_targets': main_compile_targets,
  33. }
  34. sys.exit(common.run_script(sys.argv[1:], funcs))