Fix .pydeps PRESUBMIT check not always triggering
The check was never updated to support --gn-paths.
Also adds missing --output arg to error messages when missing.
Bug: 1141255
Change-Id: I1e5fa5b6926247f3f00ae2687c72b894c666e2c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2491521
Reviewed-by: Mohamed Heikal <[email protected]>
Commit-Queue: Andrew Grieve <[email protected]>
Cr-Commit-Position: refs/heads/master@{#819963}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 9f54921..ce0c63a 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -3635,11 +3635,17 @@
def _ComputeNormalizedPydepsEntries(self, pydeps_path):
"""Returns an interable of paths within the .pydep, relativized to //."""
- os_path = self._input_api.os_path
- pydeps_dir = os_path.dirname(pydeps_path)
- entries = (l.rstrip() for l in self._LoadFile(pydeps_path).splitlines()
- if not l.startswith('*'))
- return (os_path.normpath(os_path.join(pydeps_dir, e)) for e in entries)
+ pydeps_data = self._LoadFile(pydeps_path)
+ uses_gn_paths = '--gn-paths' in pydeps_data
+ entries = (l for l in pydeps_data.splitlines() if not l.startswith('#'))
+ if uses_gn_paths:
+ # Paths look like: //foo/bar/baz
+ return (e[2:] for e in entries)
+ else:
+ # Paths look like: path/relative/to/file.pydeps
+ os_path = self._input_api.os_path
+ pydeps_dir = os_path.dirname(pydeps_path)
+ return (os_path.normpath(os_path.join(pydeps_dir, e)) for e in entries)
def _CreateFilesToPydepsMap(self):
"""Returns a map of local_path -> list_of_pydeps."""
@@ -3679,6 +3685,8 @@
old_pydeps_data = self._LoadFile(pydeps_path).splitlines()
if old_pydeps_data:
cmd = old_pydeps_data[1][1:].strip()
+ if '--output' not in cmd:
+ cmd += ' --output ' + pydeps_path
old_contents = old_pydeps_data[2:]
else:
# A default cmd that should work in most cases (as long as pydeps filename