| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 2 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE.md file. | 4 # BSD-style license that can be found in the LICENSE.md file. |
| 5 | 5 |
| 6 # This program runs the Fletch VM in a virtual terminal controlled by the | 6 # This program runs the Dartino VM in a virtual terminal controlled by the |
| 7 # program "screen". It then attaches to the VM using the given command-line | 7 # program "screen". It then attaches to the VM using the given command-line |
| 8 # arguments. Normal usage would be something like: | 8 # arguments. Normal usage would be something like: |
| 9 # | 9 # |
| 10 # ./tools/spawn_vm_and_attach.sh out/DebugIA32Clang/fletch in session SESSION_N
AME | 10 # ./tools/spawn_vm_and_attach.sh out/DebugIA32Clang/dartino in session SESSION_
NAME |
| 11 # | 11 # |
| 12 # This is a tool that's intended for people building the Fletch VM. If you find | 12 # This is a tool that's intended for people building the Dartino VM. If you find |
| 13 # yourself using this to run Fletch on a regular basis, please get in touch | 13 # yourself using this to run Dartino on a regular basis, please get in touch |
| 14 # with the authors and let us know why. If you're unsure about how to reach the | 14 # with the authors and let us know why. If you're unsure about how to reach the |
| 15 # authors, you're welcome to file an issue at | 15 # authors, you're welcome to file an issue at |
| 16 # https://github.com/dart-lang/fletch/issues/new. | 16 # https://github.com/dart-lang/dartino/issues/new. |
| 17 | 17 |
| 18 fletch="${1}" | 18 dartino="${1}" |
| 19 shift | 19 shift |
| 20 if [ ! -x "${fletch}" ]; then | 20 if [ ! -x "${dartino}" ]; then |
| 21 echo 1>&2 Usage: "$0" PATH_TO_FLETCH_EXECUTABLE | 21 echo 1>&2 Usage: "$0" PATH_TO_DARTINO_EXECUTABLE |
| 22 exit 1 | 22 exit 1 |
| 23 fi | 23 fi |
| 24 | 24 |
| 25 # Make all errors fatal | 25 # Make all errors fatal |
| 26 set -e | 26 set -e |
| 27 | 27 |
| 28 # Create a FIFO file (aka named pipe) | 28 # Create a FIFO file (aka named pipe) |
| 29 fifo=$(mktemp -u -t fifo) | 29 fifo=$(mktemp -u -t fifo) |
| 30 mkfifo "${fifo}" | 30 mkfifo "${fifo}" |
| 31 | 31 |
| 32 # Launch the Fletch VM in a detached screen session, and duplicate its output | 32 # Launch the Dartino VM in a detached screen session, and duplicate its output |
| 33 # to the FIFO (using script) | 33 # to the FIFO (using script) |
| 34 screen -L -d -m script -t 0 -q -a "${fifo}" "${fletch}-vm" | 34 screen -L -d -m script -t 0 -q -a "${fifo}" "${dartino}-vm" |
| 35 | 35 |
| 36 # Wait for the first line of output from the VM | 36 # Wait for the first line of output from the VM |
| 37 tcp_socket=$(head -1 "${fifo}" | sed 's/^Waiting for compiler on //') | 37 tcp_socket=$(head -1 "${fifo}" | sed 's/^Waiting for compiler on //') |
| 38 | 38 |
| 39 # We're done with the FIFO | 39 # We're done with the FIFO |
| 40 rm "${fifo}" | 40 rm "${fifo}" |
| 41 | 41 |
| 42 # Attach to the VM | 42 # Attach to the VM |
| 43 exec "${fletch}" attach tcp_socket "${tcp_socket}" "$@" | 43 exec "${dartino}" attach tcp_socket "${tcp_socket}" "$@" |
| OLD | NEW |