Files
tdc-rs/Cargo.toml
T
admin 400d883e1a feat(p6): 平台改为预编译 rlib 接入,依赖全部来自包内闭包
- 新增 scripts/fetch-platform.sh:读 .sspf-version 解包 vendor/ + 生成 .cargo/config.toml(rustflags + rustdocflags),只校工具链 channel
- Cargo.toml 的 [dependencies]/[dev-dependencies] 清空:17 个 crate 全部 --extern 自平台闭包
- release profile lto 由 thin 改 false(平台 rlib bitcode-free,开 LTO 找不到 __bitcode)
- tower-http 不在闭包 ⇒ 自研 platform::static_files(ServeDir 等价,含 Range 206)与 platform::cors(permissive 等价)
- reqwest 与 extern tokio 双 runtime 必 panic(no reactor running)⇒ 自研 platform::http(HTTP/1.1 明文)
- tests/auth_flow 的 reqwest 调用改用 lib 客户端;tds_biz 的头白名单补 connection
- 新增尺子 check-platform-package.sh:依赖单一来源 + 真编一次证明平台闭包零重编
- 验收:cargo test 306 passed / 七把尺子 + 新尺子全绿;dev 构建 2.5s 只编本仓
2026-11-05 13:01:27 +08:00

48 lines
2.3 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.
[package]
name = "tdc-connector"
version = "0.1.0"
edition = "2021"
description = "TDC (数据接入连接器) MVP — Rust + 静态 HTML + PGlite 本地优先实现"
[[bin]]
name = "tdc-connector"
path = "src/main.rs"
# ============================ 依赖:全部来自平台包 ============================
#
# 🔴 **本仓没有 cargo 依赖**(`[dependencies]` / `[dev-dependencies]` 都是空的),这不是漏写。
#
# 平台从 v0.5.0 起以**预编译 rlib 闭包**发布(`scripts/release.sh` 出的
# `sspf-vX.Y.Z.tar.gz`,包内 `lib/` 是构建产物 `deps/` 的完整副本)。消费方把包解到
# `vendor/sspf-vX.Y.Z/`,由 `scripts/fetch-platform.sh` 生成 `.cargo/config.toml`,
# 用 `--extern` + `-L dependency` 直接把 rlib 喂给 rustc ⇒ **平台闭包与 axum/tokio/
# serde 全部零重编**(实测 dev 1s 级)。
#
# ⇒ 依赖声明在 `.cargo/config.toml` 里,不在本文件。**这里一旦再写 `axum = "0.8"`,
# cargo 会另编一份 axum**,于是「同名 crate 两个实例」⇒ 把业务 `Router` 交给
# `sspf::Finish` 时必然 `E0308 mismatched types`(已实测)。
#
# 🔴 两个**不在闭包里**的 crate,因此业务侧自研替身(见各自模块头部的说明):
# - `tower-http`(`ServeDir` / `CorsLayer`)⇒ `src/platform/static_files.rs`、`src/platform/cors.rs`
# - `reqwest`(TDS 出向)⇒ `src/platform/http.rs`(它必须与 extern 的 tokio 同源,
# 否则 reqwest 自带的 tokio 实例与运行时不是同一个 ⇒ 实测 panic `no reactor running`)
[dependencies]
[dev-dependencies]
[profile.release]
opt-level = 2
# 🔴 必须 `false`:平台预编译 rlib 是 **bitcode-free** 的(出包时关了
# `lto` / `embed-bitcode`)⇒ 本仓开 LTO 会因找不到 `__bitcode` 段直接失败。
# 平台 rlib 本身已是 opt-level=2,损失很小。
lto = false
strip = "symbols" # 发布包剥离符号表,体积减半以上
# 🔴 不要设 `panic = "abort"`:单进程链接 sspf 后,平台契约 §6.5 要求
# panic ⇒ HTTP 200 + code=400,catch-all 中间件依赖默认的 `panic = "unwind"`。
# abort 下 `catch_unwind` 抓不到 ⇒ 进程直接死、客户端连接重置。
codegen-units = 16
[profile.dev]
incremental = false