Sunday, June 27, 2010

How to start hacking V8 JavaScript engine, IntelliJ IDEA Project Configuration

This blog post will describe how to start hacking V8 JavaScript engine with IntelliJ IDEA and C/C++ plugin.

First, one needs to checkout the sources from Subversion. You can do it using IntelliJ IDEA via action located in Version Control | Checkout from Version Control | Subversion. In appeared "Checkout from Subversion" dialog one should add "New repository location" e.g. "http://v8.googlecode.com/svn/branches/experimental/isolates". Choosing repository and pressing "Checkout" will show us "Destination directory dialog", specify target directory and press default buttons in next dialogs.

After checkout IDEA suggests you to open the project for the directory you chose. After accepting this on and pressing default buttons several times one gets IntelliJ IDEA project with V8 sources.

For V8 project additional macros should be defined (e.g. V8_TARGET_ARCH_IA32, ENABLE_DEBUGGER_SUPPORT, etc), it should be done in Settings | C++ project settings (see screenshot below), just separate the macros list with semicolon.



V8 is cross platform project, it contains several implementations of v8::internal::OS, with the same methods. To avoid getting many "duplicated" symbols warnings with C++ plugin one needs to deselect reporting of "Duplicated definitions" warnings in second part of C++ project settings, reference image added below.



If one starts C++ project first time then system wide settings (like where gcc / MS Visual C directory is, system wide defines, etc) should be configured in Settings| C++ IDE settings, see screenshot below for the reference.



In next blog post we will develop some patch for V8, stay tuned :)