From 874aabe98b11a27af8bc87ab5f677240019eef2f Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Mon, 12 Jan 2015 11:16:20 -0800 Subject: [PATCH] Fix skydb to work for android I changed skydb start to take a build directory and read the configuration out of gn args instead of --release, --debug, etc. This should be more flexable and handle all the crazy asan cases mopy/config.py tries to. Once we merge sky/tools into mojo/tools we should make mopy/config use this method too. This follows similar patterns to what mojo/tools/android_mojo_shell.py does, but doesn't use as much of the (old) android_commands and forwarder logic. We could even remove all of that build/android/pylib code by calling the (new) adb reverse instead of using Forwarder (in a later patch). This still only supports a single skydb running at once, but it should be trivial to move the skydb.pids file into the build directory or to have it support more than one instance. The big question there is what the command-line usage should look like when supporting more than one running instance. See the mojo-dev thread on the subject. R=abarth@chromium.org Review URL: https://codereview.chromium.org/816693006 --- .../flutter/tools/debugger/prompt/prompt.cc | 2 +- engine/src/flutter/tools/skydb | 159 +++++++++++++++--- 2 files changed, 133 insertions(+), 28 deletions(-) diff --git a/engine/src/flutter/tools/debugger/prompt/prompt.cc b/engine/src/flutter/tools/debugger/prompt/prompt.cc index 58c2e240ee..e31233646f 100644 --- a/engine/src/flutter/tools/debugger/prompt/prompt.cc +++ b/engine/src/flutter/tools/debugger/prompt/prompt.cc @@ -156,7 +156,7 @@ class Prompt : public mojo::ApplicationDelegate, public net::HttpServer::Delegat std::string url_; base::WeakPtrFactory weak_ptr_factory_; scoped_ptr web_server_; - unsigned command_port_; + uint32_t command_port_; DISALLOW_COPY_AND_ASSIGN(Prompt); }; diff --git a/engine/src/flutter/tools/skydb b/engine/src/flutter/tools/skydb index a84db8782d..ff906784fa 100755 --- a/engine/src/flutter/tools/skydb +++ b/engine/src/flutter/tools/skydb @@ -9,12 +9,18 @@ import argparse import json import logging import os +import pipes import requests import signal -import skypy.configuration as configuration import subprocess -import urlparse +import sys import time +import urlparse + +sys.path.insert(0, os.path.join(Paths('ignored').src_root, 'build', 'android')) +from pylib import android_commands +from pylib import constants +from pylib import forwarder SUPPORTED_MIME_TYPES = [ @@ -29,6 +35,21 @@ PID_FILE_PATH = "/tmp/skydb.pids" DEFAULT_URL = "https://raw.githubusercontent.com/domokit/mojo/master/sky/examples/home.sky" +# FIXME: Move this into mopy.config +def gn_args_from_build_dir(build_dir): + gn_cmd = [ + 'gn', 'args', + build_dir, + '--list', '--short' + ] + config = {} + for line in subprocess.check_output(gn_cmd).strip().split('\n'): + # FIXME: This doesn't handle = in values. + key, value = line.split(' = ') + config[key] = value + return config + + class SkyDebugger(object): def __init__(self): self.paths = None @@ -48,48 +69,114 @@ class SkyDebugger(object): def _in_chromoting(self): return os.environ.get('CHROME_REMOTE_DESKTOP_SESSION', False) - def _build_mojo_shell_command(self, args): - self.paths = Paths(os.path.join('out', args.configuration)) + def _wrap_for_android(self, shell_args): + build_dir_url = SkyServer.url_for_path( + self.pids['remote_sky_server_port'], + self.pids['sky_server_root'], + self.pids['build_dir']) + shell_args += ['--origin=%s' % build_dir_url] + # am shell --esa: (someone shoot me now) + # [--esa [,