On some operating systems, such as Fedora 26, you can download pre-built V8 using your package manager. This is recommended. Otherwise, you'll need to choose between a static and dynamic build (static is less hassle, but the application binary will take longer to link).
Building V8 is always a clusterfuck. Don't get discouraged if you keep getting obscure errors from wacky Google tools. It's normal. If stuck, you can refer to the travis config which targets a pristine enviroment with no pre-installed tools.
cd dependencies
# depot tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
# clone v8 repository
fetch v8
cd v8
# pick a known-good version
git checkout tags/6.0.286.55
gclient sync
On Windows, you'll need to use CMD, not bash. Also don't forget to set DEPOT_TOOLS_WIN_TOOLCHAIN=0
first.)
You'll need to have Python in your $PATH
. On Windows, you can use the one from depot_tools
.
As of 2017/08, V8's build system is fucked again, and if you want a static build, you'll need to edit v8/gni/v8.gni
to v8_static_library = true
.
gn gen out.gn/x64.release --args='is_debug=false target_cpu="x64" is_component_build=false v8_static_library=true'
ninja -j 4 -C out.gn/x64.release v8
Visual Studio 2015 + Debugging Tools for Windows is currently required by V8. The codebase actually supports 2017 now, but v8/gypfiles/vs_toolchain.py
must be manually updated by copying from Chromium repo.
gn gen out.gn/x64.optdebug --args='v8_optimized_debug=true target_cpu="x64" is_component_build=false v8_static_library=true'
ninja -C out.gn/x64.optdebug v8
Building V8 in Debug mode is of course possible as well. Do note, however, that a Debug build of V8 will take a few gigabytes on disk.
Of course, if you don't need debugging, you can go for a Release build. This precludes debugging of not only V8, but also the application itself.
This is ridiculously easy in comparison to messing with V8. The options will vary based on your setup.
git submodule update --init --recursive
cmake -DWITH_V8=1 -DSTATIC_V8=1 -DSYSTEM_V8=0 .
make -j4
./agdgserverd