Files
ssw-jnpf-lite-rust/Cargo.toml
T
admin bef326ad2f feat(dep): 方案 C —— 消费平台预编译 rlib,零重编平台/axum
- Cargo.toml: [workspace.dependencies] 清空(sspf/axum/tokio/serde/serde_json
  全部改由平台包 lib/ 经 --extern 喂入);release profile lto=false
  (预编译 rlib bitcode-free,开 LTO 会 failed to get bitcode for LTO)
- src/backend/Cargo.toml: 去掉 axum/tokio;packs/*: 去掉 sspf workspace 依赖
- scripts/fetch-platform.sh: 解包前 mv 走旧包目录(避免旧 hash rlib 残留);
  为 sspf/axum/tokio/serde/serde_json/http/bytes 生成 --extern(保证与 sspf
  同一 crate 实例,否则跨 API 边界 E0308 mismatched types);修 channel 解析
- .gitignore: 忽略 .cargo/config.toml(含本机绝对路径,跨机无效)
- rust-toolchain.toml: 新增(锁 rustc 1.95.0)
- 文档同步 SKILL/README/CLAUDE/HANDOFF

实测: cargo build 5.7s / --release 11s,只编本仓 5 个 crate,平台 17 crate 与
axum/tokio 零重编。
2026-11-05 11:41:19 +08:00

66 lines
3.7 KiB
TOML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ssw-jnpf-lite-rust —— cargo workspace 根
#
# 🔴 **平台不在本仓**(2026-11-04 改造):
# 平台能力(登录 / 权限 / 面 A·B / 低代码 / MCP / 177 张 base_* 表)来自
# **已发布的 `sspf` 包**(git tag `v0.5.0`),不是本仓自己实现的一份。
# 本仓只留:**示例业务包(`packs/*`)+ 面 A 适配器(`src/backend/src/modules`)
# + 薄装配入口(`src/backend/src/main.rs`)+ 前端产物**。
#
# 🔴 **依赖只有一个来源**:`[workspace.dependencies] sspf`,成员 crate 一律
# `sspf = { workspace = true }`。要升平台版本 ⇒ **只改这一行**(升 tag),
# 不许在任何成员里写第二份 git/path 依赖。
#
# 🔴 成员 crate 不得再写 `[profile.*]`(cargo 直接报错),profile 只在本文件。
[workspace]
members = ["src/backend", "packs/*"]
# 🔴 **exclude vendor/**:平台发布包解包在这里(`vendor/sspf-vX.Y.Z/`),它自带
# 自己的 workspace 根(含 `[workspace.dependencies]`)。若不 exclude,cargo 会把
# 包内 crate 误并入职本仓 workspace,导致 `libc` 等 `workspace = true` 继承解析失败。
# exclude 后,包内 crate 用包自己的 workspace 根解析,path 依赖照常工作。
exclude = ["vendor"]
resolver = "2"
[workspace.package]
version = "0.2.0"
edition = "2021"
# pglite-rs 0.2.7 要求 Rust ≥ 1.85(edition 2024 家族)。
rust-version = "1.85"
[workspace.dependencies]
# 🔴 本仓**不声明任何外部 crate 依赖**(2026-11-05 方案 C 最终形态)。
# 外部依赖(平台 sspf + axum/tokio/serde/serde_json/http/bytes)全部由
# `scripts/fetch-platform.sh` 解包平台自包含包后,在 `.cargo/config.toml` 里用
# `--extern <crate>=vendor/…/lib/lib<crate>-*.rlib` + `-L dependency=…/lib`
# 直接喂给 rustc(含 sspf 及本仓代码直用的 axum/tokio 等)。
#
# 为什么连 axum/tokio 也走 lib/(关键,已实测踩坑):
# sspf 的公共 API 签名里带 `axum::Json` / `http::HeaderMap` / `bytes::Bytes` 等类型。
# 若本仓自己再编一份 axum,就是「同名 crate 的两个实例」(version 相同、hash 不同),
# 跨 sspf 边界传参必报 `E0308 mismatched types`(multiple different versions of
# crate `axum`/`http`)。只有让本仓也用平台 lib/ 里那份预编译 axum,类型才同源。
# ⇒ 本仓 `cargo build` 只编译自己的 crate(packs/* + src/backend),零编译平台与外部依赖。
#
# 升版本 = 换 `vendor/` 里的包目录 + 重跑 `scripts/fetch-platform.sh <ver>`
# (rust-toolchain.toml 会同步锁到包内版本,如 1.95.0)。
#
# dev 回退(要改平台或换任意版本依赖时):删掉 `.cargo/config.toml`,把需要的东西
# 改回 path/registry 依赖写在此处与各成员即可(多一次编译,但完全可控)。
[profile.release]
opt-level = 2
# 🔴 必须 lto = false(方案 C,2026-11-05):平台预编译 rlib 是 **bitcode-free** 的
# (平台侧为让 macOS 系统 ld 能链上,特意关了 embed-bitcode)。若消费方开 LTO,
# 链接器会去找 rlib 里的 `__bitcode` 段 → `failed to get bitcode from object file for LTO`。
# 平台 rlib 已用 opt-level=2 编译过,关掉跨边界 LTO 的实际损失很小。
lto = false
strip = "symbols"
# 🔴 不要设 `panic = "abort"`:契约 §6.5 要求 panic ⇒ HTTP 200 + code=400,
# 而 abort 下 `catch_unwind` 抓不到 panic(进程直接死 ⇒ 客户端连接重置)。
# catch-all 中间件依赖默认的 `panic = "unwind"`(Ruling P19)。
codegen-units = 16
[profile.dev]
# 🔴 workspace 根必须关增量:member 才进 sccache,`target/debug/incremental` 也不暴涨。
incremental = false