[tools][devshell][aemu] Add gRPC flag

DX-1617 #comment

This provides a mechanims to control and stream the output
of the emulator to a remote host, which is useful for remote
workflows.

This also adds the -no-window flag when running in headless
mode, which is needed by the webrtc bridge to work in the
headless setup.

Test: fx aemu -g 5556
Change-Id: Iba9016688d95da401d3bb6f0c61f86abcbb07c10
diff --git a/tools/devshell/aemu b/tools/devshell/aemu
index 019dcb6..5c1f129 100755
--- a/tools/devshell/aemu
+++ b/tools/devshell/aemu
@@ -5,12 +5,13 @@
 
 ### start fuchsia in aemu
 
-## usage: fx aemu [-a <mode>] [-N [-I <ifname>]] [-u <path>] [-e <directory>] [-w <size>] [--audio] [--headless] [--debugger]
+## usage: fx aemu [-a <mode>] [-N [-I <ifname>]] [-u <path>] [-g <port>] [-e <directory>] [-w <size>] [--audio] [--headless] [--debugger]
 ##   -a <mode> acceleration mode (auto, off, kvm, hvf, hax), default is auto
 ##   -N run with emulated nic via tun/tap
 ##   -I <ifname> uses the tun/tap interface named ifname
 ##   -u <path> execute aemu if-up script, default is no script
 ##   -e <directory> location of emulator, defaults to looking in zircon/prebuilt/downloads/aemu
+##   -g <port> enable gRPC service on port to control the emulator
 ##   -w <size> window size, default is 1280x800
 ##   --audio run with audio hardware added to the virtual machine
 ##   --headless run in headless mode
@@ -31,6 +32,7 @@
 AEMU_DIR=""
 UPSCRIPT=no
 WINDOW_SIZE="1280x800"
+GRPC=0
 
 while [[ $# -ge 1 ]]; do
   case "$1" in
@@ -57,6 +59,10 @@
     shift
     AEMU_DIR="$1"
     ;;
+  -g)
+    shift
+    GRPC="$1"
+    ;;
   -w)
     shift
     WINDOW_SIZE="$1"
@@ -137,6 +143,10 @@
     OPTIONS+=("-wait-for-debugger")
 fi
 
+if (( $GRPC )); then
+  OPTIONS+=("-grpc" "$GRPC")
+fi
+
 if (( $NET )); then
   if [[ "$(uname -s)" == "Darwin" ]]; then
     if [ -z "$IFNAME" ]; then