PRESUBMIT.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. """Presubmit script for mojo
  5. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
  6. for more details about the presubmit API built into depot_tools.
  7. """
  8. import os.path
  9. USE_PYTHON3 = True
  10. PRESUBMIT_VERSION = '2.0.0'
  11. def CheckChange(input_api, output_api):
  12. # Additional python module paths (we're in src/mojo/); not everyone needs
  13. # them, but it's easiest to add them to everyone's path.
  14. # For ply and jinja2:
  15. third_party_path = os.path.join(
  16. input_api.PresubmitLocalPath(), "..", "third_party")
  17. # For the bindings generator:
  18. mojo_public_bindings_pylib_path = os.path.join(
  19. input_api.PresubmitLocalPath(), "public", "tools", "bindings", "pylib")
  20. # For the python bindings:
  21. mojo_python_bindings_path = os.path.join(
  22. input_api.PresubmitLocalPath(), "public", "python")
  23. # TODO(vtl): Don't lint these files until the (many) problems are fixed
  24. # (possibly by deleting/rewriting some files).
  25. files_to_skip = input_api.DEFAULT_FILES_TO_SKIP + \
  26. (r".*\bpublic[\\\/]tools[\\\/]bindings[\\\/]pylib[\\\/]mojom[\\\/]"
  27. r"generate[\\\/].+\.py$",
  28. r".*\bpublic[\\\/]tools[\\\/]bindings[\\\/]checks[\\\/].+\.py$",
  29. r".*\bpublic[\\\/]tools[\\\/]bindings[\\\/]generators[\\\/].+\.py$",
  30. r".*\bspy[\\\/]ui[\\\/].+\.py$",
  31. r".*\btools[\\\/]pylib[\\\/]transitive_hash\.py$",
  32. r".*\btools[\\\/]test_runner\.py$")
  33. results = []
  34. pylint_extra_paths = [
  35. third_party_path,
  36. mojo_public_bindings_pylib_path,
  37. mojo_python_bindings_path,
  38. ]
  39. results += input_api.canned_checks.RunPylint(
  40. input_api, output_api, extra_paths_list=pylint_extra_paths,
  41. files_to_skip=files_to_skip)
  42. return results