| 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 088587534124bba8aa7a038a20cde91e627bd364..6d0fc3e407df40c80b2a527df4aea7526bde8282 100755
|
| --- a/mojo/dart/tools/presubmit/check_mojom_dart.py
|
| +++ b/mojo/dart/tools/presubmit/check_mojom_dart.py
|
| @@ -238,6 +238,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:
|
| @@ -272,6 +277,7 @@ def check_for_bindings_machinery_changes(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) and
|
| (len(mojom_darts) == 0)):
|
| @@ -282,7 +288,6 @@ def presubmit_check(packages, affected_files):
|
| _print_regenerate_message(package)
|
| return True
|
|
|
| -
|
| updated_mojom_dart_files = []
|
| packages_with_failures = []
|
| check_failure = False
|
| @@ -322,26 +327,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.
|
| + 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)
|
|
|