<commit_before>V8Js on Windows
===============

The V8Js PHP extension is primarily targeted at Unix platforms, especially
GNU/Linux.  However it is possible (and supported) to build on Windows, using
Microsoft Visual Studio.

Building with MinGW or Cygwin is not officially supported; mainly since
Google v8 does not support builds on Cygwin (and building it on Cygwin is
currently broken).

Compared to installation on GNU/Linux it's way more tedious to install V8Js
on Windows, since you need to compile PHP with all its dependencies beforehand.

You need to have Visual Studio 2015 (aka VC14), make sure to install the C++
compiler (which is not installed by default any longer).

Compiling V8 using GN (required for 5.2 and higher)
---------------------------------------------------

[Build transcript using GN](https://github.com/phpv8/v8js/issues/287#issuecomment-284222529) by @Jan-E

This is how I built V8 5.8.

TL;DR: these are the essential commands for x64.

```
call git checkout 5.8-lkgr
call gclient sync
call gn gen v5.8\x64.release --args="is_component_build=true is_debug=false v8_use_snapshot=false enable_nacl=false target_cpu=\"x64\"" --ide=vs
cd v5.8\x64.release
msbuild all.sln
```

Prerequisites:

- VC14 aka VS2015 with the C and C++ compilers. The Community edition suffices.
- The Windows 10 Debugging Tools. If you did not install the Windows 10 SDK together with VC14, you can do a separate download from https://developer.microsoft.com/en-us/windows/hardware/windows-driver-kit => Windows 10 (WinDbg)

My initial setup was a mixture of the Linux & Windows commands at https://www.chromium.org/developers/how-tos/install-depot-tools

```
D:
cd \
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git chromium
set path=D:\chromium;%path%
set GYP_MSVS_VERSION=2015
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_CHROMIUM_NO_ACTION=0
cd chromium
fetch v8
git stash
```

Then I ran the following batch script, inside a 'VS2015 x64 Native Tools Command Prompt' (x64) or a 'VS2015 x86 Native Tools Command Prompt' (x86):

```<commit_msg>Add the note about the PATH once again<commit_after>V8Js on Windows
===============

The V8Js PHP extension is primarily targeted at Unix platforms, especially
GNU/Linux.  However it is possible (and supported) to build on Windows, using
Microsoft Visual Studio.

Building with MinGW or Cygwin is not officially supported; mainly since
Google v8 does not support builds on Cygwin (and building it on Cygwin is
currently broken).

Compared to installation on GNU/Linux it's way more tedious to install V8Js
on Windows, since you need to compile PHP with all its dependencies beforehand.

You need to have Visual Studio 2015 (aka VC14), make sure to install the C++
compiler (which is not installed by default any longer).

Compiling V8 using GN (required for 5.2 and higher)
---------------------------------------------------

[Build transcript using GN](https://github.com/phpv8/v8js/issues/287#issuecomment-284222529) by @Jan-E

This is how I built V8 5.8.

TL;DR: these are the essential commands for x64.

```
call git checkout 5.8-lkgr
call gclient sync
call gn gen v5.8\x64.release --args="is_component_build=true is_debug=false v8_use_snapshot=false enable_nacl=false target_cpu=\"x64\"" --ide=vs
cd v5.8\x64.release
msbuild all.sln
```

Prerequisites:

- VC14 aka VS2015 with the C and C++ compilers. The Community edition suffices.
- The Windows 10 Debugging Tools. If you did not install the Windows 10 SDK together with VC14, you can do a separate download from https://developer.microsoft.com/en-us/windows/hardware/windows-driver-kit => Windows 10 (WinDbg)

My initial setup was a mixture of the Linux & Windows commands at https://www.chromium.org/developers/how-tos/install-depot-tools

```
D:
cd \
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git chromium
set path=D:\chromium;%path%
set GYP_MSVS_VERSION=2015
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_CHROMIUM_NO_ACTION=0
cd chromium
fetch v8
git stash
```
Note: do not add the checkout dir to your path permanently if you've already installed git.exe somewhere in your path: the depot tools will create a git.bat in the checkout dir!

Then I ran the following batch script, inside a 'VS2015 x64 Native Tools Command Prompt' (x64) or a 'VS2015 x86 Native Tools Command Prompt' (x86):

```
{'fraction_non_alphanumeric': 0.104247990815155, 'fraction_numerical': 0.037657864523536165, 'mean_word_length': 4.118683901292597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '568733', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1290, 'n_words': 550}