Update instructions

This commit is contained in:
Changhua 2023-12-06 22:12:26 +08:00
parent 5b6d202dde
commit 45826ec8be

View File

@ -1,26 +1,33 @@
# WeChatFerry Java 客户端 # WeChatFerry Java 客户端
⚠️ **只支持 Windows** ⚠️ ⚠️ **只支持 Windows** ⚠️
## 快速开始 ## 快速开始
* 下载 [最新发布的版本](https://github.com/lich0821/WeChatFerry/releases/latest),解压,找到 java 客户端。
* 下载 [最新发布的文件](https://github.com/lich0821/WeChatFerry/releases/latest),解压到 `WeChatFerry\clients\java\wcferry\src\main\resources\win32-x86-64`。
* 使用惯用 IDE打开工程编译运行。 * 使用惯用 IDE打开工程编译运行。
## 从头开始 ## 从头开始
【添加 `wcferry` 依赖】是必须要执行的,工程里不带这几个文件;如果开发新功能,一般需要修改 `wcf.proto`,从而需要重新生成 PB 文件;其他的,一般不需要关注。 【添加 `wcferry` 依赖】是必须要执行的,工程里不带这几个文件;如果开发新功能,一般需要修改 `wcf.proto`,从而需要重新生成 PB 文件;其他的,一般不需要关注。
### 添加 `nng` 依赖 ### 添加 `nng` 依赖
* 新建一个 `libs` 目录 * 新建一个 `libs` 目录
* 参考 [nng-java](https://github.com/voutilad/nng-java),编译 jar 包(`nng-java-1.4.0-SNAPSHOT.jar` * 参考 [nng-java](https://github.com/voutilad/nng-java),编译 jar 包(`nng-java-1.4.0-SNAPSHOT.jar`
* 添加依赖 `nng-java-1.4.0-SNAPSHOT.jar` * 添加依赖 `nng-java-1.4.0-SNAPSHOT.jar`
```groovy ```groovy
implementation 'net.java.dev.jna:jna:5.6.0' implementation 'net.java.dev.jna:jna:5.6.0'
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
``` ```
#### 编译 / 安装 `mbedtls` #### 编译 / 安装 `mbedtls`
* 下载 [Mbed TLS](https://github.com/Mbed-TLS/mbedtls) 代码并解压 * 下载 [Mbed TLS](https://github.com/Mbed-TLS/mbedtls) 代码并解压
* 新建 `build` 目录,生成 VS 工程 * 新建 `build` 目录,生成 VS 工程
```sh ```sh
cd build cd build
cmake .. cmake ..
@ -30,8 +37,10 @@ cmake ..
* [参考](https://github.com/Mbed-TLS/mbedtls) * [参考](https://github.com/Mbed-TLS/mbedtls)
#### 编译 / 安装 `nng` #### 编译 / 安装 `nng`
* 下载 [nng](https://github.com/nanomsg/nng) 代码并解压 * 下载 [nng](https://github.com/nanomsg/nng) 代码并解压
* 新建 `build` 目录,生成 VS 工程 * 新建 `build` 目录,生成 VS 工程
```sh ```sh
cmake -DBUILD_SHARED_LIBS=ON -DNNG_ENABLE_TLS=ON -DMBEDTLS_ROOT_DIR="C:\Program Files (x86)\mbed TLS" .. cmake -DBUILD_SHARED_LIBS=ON -DNNG_ENABLE_TLS=ON -DMBEDTLS_ROOT_DIR="C:\Program Files (x86)\mbed TLS" ..
``` ```
@ -40,24 +49,31 @@ cmake -DBUILD_SHARED_LIBS=ON -DNNG_ENABLE_TLS=ON -DMBEDTLS_ROOT_DIR="C:\Program
* [参考](https://github.com/nanomsg/nng/issues/953) * [参考](https://github.com/nanomsg/nng/issues/953)
### 添加 PB 依赖 ### 添加 PB 依赖
```groovy ```groovy
implementation 'com.google.protobuf:protobuf-java:3.22.2' // 版本需要和 protoc 一致 implementation 'com.google.protobuf:protobuf-java:3.22.2' // 版本需要和 protoc 一致
``` ```
#### 重新生成 PB 文件 #### 重新生成 PB 文件
参考 [Protocol Buffer Basics: Java](https://protobuf.dev/getting-started/javatutorial/#problem-domain)。 参考 [Protocol Buffer Basics: Java](https://protobuf.dev/getting-started/javatutorial/#problem-domain)。
* 下载 `protoc` 工具(注意,需要与 `com.google.protobuf:protobuf-java` 一致): * 下载 `protoc` 工具(注意,需要与 `com.google.protobuf:protobuf-java` 一致):
这里下载 [protoc-22.2](https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-win64.zip),解压,并将所在路径加入环境变量(以便随处可用)。 这里下载 [protoc-22.2](https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-win64.zip),解压,并将所在路径加入环境变量(以便随处可用)。
* 编译 PB 文件 * 编译 PB 文件
```sh ```sh
# 调整项目路径
cd C:/Projs/WeChatFerry/java/wcferry/src/main/java cd C:/Projs/WeChatFerry/java/wcferry/src/main/java
protoc.exe --java_out=. --proto_path=C:\Projs\WeChatFerry\rpc\proto wcf.proto protoc.exe --java_out=. --proto_path=C:\Projs\WeChatFerry\WeChatFerry\rpc\proto wcf.proto
``` ```
### 添加 `wcferry` 依赖 ### 添加 `wcferry` 依赖
将 `wcf.exe` 、 `spy.dll` 、 `spy_debug.dll` 添加到 `C:\Projs\WeChatFerry\java\wcferry\src\main\resources\win32-x86-64`。
将 `wcf.exe` 、 `spy.dll` 、 `spy_debug.dll` 添加到 `WeChatFerry\clients\java\wcferry\src\main\resources\win32-x86-64`。
### 其他问题 ### 其他问题
### 乱码 ### 乱码
参考 [这篇文章](https://www.quanxiaoha.com/idea/idea-chinese-garbled-code.html)。 参考 [这篇文章](https://www.quanxiaoha.com/idea/idea-chinese-garbled-code.html)。