目次
構築環境
- MagicOnion.Client.Unity.unitypackage 3.0.12
- MessagePack 2.2.60
- MagicOnion.Hosting 3.0.13
- gRPC のバージョン 2.23.0
- grpc-unity-package 2.26.0 (2019-12-02)
- vcpkg 2020.01
- gRPC のバージョン 1.26.0
補足
NGは動作させることができなかったバージョン。
- grpc-unity-package
- Artifacts for gRPC Build a9a4aa63-2614-4505-a66b-826d928f6667 (2.23.0 / 2019-08-02) NG
- Artifacts for gRPC Build d6090f79-7b70-429d-a477-9df736e4941a (2.25.0 / 2019-10-24) OK
- Artifacts for gRPC Build edd81ac6-e3d1-461a-a263-2b06ae913c3f (2.26.0 / 2019-12-02) OK
- Artifacts for gRPC Build 541035b6-6a06-4daf-91bc-9fb2c49fdec8 (2.32.0 / 2020-07-29) NG
- vcpkg
- 2019.12 NG
- gRPC のバージョン 1.23.0
- 2019.12 NG
- MagicOnion.Hosting
- gRPC のバージョン 2.23.0
Unity のベース構築
- MagicOnion.Client.Unity.unitypackage をインポートする
MessagePack をインポートする
CodeGenerator は
Window > MessagePack > CodeGenerator
にある
grpc-unity-package.x.xx.x-dev.zip
を解凍してAssets\Plugins
フォルダへインポートするSystem.Buffers
、System.Memory
、System.Runtime.CompilerServices.Unsafe
は除く
gRPC のコード修正・ビルド
Grpc.Core.dll
- gRPC のソースコードを取得する
- タグ [v1.26.0] をチェックアウトする
Unity の
Asset\Plugins\Grpc.Core\runtimes\win\x64\grpc_csharp_ext.dll
を gRPC プロジェクトのgrpc\cmake\build\x64\Release
フォルダにコピーする- 次のフォルダは除く
- System.Buffers
- System.Memory
- System.Runtime.CompilerServices.Unsafe
- 次のフォルダは除く
ソースコードを修正する
Release
のAny CPU
で、Grpc.Core をビルドする- 生成された
Grpc.Core\bin\Release\net45\Grpc.Core.dll
をUnityのAsset\Plugins\Grpc.Core\lib\net45\Grpc.Core.dll
に上書きする
grpc_csharp_ext.dll
vcpkg をインストールする
- vcpkg のソースコード取得
- タグ [2020.01] をチェックアウトする
bootstrap-vcpkg.bat
を実行する- 以下のファイルを
vcpkg\ports\grpc
フォルダに上書きする - 以下のファイルを
vcpkg\triplets\community
にコピーする
vcpkg install protobuf:x86-windows
vcpkg install grpc:arm64-windows-static
なにか言われたら随時対処して再実行する
Warning: The following VS instances are excluded because the English language pack is unavailable. C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional Please install the English language pack. Could not locate a complete toolset.
- Visual Studio Installer から英語の言語パックをインストール
-- Using source at C:/git/Microsoft/vcpkg/buildtrees/protobuf/src/a5c431386a-c9deea9e31.clean CMake Error at ports/protobuf/portfile.cmake:22 (message): Cross-targetting protobuf requires the x86-windows protoc to be available. Please install protobuf:x86-windows first. Call Stack (most recent call first): scripts/ports.cmake:79 (include)
Error: Building package protobuf:arm64-windows-static failed with: BUILD_FAILED
install protobuf:x86-windows
やり直したい場合は、
vcpkg remove grpc:arm64-windows-static
してbuildtrees\grpc
フォルダを削除する- キャッシュ使って
buildtrees
が吐き出されない場合は下記フォルダを削除するC:\Users\[username]\AppData\Local\vcpkg\archives
- キャッシュ使って
buildtrees\grpc\arm64-windows-static-rel
にgrpc_csharp_ext.dll
が生成されるので、UnityのAsset\Plugins\Grpc.Core\runtimes\win\arm64
フォルダを作成してインポート- PlatformでWSAPlayer を選択、CPU を ARM64 に
grpc_csharp_ext_dummy_stubs.c
Asset\Plugins\Grpc.Core\runtimes\grpc_csharp_ext_dummy_stubs
の WSAPlayer にチェックを付ける
動作確認
以下のサイトに習い一部読み替えながら実施する。