cocos creator: v8 能支持uwp么?如何编译给uwp用的v8?

我下载v8之后,进行编译,编译的v8放在win32下面,能跑起来,但是我构建uwp工程的时候,提交到windows 商店去的时候,应用认证不过,报告上面有一些api不支持,

此应用程序类型不支持 vcruntime140.dll 中的 API _CxxThrowException。v8_libbase.dll 调用此 API。
此应用程序类型不支持 vcruntime140.dll 中的 API __std_exception_copy。v8_libbase.dll 调用此 API。
此应用程序类型不支持 vcruntime140.dll 中的 API __std_exception_destroy。v8_libbase.dll 调用此 API。
此应用程序类型不支持 vcruntime140.dll 中的 API __std_type_info_destroy_list。v8_libbase.dll 调用此 API。
此应用程序类型不支持 vcruntime140.dll 中的 API __vcrt_InitializeCriticalSectionEx。v8_libbase.dll 调用此 API。
此应用程序类型不支持 vcruntime140.dll 中的 API _except_handler4_common。v8_libbase.dll 调用此 API。
此应用程序类型不支持 vcruntime140.dll 中的 API _purecall。v8_libbase.dll 调用此 API。

应该是v8的lib构建是用了win32的api,
然后我自己构建v8的时候,生成的uwp的工程一直无法编译,
gn gen gen.out/v8x86t -ide=vs2015 --args="is_debug=false v8_enable_i18n_support=false is_component_build=false v8_use_snapshot=false current_os=“win” target_os=“winuwp” target_cpu=“x86” current_cpu=“x86"”
我是用上面的命令生成的uwp的all.sln,

我用命令生成的win32的工程,可以编译出v8 的lib,
gn gen gen.out/v8x86n -ide=vs2015 --args="is_debug=false is_component_build=true v8_use_snapshot=false target_cpu=“x86"”

请教哪位大神编译过v8的lib,如何编译给uwp用的v8的lib

1赞

uwp 有 chrome 么?

没有,只是政策不让上而已,但是react native window可以使用v8,react native window可以构建发布win app,那是不是v8应该也可以跑在winuwp上面,我构建了winuwp的工程,但是编译出错,蛋疼

我在chromium上发现还有针对winuwp的代码的提交,
https://chromium.googlesource.com/chromium/src/build/config/+log/master/BUILD.gn

31041eb WinUWP store application support is out of date by Robin Raymond · 8 months ago

我想v8应该是可以跑在winuwp上的

编译 uwp 报错是什么

build/toolchain/winbuild/win 这两个目录的东西,可能会根据环境不一样,要做一些修改。我在编译 android 的时候有做小的改动。

D:\Develop\Tools\V8\v8>gn gen gen.out/v8x86t -ide=vs2015 --args="is_debug=false v8_enable_i18n_support=false is_component_build=false v8_use_snapshot=false current_os=“win” target_os=“winuwp” target_cpu=“x86” current_cpu=“x86"”

我用这个命令生成了sln工程,
编译的时候,先是出现无法解释的编译项,-Wno-c++11-narrowing 。。。 很多,
然后我手动去掉之后,有开始出
error C2220: warning treated as error - no ‘object’ file generated
fatal error C1083: Cannot open include file: ‘iostream’: No such file or directory

默认开启了 treat warning as errors,你可以把这个关掉,关掉后遇到 warning 就不会卡编译过程。

另一个做法是,你把需要关闭的 warnings,明确指出。Wno-c++11-narrowing 是 clang 识别的, 你可以改成 msvc 识别的,风格是四个数字

看构建脚本,include 目录的设置,和自己本地的对比,可以更改

这个可以提供一些类比的素材

https://github.com/cocos2d/v8/pull/2

嗯,好的,我试试先,有结果我会再回复的,谢谢大神指导

苦笑,我看过生成的toolchain.ninja了,
rule cc
command = ninja -t msvc -e environment.store_x86 – “D:\Develop\VS2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x86\cl.exe” /nologo /showIncludes {defines} {include_dirs} {cflags} {cflags_c} /c {in} /Fo{out} /Fd"{target_out_dir}/{label_name}_c.pdb"
description = CC {out} deps = msvc rule cxx command = ninja -t msvc -e environment.store_x86 -- "D:\Develop\VS2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x86\cl.exe" /nologo /showIncludes {defines} {include_dirs} {cflags} {cflags_cc} /c {in} /Fo${out} /Fd"{target_out_dir}/{label_name}_cc.pdb"
description = CXX ${out}
deps = msvc

编译器用的cl,不是clang。。。。

把这个关掉吧,clang 的参数注释掉,有个 is_clang 的参数或许可以利用

可能默认 uwp 平台就是用的 cl.exe,微软的那一套

treat warning as error, 我已经将这个从*.vcxproj中全部替换掉了,
D:\Develop\Tools\V8\v8>gn gen gen.out/v81 -ide=vs2015 --args="is_debug=false v8_enable_i18n_support=false is_clang=true is_component_build=false v8_use_snapshot=false current_os=“win” target_os=“winuwp” target_cpu=“x86” target_winuwp_family=“app” target_winuwp_version=“10” current_cpu=“x86"”

增加了is_clang=true参数设置,但是生成的工程文件,没什么区别

你应该修改这两个目录里,gn 构建相关的文件,vcxproj 本身就是生成的东西吧,替换那个重新生成又覆盖了,没用

我修改了build/config/compiler/BUILD.gn里面的参数,将treat_warnings_as_errors=true改为false,
这样cflag中就没有添加/WX了,
error C2220: warning treated as error - no ‘object’ file generated
这个error是去掉了,
还有那些warning的关闭,我直接去掉了,
现在的问题就是
fatal error C1083: Cannot open include file: ‘iostream’: No such file or directory

我VS2017安装目录下面居然没有iostream.h文件,这正常么???

强行修改了toolchain.ninja,
添加/I 增加头文件路径,编译过去,链接异常,
error : obj/bytecode_builtins_list_generator/generate-bytecodes-builtins-list.obj: machine type x86 conflicts with x64

上面那个是链接参数设置错误了,写成x64了,应该是X86的,

iostream 没有 .h ,安装目录肯定能找到的

不要修改生成目录的东西,要修改 gn

哦,我先改生成出来的ninja文件,想先把东西编译出来先,后面再改gn,
还在处理编译问题,
assembler-ia32-inl.h(284): error C2593: ‘operator !=’ is ambiguous

if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) {

被这么一个bug困住了,

不太认同,总是要改 gn 的,gn 的可读性比 ninja 还好一点