|
9 | 9 | from __future__ import print_function
|
10 | 10 |
|
11 | 11 | import sys
|
12 |
| -from sys import stdout |
| 12 | +from sys import stdout, platform |
13 | 13 | from os.path import (join, dirname, realpath, exists, isdir, basename,
|
14 | 14 | expanduser)
|
15 | 15 | from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk, uname
|
@@ -2520,6 +2520,27 @@ def delete_dist(self, args):
|
2520 | 2520 | info('No dist exists that matches your specifications, exiting without deleting.')
|
2521 | 2521 | shutil.rmtree(dist.dist_dir)
|
2522 | 2522 |
|
| 2523 | + def adb(self, args): |
| 2524 | + '''Runs the adb binary from the detected SDK directory, passing all |
| 2525 | + arguments straight to it.''' |
| 2526 | + ctx = self.ctx |
| 2527 | + ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir, |
| 2528 | + user_ndk_dir=self.ndk_dir, |
| 2529 | + user_android_api=self.android_api, |
| 2530 | + user_ndk_ver=self.ndk_version) |
| 2531 | + if platform in ('win32', 'cygwin'): |
| 2532 | + adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb.exe')) |
| 2533 | + else: |
| 2534 | + adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb')) |
| 2535 | + info_notify('Starting adb...') |
| 2536 | + output = adb(args, _iter=True, _out_bufsize=1, _err_to_out=True) |
| 2537 | + for line in output: |
| 2538 | + print(line) |
| 2539 | + |
| 2540 | + def logcat(self, args): |
| 2541 | + '''Runs ``adb logcat`` using the adb binary from the detected SDK |
| 2542 | + directory. All extra args are passed as arguments to logcat.''' |
| 2543 | + self.adb(['logcat'] + args) |
2523 | 2544 |
|
2524 | 2545 | if __name__ == "__main__":
|
2525 | 2546 |
|
|
0 commit comments