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
15 changes: 8 additions & 7 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# TetherKit 代码格式配置
# 以 Google 风格为基线,放宽行宽到 100 列以容纳协议常量表与长类型名。
# TetherKit code formatting configuration.
# Google style as the baseline, with line width relaxed to 100 columns to fit
# protocol constant tables and long type names.
---
Language: Cpp
BasedOnStyle: Google
Expand All @@ -11,25 +12,25 @@ TabWidth: 2
UseTab: Never
AccessModifierOffset: -1

# 指针/引用贴类型:TetherKit 统一写 `Foo* p` 而非 `Foo *p`
# Pointer/reference hugs the type: TetherKit writes `Foo* p`, not `Foo *p`
DerivePointerAlignment: false
PointerAlignment: Left
ReferenceAlignment: Left

# 大括号:函数与控制流的左括号不换行(Attach)
# Braces: function and control-flow opening braces stay on the same line (Attach)
BreakBeforeBraces: Attach
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
InsertBraces: true

# 构造函数初始化列表每行一个,便于 diff
# Constructor initializer lists: one base per line to keep diffs readable
BreakConstructorInitializers: BeforeColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
PackConstructorInitializers: NextLine

# 头文件分组:本项目头 > 第三方 > 系统/平台 > 标准库
# Include-group order: project headers > third party > system/platform > stdlib
SortIncludes: CaseSensitive
IncludeBlocks: Regroup
IncludeCategories:
Expand All @@ -46,7 +47,7 @@ IncludeCategories:
- Regex: '.*'
Priority: 5

# 其它
# Misc
AlwaysBreakTemplateDeclarations: Yes
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
Expand Down
27 changes: 17 additions & 10 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# TetherKit 静态检查配置
# TetherKit static analysis configuration.
#
# 取舍说明:
# * 本项目是与内核 ABI / USB 线格式打交道的底层驱动,必然出现大量 reinterpret_cast、
# C 风格数组、位运算与魔数常量,因此关掉一批对系统编程不适用的检查。
# * 数据路径要求零分配、无虚函数开销,因此保留 performance-* 组,但关掉
# performance-enum-size —— 本项目的协议枚举底层类型**必须**精确等于线格式
# 的字段宽度(RNDIS 全是 LE32),按检查建议缩小会直接写坏线格式。
# * 并发正确性是本项目的核心风险,因此保留 concurrency-* 与 bugprone-* 全组。
# Trade-offs:
# * This project is a low-level driver dealing with kernel ABIs and USB wire
# formats, so reinterpret_cast, C-style arrays, bit manipulation and magic
# constants are inevitable; that rules out a batch of checks that do not
# suit systems programming.
# * The data paths demand zero allocation and no virtual-call overhead, so the
# performance-* group stays on -- except performance-enum-size: the
# underlying type of a protocol enum **must** exactly match the wire-format
# field width (RNDIS is all LE32), and shrinking it as the check suggests
# would corrupt the wire format outright.
# * Concurrency correctness is the project's core risk, so the concurrency-*
# and bugprone-* groups stay on in full.
---
Checks: >
bugprone-*,
Expand Down Expand Up @@ -52,7 +57,8 @@ HeaderFilterRegex: 'tetherkit/.*'
FormatStyle: file

CheckOptions:
# 命名约定(与 docs/DESIGN.md「代码规范」一节一致)
# Naming conventions (consistent with the "Code conventions" section of
# docs/DESIGN.md)
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
Expand Down Expand Up @@ -89,6 +95,7 @@ CheckOptions:
value: CamelCase
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
# 数据路径禁止隐式堆分配,放宽 else-after-return 便于早退风格
# The data path forbids implicit heap allocation; relaxing else-after-return
# keeps the early-return style usable
- key: readability-else-after-return.WarnOnUnfixable
value: 'false'
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ---- 构建产物 ----
# ---- build artifacts ----
build/
build-*/
out/
Expand All @@ -15,7 +15,7 @@ Testing/
compile_commands.json
_deps/

# ---- 编译中间产物 ----
# ---- compiler intermediates ----
*.o
*.a
*.so
Expand All @@ -33,21 +33,21 @@ _deps/
.Spotlight-V100
.Trashes

# ---- 编辑器 / IDE ----
# ---- editors / IDEs ----
.vscode/
.idea/
*.swp
*.swo
.cache/
.clangd/

# ---- GUI 打包产物 ----
# ---- GUI packaging artifacts ----
#
# dist/ 由 gui/Scripts/build-gui.sh 生成(TetherKit.app + helper),
# 是纯派生物,不进版本库。
# dist/ is produced by gui/Scripts/build-gui.sh (TetherKit.app + helper).
# It is a pure derivative and does not belong in version control.
dist/

# ---- 运行期产物 ----
# ---- runtime artifacts ----
*.log
*.pcap
/benchmark-results/
Expand Down
Loading
Loading