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

Unified Diff: build/android/gyp/gen-android-test-isolate.py

Issue 1805643002: 🚀 Geneate base_unittest's Android .isolate file at build-time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: os.nice() and use isolate_file rather than requires_apk_isolate Created 4 years, 9 months 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 | testing/test.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/gen-android-test-isolate.py
diff --git a/build/android/gyp/gen-android-test-isolate.py b/build/android/gyp/gen-android-test-isolate.py
new file mode 100755
index 0000000000000000000000000000000000000000..d195b4b98c580e82782703a1ddab9a2ea8389776
--- /dev/null
+++ b/build/android/gyp/gen-android-test-isolate.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Creates an Android .apk.isolate for a given test target.
+
+This currently works by running "gn desc runtime_deps". In the future, it would
+be better if GN had a way to forcefully write gn runtime deps during generation
+(as if --runtime-deps-list-file were used for a target with
+record_runtime_deps = "path"). Then, this script can be changed to just convert
+the file into an .apk.isolate.
+"""
+
+import argparse
+import os
+import sys
+import pprint
+
+from util import build_utils
+
+
+_FILE_BLACKLIST = set((
+ # test_env.py are listed by test_support targets. Not needed on-device.
+ 'test_env.py',
+ # The following are packaged into the .apk.
+ 'icudtl.dat',
+ 'natives_blob_32.bin',
+ 'natives_blob_64.bin',
+ 'snapshot_blob_32.bin',
+ 'snapshot_blob_64.bin',
+))
+
+
+def _GnPath():
+ src_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
+ os.pardir)
+ if sys.platform == 'linux2':
+ subdir, exe = 'linux64', 'gn'
+ elif sys.platform == 'darwin':
+ subdir, exe = 'mac', 'gn'
+ else:
+ subdir, exe = 'win', 'gn.exe'
+ return os.path.join(src_dir, 'buildtools', subdir, exe)
+
+
+def main():
+ # GN uses a lot of CPU and ninja may run multiple at the same time. Be nice.
+ os.nice(10)
+
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('path', help='path build was generated into')
+ parser.add_argument('target', help='ninja target to generate the isolate for')
+ parser.add_argument('--out-file', help='write to file rather than stdout')
+ options = parser.parse_args()
+
+ # Use the data deps defined by the library dependencies to avoid pulling in
+ # deps required only by the test runner.
+ deps = build_utils.CheckOutput([_GnPath(), 'desc', options.path,
+ options.target, 'runtime_deps']).splitlines()
+ # .so files are hardcoded by .gn to be included in runtime_deps, but since
+ # they are embedded in the .apk, we don't need to push them to device.
+ deps = (d for d in deps if not d.endswith('.so'))
+ # lint rules are declared as data_deps to achieve better concurrency.
+ deps = (d for d in deps if '__lint' not in d)
+ # Blacklisted files.
+ deps = (d for d in deps if os.path.basename(d) not in _FILE_BLACKLIST)
+
+ # Make them relative to out-file.
+ if options.out_file:
+ subdir = os.path.relpath(options.path, os.path.dirname(options.out_file))
+ deps = (os.path.join(subdir, d) for d in deps)
+
+ isolate_data = pprint.pformat({
+ 'variables': {
+ 'files': sorted(deps),
+ }
+ })
+
+ if options.out_file:
+ with open(options.out_file, 'w') as f:
+ f.write(isolate_data + '\n')
+ else:
+ print isolate_data
+
+
+if __name__ == '__main__':
+ sys.exit(main())
+
« no previous file with comments | « no previous file | testing/test.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698