Skip to content

Commit

Permalink
docs: 📝 specify protoc minimal version in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisu-Woniu committed Mar 22, 2024
1 parent 8c810ec commit b38b786
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 52 deletions.
5 changes: 3 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
xtask = "run --package xtask --"
xtask-dbg = "run --package xtask --features dbg --"

[build]
rustflags = ["-Clink-arg=-fuse-ld=lld"]
# Use custom linker for faster linking
# [build]
# rustflags = ["-Clink-arg=-fuse-ld=mold"]
12 changes: 10 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get upgrade -y && \
sudo apt-get install -y lld lintian
- name: Setup Buf
sudo apt-get install -y wget lintian clang
- name: Setup mold
uses: rui314/setup-mold@v1
- name: Setup buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- name: Lint protobuf files
uses: bufbuild/buf-lint-action@v1
- name: Run clippy lint
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 30 additions & 19 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,53 +46,62 @@ https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=NJUPT-SAST%2Frsjudge[
=== Prerequisites

* Rust 1.74 or later,
* `lld` for faster linking,
** You can use other linkers instead, just update the `.cargo/config.toml` file.
* Linux kernel >= 4.5,
** Required for Seccomp BPF support.
* For gRPC support (under `grpc` feature):
** `protoc` as Protocol Buffers compiler,
** `buf` for gRPC dependencies management.
** https://github.com/protocolbuffers/protobuf?tab=readme-ov-file#protobuf-compiler-installation[`protoc`] >= 3.15,
** https://github.com/bufbuild/buf/[`buf`] for gRPC dependencies management.
* For `.deb` package generation, a Debian/Ubuntu system with `dpkg-dev` and `liblzma-dev` installed.

=== Install dependencies

==== Debian/Ubuntu
You can install Rust toolchain with `rustup`:

[,bash]
----
sudo apt install -y lld protobuf-compiler libprotobuf-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
----

# For buf support
curl -sSL -o buf \
"https://github.com/bufbuild/buf/releases/download/latest/buf-Linux-$(uname -m)"
# You may replace `/usr/local/bin` with your preferred directory,
# and ensure it is added to `PATH`.
sudo install -Dm755 buf /usr/local/bin/buf
==== Debian/Ubuntu

. Install buf manually, if they are not available in the package manager.

. Ensure a `protoc` binary with version >= 3.15 is available in your PATH, or install it manually by downloading from https://github.com/protocolbuffers/protobuf/releases/[the release page].

# If you want to build `.deb` package
sudo apt install -y dpkg-dev liblzma-dev
** On Debian 12, Ubuntu 23.04 or later versions, you can install a compatible `protoc` with `apt`:
+
[,bash]
----
sudo apt install -y protobuf-compiler libprotobuf-dev
----

. Install packaging related packages with `apt`:
+
[,bash]
----
sudo apt install dpkg-dev liblzma-dev
----

==== Alpine

[,bash]
----
sudo apk add lld protoc protobuf-dev
sudo apk add protoc protobuf-dev
# For buf support
# Installing buf
curl -sSL -o buf \
"https://github.com/bufbuild/buf/releases/download/latest/buf-Linux-$(uname -m)"
# Replace `/usr/local/bin` with your preferred directory,
# remember to add it to `PATH`
# You can replace `/usr/local/bin` with your preferred directory,
# but remember to add it to `PATH`
sudo install -Dm755 buf /usr/local/bin/buf
----

==== Arch Linux

[,bash]
----
sudo pacman -S --needed lld protobuf buf
sudo pacman -S --needed protobuf buf
----

=== Build
Expand All @@ -118,3 +127,5 @@ Generate `.deb` package:
----
cargo xtask dist deb
----

The `.deb` package will be generated in `target/debian`.
32 changes: 21 additions & 11 deletions README.zh-CN.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
= RsJudge
= rsjudge
:lang: zh-CN
:toc: preamble
:toc-title: 目录

Expand Down Expand Up @@ -47,28 +48,35 @@ https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=NJUPT-SAST%2Frsjudge[
=== 先决条件

* Rust 1.74 或更高版本。
* `lld` 用于更快的链接。
** 你也可以使用其他链接器,只需更新 `.cargo/config.toml` 文件。
* Linux 内核 >= 4.5
** 这是为了支持 Seccomp BPF。
* 对于 gRPC 支持,需要 `protoc` 协议缓冲区编译器,以及协议缓冲区资源文件(在 `grpc` 特性下)
* 对于 gRPC 支持(在 `grpc` 特性下)
** https://github.com/protocolbuffers/protobuf?tab=readme-ov-file#protobuf-compiler-installation[`protoc`] >= 3.15,
** https://github.com/bufbuild/buf/[`buf`] 用于 gRPC 依赖管理。
* 对于 `.deb` 包的生成,需要安装了 `dpkg-dev` 和 `liblzma-dev` 的 Debian/Ubuntu 系统。

=== 安装额外的依赖

==== Debian/Ubuntu

. 确保 `PATH` 中包含 `protoc` >= 3.15,可以从
https://github.com/protocolbuffers/protobuf/releases/[发布页]下载最新版本。

** 在 Debian 12, Ubuntu 23.04 或更高版本的系统上,可以使用 `apt` 安装符合版本要求的 `protoc`:
+
[,bash]
----
sudo apt install -y lld protobuf-compiler libprotobuf-dev
sudo apt install -y protobuf-compiler libprotobuf-dev
protoc --version
# libprotoc <VERSION>
----

# 安装 `buf` 工具
curl -sSL -o buf \
"https://github.com/bufbuild/buf/releases/download/latest/buf-Linux-$(uname -m)"
# 您可以用自己喜欢的目录替换 `/usr/local/bin`,并确保将其添加到 `PATH` 中。
sudo install -Dm755 buf /usr/local/bin/buf
. 手动安装 `buf`。

# 如果你想构建 `.deb` 包
. 使用 `apt` 安装打包 `.deb` 需要的软件包:
+
[,bash]
----
sudo apt install -y dpkg-dev liblzma-dev
----

Expand Down Expand Up @@ -115,3 +123,5 @@ cargo build --release
----
cargo xtask dist deb
----

生成的软件包位于 `target/debian` 目录下。
4 changes: 2 additions & 2 deletions crates/rsjudge-grpc/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, io::BufRead, path::PathBuf, process::Command};

use tonic_build::compile_protos;
use tonic_build::configure;

/// Generate Rust code from the proto files.
///
Expand Down Expand Up @@ -43,7 +43,7 @@ fn main() -> anyhow::Result<()> {
);

for proto in protos {
compile_protos(proto_out_dir.join(proto))?;
configure().compile(&[proto_out_dir.join(proto)], &[&proto_out_dir])?;
}

println!("cargo:rerun-if-changed=proto");
Expand Down

0 comments on commit b38b786

Please sign in to comment.