Chromium Code Reviews| Index: mojo/dart/tools/presubmit/check_mojom_dart.py |
| diff --git a/mojo/dart/tools/presubmit/check_mojom_dart.py b/mojo/dart/tools/presubmit/check_mojom_dart.py |
| index 8ef547fa5e35891045980d96807fc92e228089bc..97a4481f5a7f49d30180b7219637c324b06314d9 100755 |
| --- a/mojo/dart/tools/presubmit/check_mojom_dart.py |
| +++ b/mojo/dart/tools/presubmit/check_mojom_dart.py |
| @@ -250,6 +250,11 @@ def is_mojom(path): |
| return path.endswith('.mojom') |
| +def is_generator_file(path): |
| + return path.find('mojom_dart_generator.py') != -1 or \ |
| + (path.find('dart_templates') != -1 and path.endswith('.tmpl')) |
| + |
| + |
| def filter_paths(paths, path_filter): |
| result = [] |
| for path in paths: |
| @@ -306,6 +311,7 @@ def bindings_machinery_latest_mtime(affected_files): |
| def presubmit_check(packages, affected_files): |
| mojoms = filter_paths(affected_files, is_mojom) |
| mojom_darts = filter_paths(affected_files, is_mojom_dart) |
| + generator_files = filter_paths(affected_files, is_generator_file) |
| if check_for_bindings_machinery_changes(affected_files): |
|
zra
2015/11/24 17:34:44
Is the new code below still needed after this chec
alexfandrianto
2015/12/18 01:53:19
Not using this anymore.
|
| # Bindings machinery changed, perform global check instead. |
| @@ -351,26 +357,28 @@ def presubmit_check(packages, affected_files): |
| updated_mojom_dart_files.append(mojom_dart_path) |
| # Check for updated .mojom.dart file without updated .mojom file. |
| - for mojom_dart_file in mojom_darts: |
| - # mojom_dart_file is not inside //mojo/dart/packages. |
| - if not mojom_dart_file.startswith(PACKAGES_DIR): |
| - continue |
| - |
| - # Path relative to //mojo/dart/packages/ |
| - path_relative_to_packages = os.path.relpath(mojom_dart_file, |
| - start=PACKAGES_DIR) |
| - # Package name is first element of split path. |
| - package = path_relative_to_packages.split(os.sep)[0] |
| - # Path relative to src. |
| - mojom_dart_path = os.path.relpath(mojom_dart_file, start=SRC_DIR) |
| - # If mojom_dart_path is not in updated_mojom_dart_files, a .mojom.dart |
| - # file was updated without updating the related .mojom file. |
| - if not (mojom_dart_path in updated_mojom_dart_files): |
| - check_failure = True |
| - print("Package %s has new %s without updating source .mojom file." % |
| - (package, mojom_dart_path)) |
| - if not (package in packages_with_failures): |
| - packages_with_failures.append(package) |
| + # If the Python generator or dart template files changed, skip this check. |
|
zra
2015/11/24 17:34:44
Is this case not already covered by the check_for_
alexfandrianto
2015/12/18 01:53:19
Not using this anymore.
|
| + if len(generator_files) == 0: |
| + for mojom_dart_file in mojom_darts: |
| + # mojom_dart_file is not inside //mojo/dart/packages. |
| + if not mojom_dart_file.startswith(PACKAGES_DIR): |
| + continue |
| + |
| + # Path relative to //mojo/dart/packages/ |
| + path_relative_to_packages = os.path.relpath(mojom_dart_file, |
| + start=PACKAGES_DIR) |
| + # Package name is first element of split path. |
| + package = path_relative_to_packages.split(os.sep)[0] |
| + # Path relative to src. |
| + mojom_dart_path = os.path.relpath(mojom_dart_file, start=SRC_DIR) |
| + # If mojom_dart_path is not in updated_mojom_dart_files, a .mojom.dart |
| + # file was updated without updating the related .mojom file. |
| + if not (mojom_dart_path in updated_mojom_dart_files): |
| + check_failure = True |
| + print("Package %s has new %s without updating source .mojom file." % |
| + (package, mojom_dart_path)) |
| + if not (package in packages_with_failures): |
| + packages_with_failures.append(package) |
| for package in packages_with_failures: |
| _print_regenerate_message(package) |