Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/rust-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 只检查不链接,不受影响。

---

Expand Down Expand Up @@ -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.
5 changes: 5 additions & 0 deletions rust/crates/workspace/src/ssh_configuration/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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",
Expand Down
Loading