git clone https://chromium.googlesource.com/chromium/tools/depot_tools set DEPOT_TOOLS_WIN_TOOLCHAIN = 0 set GYP_MSVS_OVERRIDE_PATH =C:\Program Files (x86)\Microsoft Visual Studio19\Enterprise set GYP_MSVS_VERSION =2019 git config --global http.proxy http://127.0.0.1:8080 git config --global https.proxy http://127.0.0.1:8080 netsh winhttp set proxy 127.0.0.1:8080 set HTTP_PROXY=http://127.0.0.1:8080 set HTTPS_PROXY=http://127.0.0.1:8080 fetch v8 cd v8 #这个切换分支的 最新稳定版- 此次编译使用的是9.4 git checkout lkgr gclient sync #可能要修改这两处-否则后面编译不过云 #gm.py文件修改下面的 #return os.uname()[4] return "nt" setup_toolchain.py文件修改下面的 #with open(environment_block_name, 'w') as f: with open(environment_block_name, 'w',encoding='utf-8') as f: #编译动态库- 这4条命令编译出来的lib不能用,导出符号名有问题. python tools\dev\gm.py ia32.debug python tools\dev\gm.py ia32.release python tools/dev/gm.py x64.debug python tools/dev/gm.py x64.release #编译静态库(lib) x64 release python .\tools\dev\v8gen.py x64.release -- v8_monolithic=true v8_use_external_startup_data=false use_custom_libcxx=false is_component_build=false treat_warnings_as_errors=false v8_symbol_level=0 v8_enable_pointer_compression=false ninja -C .\out.gn\x64.release v8_monolith -j 32 #x64 debug python .\tools\dev\v8gen.py x64.debug -- enable_iterator_debugging=false v8_monolithic=true v8_enable_i18n_support=false is_debug=true v8_use_external_startup_data=false use_custom_libcxx=false is_component_build=false treat_warnings_as_errors=false v8_symbol_level=0 v8_enable_pointer_compression=false ninja -C .\out.gn\x64.debug v8_monolith -j 32 #x86 release python .\tools\dev\v8gen.py ia32.release -- v8_monolithic=true v8_enable_i18n_support=false v8_use_external_startup_data=false use_custom_libcxx=false is_component_build=false treat_warnings_as_errors=false v8_symbol_level=0 ninja -C .\out.gn\ia32.release v8_monolith -j 32 #x86 debug python .\tools\dev\v8gen.py ia32.debug -- enable_iterator_debugging=false v8_monolithic=true v8_enable_i18n_support=false is_debug=true v8_use_external_startup_data=false use_custom_libcxx=false is_component_build=false treat_warnings_as_errors=false v8_symbol_level=0 ninja -C .\out.gn\ia32.debug v8_monolith -j 32 #编译动态库 #使用msvc编译 call gn gen out/ia32.debug --args="is_debug=true use_glib=false is_component_build=true v8_use_external_startup_data=false v8_static_library=false is_clang = false treat_warnings_as_errors=false v8_enable_i18n_support=false target_cpu=\"x86\"" ninja -C .\out\ia32.debug v8.dll -j 34 #ninja -C .\out\ia32.debug -j 34
#编译静态库需要修改预定义宏-以达到与VS相匹配 #修改文件build\config\BUILD.gn #找到以下代码修改 if (is_win) { if (!enable_iterator_debugging && !use_custom_libcxx) { # Iterator debugging is enabled by default by the compiler on debug # builds, and we have to tell it to turn it off. #defines += [ "_HAS_ITERATOR_DEBUGGING=0" ] //修改这行 defines += [ "_HAS_ITERATOR_DEBUGGING=1" ] #再添加这一行 defines += [ "_ITERATOR_DEBUG_LEVEL=2" ] } } else if ((is_linux || is_chromeos) && current_cpu == "x64" && enable_iterator_debugging) { # Enable libstdc++ debugging facilities to help catch problems early, see # http://crbug.com/65151 . # TODO(phajdan.jr): Should we enable this for all of POSIX? defines += [ "_GLIBCXX_DEBUG=1" ] }
参考:https://toyobayashi.github.io/2020/07/04/V8/
11