Index: PRESUBMIT.py |
diff --git a/PRESUBMIT.py b/PRESUBMIT.py |
index 276db1e83b92d74b715347b5122c207c589bc3aa..a89bf00476e44f5a0efe009ce66a35a05bffe217 100755 |
--- a/PRESUBMIT.py |
+++ b/PRESUBMIT.py |
@@ -9,6 +9,7 @@ |
import json |
import os |
import re |
+import subprocess |
import sys |
@@ -84,6 +85,18 @@ LEGACY_API_DIRS = ( |
API_DIRS = NATIVE_API_DIRS[:] + LEGACY_API_DIRS[:] |
+def _RunCommand(command, cwd): |
+ """Runs a command and returns the output from that command.""" |
+ p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
+ cwd=cwd) |
+ stdout = p.stdout.read() |
+ stderr = p.stderr.read() |
+ p.wait() |
+ p.stdout.close() |
+ p.stderr.close() |
+ return p.returncode, stdout, stderr |
+ |
+ |
def _VerifyNativeApiHeadersListIsValid(input_api, output_api): |
"""Ensures the list of native API header directories is up to date.""" |
non_existing_paths = [] |
@@ -285,6 +298,19 @@ def _CheckNoMixingCAndCCSources(input_api, gn_files, output_api): |
items=violating_gn_files.keys())] |
return [] |
+def _CheckNoPackageBoundaryViolations(input_api, gn_files, output_api): |
+ cwd = input_api.PresubmitLocalPath() |
+ script_path = os.path.join('tools-webrtc', 'check_package_boundaries.py') |
+ webrtc_path = os.path.join('webrtc') |
+ command = ['python', script_path, '--max_messages=1', webrtc_path] |
+ command += [gn_file.LocalPath() for gn_file in gn_files] |
+ returncode, _, stderr = _RunCommand(command, cwd) |
+ if returncode: |
+ return [output_api.PresubmitError( |
+ 'There are package boundary violations in the following GN files:\n\n' |
kjellander_webrtc
2017/01/16 07:26:10
I think since most people are not familiar with wh
ehmaldonado_webrtc
2017/01/16 08:52:50
Acknowledged.
|
+ '%s' % stderr)] |
+ return [] |
+ |
def _CheckGnChanges(input_api, output_api): |
source_file_filter = lambda x: input_api.FilterSourceFile( |
x, white_list=(r'.+\.(gn|gni)$',)) |
@@ -298,6 +324,8 @@ def _CheckGnChanges(input_api, output_api): |
if gn_files: |
result.extend(_CheckNoSourcesAbove(input_api, gn_files, output_api)) |
result.extend(_CheckNoMixingCAndCCSources(input_api, gn_files, output_api)) |
+ result.extend(_CheckNoPackageBoundaryViolations( |
+ input_api, gn_files, output_api)) |
return result |
def _CheckUnwantedDependencies(input_api, output_api): |