Make the Sky pub package include our APK and teach sky_tool to install it

I'm not sure this is the final long-term solution, but works for now.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1022193002
This commit is contained in:
Eric Seidel 2015-03-20 14:35:14 -07:00
parent 6d1228a2f3
commit a92a67ae42
2 changed files with 17 additions and 12 deletions

View File

@ -13,17 +13,17 @@ import subprocess
import sys
import urlparse
SDK_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
SDK_ROOT = os.path.dirname(SDK_TOOLS_DIR)
# TODO(eseidel): This should be BIN_DIR.
LIB_DIR = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
SKY_PACKAGE_ROOT = os.path.realpath(os.path.dirname(LIB_DIR))
SKY_SERVER_PORT = 9888
DEFAULT_URL = os.path.join(SDK_ROOT, "examples/index.sky")
APK_NAME = 'SkyDemo.apk'
ANDROID_PACKAGE = "org.domokit.sky.demo"
# FIXME: This assumes adb is in $PATH, we could look for ANDROID_HOME, etc?
ADB_PATH = 'adb'
PID_FILE_PATH = "/tmp/skydemo.pids"
PID_FILE_PATH = "/tmp/sky_tool.pids"
PID_FILE_KEYS = frozenset([
'remote_sky_server_port',
'sky_server_pid',
@ -112,16 +112,25 @@ def _url_for_path(port, root, path):
class StartSky(object):
def add_subparser(self, subparsers):
start_parser = subparsers.add_parser('start',
help='launch SKyShell.apk on the device')
help='launch %s on the device' % APK_NAME)
start_parser.add_argument('--install', action='store_true')
start_parser.add_argument('project_or_path', nargs='?', type=str,
default='main.sky')
start_parser.set_defaults(func=self.run)
def _is_package_installed(self, package_name):
pm_path_cmd = [ADB_PATH, 'shell', 'pm', 'path', package_name]
return subprocess.check_output(pm_path_cmd).strip() != ''
def run(self, args, pids):
StopSky().run(args, pids)
if not self._is_package_installed(ANDROID_PACKAGE):
print '%s is not installed, installing.' % APK_NAME
args.install = True
if args.install:
apk_path = os.path.join(SDK_ROOT, 'apks', APK_NAME)
apk_path = os.path.join(SKY_PACKAGE_ROOT, 'apks', APK_NAME)
if not os.path.exists(apk_path):
print "'%s' does not exist?" % apk_path
return 2

View File

@ -167,10 +167,6 @@ def main():
copy(os.path.join(build_dir, 'gen/sky'),
sdk_path('packages/sky/lib'), gen_filter)
# Work around the fact that pub run doesn't work well right now.
copy(src_path('sky/sdk/packages/sky/bin/sky'),
sdk_path('packages/sky/lib/sky_tool'))
# Sky SDK additions:
copy_or_link(src_path('sky/engine/bindings/builtin.dart'),
sdk_path('packages/sky/sdk_additions/dart_sky_builtins.dart'))
@ -192,9 +188,9 @@ def main():
sdk_path('packages/mojo/sdk_additions/dart_mojo_core.dart'))
if not skip_apks:
ensure_dir_exists(sdk_path('apks'))
ensure_dir_exists(sdk_path('packages/sky/apks'))
shutil.copy(os.path.join(build_dir, 'apks', 'SkyDemo.apk'),
sdk_path('apks'))
sdk_path('packages/sky/apks'))
if generate_licenses:
with open(sdk_path('LICENSES.sky'), 'w') as license_file: