編譯v8需要開啓vpn,需要下載代碼和依賴項。
google 編譯文檔
https://github.com/v8/v8/wiki/Building%20from%20Source
1、安裝git
2、安裝depot_tools,安裝方法參照 https://www.chromium.org/developers/how-tos/install-depot-tools,注意下載解壓的路徑不能有空格,並將解壓路徑添加至環境變量path,
如果一切正常的話在depot_tools目錄下應該有python276_bin目錄, 將此路徑添加至path
3、運行gclient(好像是更新depot_tools和下載一些依賴項)
4、cd到你需要下載v8源碼的目錄,執行fetch v8 ,下載需要較長的時間(大概1G),下載的是github上最新的,(此時應該是v5.7)
5、cd 到v8 目錄
6、運行
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_MSVS_VERSION=2015
set GYP_GENERATORS=ninja
python gypfiles\gyp_v8(google文檔這樣操作,但是在build目錄下卻找不到all.sln)
使用下面方法中的其中一種,-Dtarget_arch指定平臺 -Dcomponent=shared_library 動態庫 沒有則是靜態庫
python gypfiles\gyp_v8.py -Dtarget_arch=x64 -Dcomponent=shared_library -f msvs
python gypfiles\gyp_v8.py -Dtarget_arch=ia32 -Dcomponent=shared_library -f msvs
python gypfiles\gyp_v8.py -Dtarget_arch=x64 -f msvs
python gypfiles\gyp_v8.py -Dtarget_arch=ia32 -f msvs
在gypfiles目錄下應該就可以看到All.sln解決方案了。
對於需要將v8嵌入到c++程序的 ,建議看官方文檔說明
https://github.com/v8/v8/wiki/Embedder's%20Guide