-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Once you're done Building the Fletch binaries, you can run your Fletch code in two ways: (1) from source and (2) from snapshot. In the following examples, we assume that you are running on a 32-bit Linux system. You'll have to adjust the path to the fletch
and fletch-vm
binaries on other platforms.
This is the easiest way of running Dart code on top of Fletch. You simply pass the .dart
file to run to the fletch
binary that matches your platform:
$ out/ReleaseIA32Clang/fletch compile-and-run hello.dart
Hello, World!
Running from a snapshot is also simple. You just instruct fletch
to output a snapshot and then you run it separately with the raw fletch-vm
binary:
$ out/ReleaseIA32Clang/fletch compile-and-run hello.dart --out hello.snapshot
$ out/ReleaseIA32Clang/fletch-vm hello.snapshot
Hello, World!
Note: although the command is compile-and-run
, when using --out
, the code isn't run automatically.
Normally, fletch compile-and-run
will launch the fletch-vm
binary. But if you want to run the fletch-vm
on a device (a phone, tablet, smart lightbulb, etc.) it is often easier to start the VM and tell the compiler to attach to the already running VM. For example, on the device, run:
$ ./out/ReleaseIA32Clang/fletch-vm
Waiting for compiler on 127.0.0.1:64745
Then forward a port from your laptop to port 64745 on the device, for example, using ssh from the laptop:
$ ssh -L 64745:127.0.0.1:64745 hostname-of-device
Finally, on the laptop, run the compiler:
$ ./out/ReleaseIA32Clang/fletch compile-and-run --attach 127.0.0.1:64745 hello.dart
Connecting to 127.0.0.1:64745