gRPC 支持 Windows on ARM for HoloLens 2
gRPC support for Windows on ARM for HoloLens 2
我想在 HoloLens 2 上 运行 构建我的 Unity-AR 应用程序。我们使用 gRPC 进行 HoloLens 设备和桌面 PC 的进程间通信以传递信息。
HoloLens 2 具有 ARM 处理器架构,gRPC 不为其提供 grpc_csharp_ext.dll.
有没有人遇到同样的问题,你是怎么解决的?
*编辑:我使用 Unity 进行应用程序开发,所以我仅限于 .NET Framework 和 .NET Standard 解决方案
中的评论的合并 copy/paste
编辑:我在 Github. 上发布了一个包含 x86
、x64
和 arm64
预编译库的 Unity 项目
我解决这个问题的方法是编译一个 Grpc.Core.dll 没有用于 WSA 构建的 Mono 和 DllImportsFromStaticLib 和一个 ARM64 版本的 grpc_charp_ext.dll
这不是官方 Unity 包的一部分但对于 HoloLens 2 是必需的。
- 下载一个每日构建的统一包(例如this one) and unzip it. This is version 1.25-dev. I have tried more recent 1.26-dev daily builds but unfortunately
grpc_charp_ext.dll
is not correctly loaded in the HoloLens emulator for these builds. I also tried the most recent version (1.29.1) vcpkg has to offer but unfortunately there is a Protobuf/System.Memory version conflict (#22251)尚未解决,afaik。
- 克隆 grpc 并检查每日构建提交:
git checkout 8853754e8caa0b2ffb3ab0e25514f3f7612ebf7a
如果你使用上面的版本
- 初始化子模块:
git submodule update --init
- 如果您像我一样不想安装过时的构建工具,您可以在 tools\run_tests\helper_scripts\pre_build_csharp.bat 中更改使用的 Visual Studio 版本。我使用“Visual Studio 15 2017”而不是“Visual Studio 14 2015”。
- 建造
grpc_charp_ext
:
python tools/run_tests/run_tests.py -l csharp -c opt --build_only
- 如果一切正常,当 Python 脚本尝试构建 C# 项目时,您最终会遇到一些 Microsoft.Build.Tasks.Git.targets 异常。它可能与某些过时的 SourceLink 依赖项或其他内容有关。尽管如此,该项目将在 Visual Studio 2019 年构建得很好。
- 应用grpc-no-static.patch.txt
- 打开Grpc.sln并编译发布版本
- 将生成的Grpc.Core.dll复制到下载包Plugins/Grcp.Core/lib/net45_wsa中
- 如果您按照这些步骤操作,您应该拥有适用于 Unity 和 HoloLens 1 的部分,现在是使其适用于 HoloLens2 的部分。
- 克隆 vcpkg 并签出标签 2020.01。我不知道是否真的需要检查 2020.01 但它包含最接近 1.25 的 grpc 版本
git clone https://github.com/microsoft/vcpkg.git
git checkout 2020.01
- 您必须编辑
grpc
端口才能构建正确的版本。下载 00001-fix-uwp.patch.txt, 00002-static-linking-in-linux.patch.txt and portfile.cmake.txt,删除 .txt
结尾并覆盖位于 ports\grpc
. 的文件
- 将 Plugins 文件夹复制到您的 Unity 项目中
- 确保文件夹 net45_wsa 中的 Grpc.Core.dll 仅用于 WSA 构建,原始构建不包括 net45_wsa 中的 Grpc.Core.dll:
- 确保 Grpc 中的 grpc_charp_ext。Core/runtimes/win/x86 和 x64 为 WSA 正确导出(正确的架构):
- 接下来你必须向后移植三重配置:下载 arm64-windows-static.cmake.txt,重命名并将其放入
triplets\community
- 现在 bootstrap
vcpkg
并使用 arm64-windows-static
三元组构建 protobuf:x86-windows
和 grpc
.\vcpkg.exe install protobuf:x86-windows
.\vcpkg.exe install grpc --triplet arm64-windows-static
- 将生成的文件
buildtrees\grpc\arm64-windows-static-rel\grpc_csharp_ext.dll
复制到您的插件文件夹 (Grpc.Core\runtimes\win\arm64
) 并为此 DLL 设置目标:
- 导出并构建您的项目
我想在 HoloLens 2 上 运行 构建我的 Unity-AR 应用程序。我们使用 gRPC 进行 HoloLens 设备和桌面 PC 的进程间通信以传递信息。 HoloLens 2 具有 ARM 处理器架构,gRPC 不为其提供 grpc_csharp_ext.dll.
有没有人遇到同样的问题,你是怎么解决的?
*编辑:我使用 Unity 进行应用程序开发,所以我仅限于 .NET Framework 和 .NET Standard 解决方案
编辑:我在 Github. 上发布了一个包含 x86
、x64
和 arm64
预编译库的 Unity 项目
我解决这个问题的方法是编译一个 Grpc.Core.dll 没有用于 WSA 构建的 Mono 和 DllImportsFromStaticLib 和一个 ARM64 版本的 grpc_charp_ext.dll
这不是官方 Unity 包的一部分但对于 HoloLens 2 是必需的。
- 下载一个每日构建的统一包(例如this one) and unzip it. This is version 1.25-dev. I have tried more recent 1.26-dev daily builds but unfortunately
grpc_charp_ext.dll
is not correctly loaded in the HoloLens emulator for these builds. I also tried the most recent version (1.29.1) vcpkg has to offer but unfortunately there is a Protobuf/System.Memory version conflict (#22251)尚未解决,afaik。 - 克隆 grpc 并检查每日构建提交:
git checkout 8853754e8caa0b2ffb3ab0e25514f3f7612ebf7a
如果你使用上面的版本
- 初始化子模块:
git submodule update --init
- 如果您像我一样不想安装过时的构建工具,您可以在 tools\run_tests\helper_scripts\pre_build_csharp.bat 中更改使用的 Visual Studio 版本。我使用“Visual Studio 15 2017”而不是“Visual Studio 14 2015”。
- 建造
grpc_charp_ext
:python tools/run_tests/run_tests.py -l csharp -c opt --build_only
- 如果一切正常,当 Python 脚本尝试构建 C# 项目时,您最终会遇到一些 Microsoft.Build.Tasks.Git.targets 异常。它可能与某些过时的 SourceLink 依赖项或其他内容有关。尽管如此,该项目将在 Visual Studio 2019 年构建得很好。
- 应用grpc-no-static.patch.txt
- 打开Grpc.sln并编译发布版本
- 将生成的Grpc.Core.dll复制到下载包Plugins/Grcp.Core/lib/net45_wsa中
- 如果您按照这些步骤操作,您应该拥有适用于 Unity 和 HoloLens 1 的部分,现在是使其适用于 HoloLens2 的部分。
- 克隆 vcpkg 并签出标签 2020.01。我不知道是否真的需要检查 2020.01 但它包含最接近 1.25 的 grpc 版本
git clone https://github.com/microsoft/vcpkg.git
git checkout 2020.01
- 您必须编辑
grpc
端口才能构建正确的版本。下载 00001-fix-uwp.patch.txt, 00002-static-linking-in-linux.patch.txt and portfile.cmake.txt,删除.txt
结尾并覆盖位于ports\grpc
. 的文件
- 将 Plugins 文件夹复制到您的 Unity 项目中
- 确保文件夹 net45_wsa 中的 Grpc.Core.dll 仅用于 WSA 构建,原始构建不包括 net45_wsa 中的 Grpc.Core.dll:
- 确保 Grpc 中的 grpc_charp_ext。Core/runtimes/win/x86 和 x64 为 WSA 正确导出(正确的架构):
- 接下来你必须向后移植三重配置:下载 arm64-windows-static.cmake.txt,重命名并将其放入
triplets\community
- 现在 bootstrap
vcpkg
并使用arm64-windows-static
三元组构建protobuf:x86-windows
和grpc
.\vcpkg.exe install protobuf:x86-windows
.\vcpkg.exe install grpc --triplet arm64-windows-static
- 将生成的文件
buildtrees\grpc\arm64-windows-static-rel\grpc_csharp_ext.dll
复制到您的插件文件夹 (Grpc.Core\runtimes\win\arm64
) 并为此 DLL 设置目标: - 导出并构建您的项目