How to build PhantomJS from sources on Windows

Hello.
In this tutorial we will describe, how to build PhantomJS from main branch of the PhantomJS repository.
1) Download sources, as described on official PhantomJS site http://phantomjs.org/build.html :
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git submodule init
git submodule update
2) Start Developer Command Prompt for VS2015:
3) In Developer Command Prompt change directory to phantomjs directory.
 
4) Enable Build with Multiple Processes (https://msdn.microsoft.com/en-us/library/bb385193.aspx?f=255&MSPPError=-2147217396) – run in the console:
set CL=/MP /INCREMENTAL
Info about CL Environment Variables – https://msdn.microsoft.com/en-us/library/kezkeayy.aspx
5) Remove all files from directory phantomjs\src\qt\3rdparty\libicu\ . 
 
6) Now we need to configure phantomjs build to use custom ICU, when it will build webkit / qtwebkit. As described at the page https://wiki.qt.io/Building_Qt_5_from_Git , you will need to download precompiled ICU packages from http://download.qt.io/development_releases/prebuilt/icu/prebuilt/ . In this tutorial I will use http://download.qt.io/development_releases/prebuilt/icu/prebuilt/msvc2013/icu_53_1_msvc_2013_32_devel.7z .

Download it and extract into the phantomjs\src\qt\3rdparty\libicu\ .

7) Download and install required for build software – you must have Perl, Python, Ruby, and Git on PATH.
 
8) Download http://sourceforge.net/projects/winflexbison/files/win_flex_bison-2.5.5.zip/download and unpack it into the phantomjs\src\qt\3rdparty\gnuwin32\bin\ (with files overwriting). Rename win_flex.exe to flex.exe and win_bison.exe to bison.exe with replacement of old files both.
 
9) Run in the Developer Command Prompt: 
SET INCLUDE=%CD%\src\qt\3rdparty\libicu\include;%INCLUDE%
SET LIB=%CD%\src\qt\3rdparty\libicu\lib;%LIB%
SET PATH=%CD%\src\qt\3rdparty\libicu\lib;%PATH%
SET PATH=%CD%\src\qt\3rdparty\gnuwin32\bin;%PATH%
10) Start build:
python build.py