Enable presubmit check for copyrighted material in added / modified code
This check is already for a long time performed on some of the main
waterfall bots, including "Android Builder (dbg)",
"Android Clang Builder (dbg)", "Android Arm64 Builder (dbg)", and
also on trybots. The step is called "check licenses".
However, it's better to detect issues even earlier, so we did make sure
that the check can run on Windows, and would like to start running it
during presubmit.
Note that the presubmit check is simpler than the bot check, as it only
scans the files for "copyright-like" strings, while the bot check also
verifies that third-party projects contain Android-compatible licenses.
BUG=343104
Review URL: https://codereview.chromium.org/788163002
Cr-Commit-Position: refs/heads/master@{#307908}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 9e26beb..c875e48 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1262,6 +1262,26 @@
input_api, output_api, 'tools/android/checkstyle/chromium-style-5.0.xml')
+def _CheckForCopyrightedCode(input_api, output_api):
+ """Verifies that newly added code doesn't contain copyrighted material
+ and is properly licensed under the standard Chromium license.
+
+ As there can be false positives, we maintain a whitelist file. This check
+ also verifies that the whitelist file is up to date.
+ """
+ import sys
+ original_sys_path = sys.path
+ try:
+ sys.path = sys.path + [input_api.os_path.join(
+ input_api.PresubmitLocalPath(), 'android_webview', 'tools')]
+ import copyright_scanner
+ finally:
+ # Restore sys.path to what it was before.
+ sys.path = original_sys_path
+
+ return copyright_scanner.ScanAtPresubmit(input_api, output_api)
+
+
_DEPRECATED_CSS = [
# Values
( "-webkit-box", "flex" ),
@@ -1377,6 +1397,7 @@
results.extend(_CheckNoDeprecatedJS(input_api, output_api))
results.extend(_CheckParseErrors(input_api, output_api))
results.extend(_CheckForIPCRules(input_api, output_api))
+ results.extend(_CheckForCopyrightedCode(input_api, output_api))
if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(