Building v8 is easy but not well documented, so here's a fast guide to track you until v8 is up and running in your machine.
First, clone chromium depot_tools and set the given folder to your PATH.
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH=`pwd`/depot_tools:"$PATH"
It's also good to include this export statement at .bashrc replacing `pwd` with your pwd
return. Just try the pwd
command if you didn't heard of it before.
Now fetch the v8 source. It might take more than 1 minute.
At this point, if you use Mac OS, open your Activity Monitor, click on Window
on the context menu and then on CPU Usage
to track your cores usage.
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
.
$ cd out/native
$ ls d8
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.
Create an alias for d8 on your .bashrc
:
alias d8='~/dev/v8/out/native/d8'
And now you can run d8
from anywhere in your system.