Building V8
The documentation to build v8 is not well sorted, so here's a fast step by step guide to keep track until v8 is up and running in your system.
Get depot_tools and fetch v8, instructions here: https://chromium.googlesource.com/v8/v8/
Now build your v8 and replace CORES but the n of cores you want to use for the build. Max is the total cores you have. (e.g.: make native -j 4
.
$ cd v8/
$ make native -j `CORES`
This process might take more than 5 minutes. Get a coffee.
After it's done, you'll be able to find the built v8 for development d8
bin at out/native
.
$ ./out/native/d8
From this point you can already just run d8 and play with it.
$ ./d8
V8 version 4.3.0 (candidate) [console: dumb]
d8> var foo = "bar";
undefined
d8> foo
"bar"
d8>
If you wanna try some of the new JS features, in that case you need to use flags.
$ ./d8 --harmony_classes --harmony_sloppy
V8 version 4.3.0 (candidate) [console: dumb]
d8> class Foo {}
class Foo {}
d8> var f = new Foo()
undefined
d8> f
{}
d8>
If you want to check all the d8 flags, just run d8 --help
, there's a lot of things.
Now, in order to not mind where is d8, you might want to symlink it into a folder where you find your bin files in your PATH.
$ ln -s `pwd`/d8 /usr/local/bin/d8
Note the above example folder /usr/local/bin
might not be in your system path.
And now you can run d8
from anywhere in your system.