From fd32211bc2bcb48d24131d1fbfaa552735164ba9 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Sun, 22 Nov 2026 13:27:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20Windows=20=E7=9B=AE=E6=A0=87=20clipp?= =?UTF-8?q?y=20=E4=B8=8D=E5=86=8D=E7=BC=96=E8=AF=91=E8=87=AA=E5=B8=A6?= =?UTF-8?q?=E7=9A=84=20SQLite=EF=BC=8C=E8=A1=A5=E4=B8=8A=E5=81=9C=E6=91=86?= =?UTF-8?q?=E6=9C=9F=E9=97=B4=E6=BC=8F=E6=A3=80=E7=9A=84=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=20(Refs=201lck/Lithe-IDEA#2231)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #154 给 lithe-remote 加了 motty(bundled rusqlite),lithe-workspace 默认 打开它。从那以后,“Lint for Windows” 在 Linux runner 上编译 SQLite 的 C 源码时找不到 MSVC 的 lib.exe,所有 PR 的 Rust Core / Linux 和 gate 都失败。 - 这个步骤加 LIBSQLITE3_SYS_USE_PKG_CONFIG=1:libsqlite3-sys 只复制预生成 绑定、输出链接指令,不编译 C 源码。clippy 不链接,检查结果不变。 - 步骤停摆期间漏进来的告警:ssh_configuration 测试里只给 Unix 测试用的 Directory::write、lines、DEFAULTS 加 #[cfg(unix)]。 - CONTRIBUTING 的本地 Windows clippy 命令同样加上这个变量。 --- .github/workflows/rust-core.yml | 7 ++++++- CONTRIBUTING.md | 4 ++-- rust/crates/workspace/src/ssh_configuration/tests.rs | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust-core.yml b/.github/workflows/rust-core.yml index 3d7786ed..335d9717 100644 --- a/.github/workflows/rust-core.yml +++ b/.github/workflows/rust-core.yml @@ -111,8 +111,13 @@ jobs: cargo clippy --locked --manifest-path rust/Cargo.toml "${packages[@]}" --all-targets --all-features -- -D warnings # Code behind cfg(windows) compiles only for Windows. Checking it here # finds its errors without a Windows runner; default features only, - # because the remote server feature targets Unix hosts. + # because the remote server feature targets Unix hosts. Clippy only + # checks and never links, so SQLite (bundled for the Motty import) is + # told to link a system library instead of compiling its C source, + # which needs the MSVC tools that a Linux runner does not have. - name: Lint for Windows + env: + LIBSQLITE3_SYS_USE_PKG_CONFIG: "1" run: | read -ra packages <<< "$PACKAGES" cargo clippy --locked --manifest-path rust/Cargo.toml "${packages[@]}" --all-targets --target x86_64-pc-windows-msvc -- -D warnings diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0216cb78..1760c4f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ node --test scripts/rust-core/*.test.mjs # CI 脚本自己的 cargo test --manifest-path rust/Cargo.toml -p lithe-platform -p lithe-platform-tests # 在 macOS 或 Windows 上运行平台测试 ``` -手边没有 Windows 时,至少运行一次 `cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings`,确认 Windows 代码能编译。 +手边没有 Windows 时,至少运行一次 `LIBSQLITE3_SYS_USE_PKG_CONFIG=1 cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings`,确认 Windows 代码能编译。环境变量让 SQLite 改为链接系统库、不编译自带的 C 源码:编译它需要 MSVC 工具,macOS 和 Linux 上没有;clippy 只检查不链接,不受影响。 --- @@ -132,4 +132,4 @@ node --test scripts/rust-core/*.test.mjs # the CI scripts' own cargo test --manifest-path rust/Cargo.toml -p lithe-platform -p lithe-platform-tests # platform tests on macOS or Windows ``` -Without a Windows host, at least run `cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings` to confirm the Windows code compiles. +Without a Windows host, at least run `LIBSQLITE3_SYS_USE_PKG_CONFIG=1 cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings` to confirm the Windows code compiles. The variable makes SQLite link a system library instead of compiling its bundled C source, which needs the MSVC tools that macOS and Linux do not have; clippy only checks and never links, so this does not matter. diff --git a/rust/crates/workspace/src/ssh_configuration/tests.rs b/rust/crates/workspace/src/ssh_configuration/tests.rs index f1931f04..bfb0f3be 100644 --- a/rust/crates/workspace/src/ssh_configuration/tests.rs +++ b/rust/crates/workspace/src/ssh_configuration/tests.rs @@ -18,6 +18,9 @@ impl Directory { Self(path) } + // Writing files, `lines` and `DEFAULTS` serve only the tests that run + // `fake_ssh`, a shell script, so they are Unix only like those tests. + #[cfg(unix)] fn write(&self, relative: &str, text: &str) { let path = self.0.join(relative); std::fs::create_dir_all(path.parent().unwrap()).unwrap(); @@ -53,10 +56,12 @@ fn fake_ssh(directory: &Directory, configured: &str, baseline: &str) -> String { program.display().to_string() } +#[cfg(unix)] fn lines(values: &[&str]) -> String { values.join("\n") } +#[cfg(unix)] const DEFAULTS: &[&str] = &[ "user localdev", "port 22",