Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: PRESUBMIT.py

Issue 805083007: Run gn check for an android build on presubmit (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | examples/device_name/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index eac0a44a153012e122848d394137df8d02fda7c4..7a3cdc0ab158209f31e692c2c8a669c6af17e5bb 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -414,6 +414,7 @@ def _CheckValidHostsInDEPS(input_api, output_api):
def _CheckGNCheck(input_api, output_api):
"""Checks that gn gen and gn check pass"""
+ import os.path
class _TemporaryDirectory(object):
"""Context manager for tempfile.mkdtemp()"""
@@ -427,32 +428,44 @@ def _CheckGNCheck(input_api, output_api):
import shutil
shutil.rmtree(self.path)
- with _TemporaryDirectory() as out_dir:
- try:
- input_api.subprocess.check_output(['gn', 'gen', out_dir])
- except input_api.subprocess.CalledProcessError, error:
- return [output_api.PresubmitError(
- 'gn gen must not fail.', long_text=error.output)]
-
- # TODO(eseidel): Currently only these are known to pass,
- # once everything passes we can just call 'gn check' once without a filter!
- KNOWN_PASSING = [
- '//examples/*',
- '//mojo/*',
- '//services/*',
- '//shell/*',
- ]
- if input_api.platform != 'win32':
- KNOWN_PASSING += [
- '//sky/*',
- ]
- for target_filter in KNOWN_PASSING:
+ available_os = [None]
+ # android tools directory is used as a sentinel to check if the current
+ # checkout is an android checkout.
+ android_tools_dir = os.path.join(input_api.change.RepositoryRoot(),
+ 'third_party', 'android_tools')
+ if os.path.isdir(android_tools_dir):
+ available_os.append('android')
+ for target_os in available_os:
+ with _TemporaryDirectory() as out_dir:
try:
- input_api.subprocess.check_output(['gn', 'check', out_dir,
- target_filter])
+ command = ['gn', 'gen', out_dir]
+ if target_os:
+ command.append('--args=%s' % r'''os="android"''')
+ input_api.subprocess.check_output(command)
except input_api.subprocess.CalledProcessError, error:
- error_title = 'gn check %s must not fail.' % target_filter
- return [output_api.PresubmitError(error_title, long_text=error.output)]
+ return [output_api.PresubmitError(
+ 'gn gen must not fail.', long_text=error.output)]
+
+ # TODO(eseidel): Currently only these are known to pass, once everything
+ # passes we can just call 'gn check' once without a filter!
+ KNOWN_PASSING = [
+ '//examples/*',
+ '//mojo/*',
+ '//services/*',
+ '//shell/*',
+ ]
+ if input_api.platform != 'win32':
+ KNOWN_PASSING += [
+ '//sky/*',
+ ]
+ for target_filter in KNOWN_PASSING:
+ try:
+ input_api.subprocess.check_output(['gn', 'check', out_dir,
+ target_filter])
+ except input_api.subprocess.CalledProcessError, error:
+ error_title = 'gn check %s must not fail.' % target_filter
+ return [output_api.PresubmitError(error_title,
+ long_text=error.output)]
return []
« no previous file with comments | « no previous file | examples/device_name/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698