Index: build/android/gyp/lint.py |
diff --git a/build/android/gyp/lint.py b/build/android/gyp/lint.py |
index 6f74d66d2b48c2fb445397b7aeb6c65f7a60e71b..3f976379a4d35f89d6aa361a871998318045760d 100755 |
--- a/build/android/gyp/lint.py |
+++ b/build/android/gyp/lint.py |
@@ -9,6 +9,7 @@ |
import argparse |
import os |
+import re |
import sys |
import traceback |
from xml.dom import minidom |
@@ -22,9 +23,8 @@ _SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), |
def _OnStaleMd5(changes, lint_path, config_path, processed_config_path, |
manifest_path, result_path, product_dir, sources, jar_path, |
- cache_dir, resource_dir=None, classpath=None, |
+ cache_dir, sdk_version, resource_dir=None, classpath=None, |
can_fail_build=False, silent=False): |
- |
def _RelativizePath(path): |
"""Returns relative path to top-level src dir. |
@@ -129,14 +129,20 @@ def _OnStaleMd5(changes, lint_path, config_path, processed_config_path, |
cmd.extend(['--sources', _RelativizePath(src_dir)]) |
os.symlink(os.path.abspath(src), PathInDir(src_dir, src)) |
+ project_dir = NewSourceDir() |
+ # Create dummy project.properies file in a temporary "project" directory. |
+ # It is the only way to add Android SDK to the Lint's classpath. Proper |
+ # classpath is necessary for most source-level checks. |
+ with open(os.path.join(project_dir, 'project.properties'), 'w') as propfile: |
+ print >> propfile, 'target=android-{}'.format(sdk_version) |
+ |
# Put the manifest in a temporary directory in order to avoid lint detecting |
# sibling res/ and src/ directories (which should be pass explicitly if they |
# are to be included). |
if manifest_path: |
- src_dir = NewSourceDir() |
os.symlink(os.path.abspath(manifest_path), |
- PathInDir(src_dir, manifest_path)) |
- cmd.append(src_dir) |
+ PathInDir(project_dir, manifest_path)) |
+ cmd.append(project_dir) |
if os.path.exists(result_path): |
os.remove(result_path) |
@@ -144,10 +150,13 @@ def _OnStaleMd5(changes, lint_path, config_path, processed_config_path, |
env = {} |
stderr_filter = None |
if cache_dir: |
+ env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir) |
# When _JAVA_OPTIONS is set, java prints to stderr: |
# Picked up _JAVA_OPTIONS: ... |
- env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir) |
- stderr_filter = lambda l: '' if '_JAVA_OPTIONS' in l else l |
+ # |
+ # We drop this line from the output. |
+ stderr_filter = lambda l: re.sub( |
+ r'^.*_JAVA_OPTIONS.*\n', '', l, flags=re.MULTILINE) |
agrieve
2016/04/08 13:40:29
nit: I don't think you need MULTILINE unless you u
mlopatkin
2016/04/08 16:55:16
My intention was to replace all lines that contain
agrieve
2016/04/08 17:26:50
oh garbage. Sorry about that. I just didn't see th
|
try: |
build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None, |
@@ -225,6 +234,9 @@ def main(): |
'directory tree should be stored.') |
parser.add_argument('--platform-xml-path', required=True, |
help='Path to api-platforms.xml') |
+ parser.add_argument('--android-sdk-version', required=True, |
+ help='Version (API level) of the Android SDK used for ' |
+ 'building.') |
parser.add_argument('--create-cache', action='store_true', |
help='Mark the lint cache file as an output rather than ' |
'an input.') |
@@ -288,7 +300,7 @@ def main(): |
classpath.extend(build_utils.ParseGypList(gyp_list)) |
input_paths.extend(classpath) |
- input_strings = [] |
+ input_strings = [ args.android_sdk_version ] |
if args.processed_config_path: |
input_strings.append(args.processed_config_path) |
@@ -302,6 +314,7 @@ def main(): |
args.product_dir, sources, |
args.jar_path, |
args.cache_dir, |
+ args.android_sdk_version, |
resource_dir=args.resource_dir, |
classpath=classpath, |
can_fail_build=args.can_fail_build, |