Skip to content

Commit 8e2c804

Browse files
committed
Update CODEBUDDY.md.
1 parent a0c34d1 commit 8e2c804

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

.codebuddy/CODEBUDDY.md

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to CodeBuddy Code when working with code in this rep
88

99
libpag is a real-time rendering library for PAG (Portable Animated Graphics) files. It renders vector and raster animations across iOS, Android, macOS, Windows, Linux, OpenHarmony, and Web platforms.
1010

11-
### Key Directories
11+
### Source Structure
1212

1313
| Directory | Purpose |
1414
|-----------|---------|
@@ -20,6 +20,8 @@ libpag is a real-time rendering library for PAG (Portable Animated Graphics) fil
2020
| `test/src/` | Google Test-based test cases |
2121
| `third_party/tgfx/` | GPU abstraction layer (OpenGL, Metal, Vulkan) |
2222

23+
File extensions: `.h` (headers), `.cpp` (implementation), `.mm` (Objective-C++). Source files are auto-collected via `file(GLOB)` - no CMake changes needed for new files.
24+
2325
### Core Classes
2426

2527
- **PAGFile**: Load and manage PAG animation files
@@ -53,34 +55,34 @@ npm install -g depsync
5355
depsync
5456
```
5557

56-
### Build and Run Tests
57-
58-
```bash
59-
mkdir build && cd build
60-
cmake -DPAG_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug ..
61-
cmake --build . --target PAGFullTest -- -j 12
62-
./PAGFullTest
63-
```
58+
### Build Verification
6459

65-
### Run Specific Test
60+
After modifying code, use this command to verify compilation. Must pass `-DPAG_BUILD_TESTS=ON` to enable ALL modules (layers, svg, pdf, etc.).
6661

6762
```bash
68-
./PAGFullTest --gtest_filter="TestSuiteName.TestName"
63+
cmake -DPAG_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -B cmake-build-debug
64+
cmake --build cmake-build-debug --target PAGFullTest -- -j 12
6965
```
7066

71-
### Code Formatting
72-
67+
### Code Formatting (REQUIRED before commit)
7368
```bash
7469
./codeformat.sh
7570
```
71+
Run this before every commit. Ignore any error output - the script completes formatting regardless of reported errors.
7672

77-
Run before committing. Ignore output errors - the formatting completes regardless.
7873

7974
## Testing
8075

8176
- Location: `/test/src/*Test.cpp`, based on Google Test framework
8277
- Test code can access all private members via compile flags (no friend class needed)
8378

79+
### Run Tests
80+
```bash
81+
./cmake-build-debug/PAGFullTest # Run all tests
82+
./cmake-build-debug/PAGFullTest --gtest_filter=CanvasTest.drawRect # Run specific test
83+
./cmake-build-debug/PAGFullTest --gtest_filter=Canvas* # Run pattern match
84+
```
85+
8486
### Screenshot Tests
8587

8688
- Use `Baseline::Compare(pixels, key)` where key format is `{folder}/{name}`, e.g., `PAGSurfaceTest/Mask`
@@ -92,15 +94,4 @@ Run before committing. Ignore output errors - the formatting completes regardles
9294
- To accept screenshot changes, copy `test/out/version.json` to `test/baseline/`, **but MUST satisfy both**:
9395
- Use `version.json` output from running ALL test cases in `PAGFullTest`, never use partial test output
9496
- User explicitly confirms accepting all screenshot changes
95-
- `UpdateBaseline` or `update_baseline.sh` syncs `test/baseline/version.json` to `.cache/` and generates local baseline cache. CMake warns when version.json files differ. **NEVER run this command automatically**
96-
97-
## Key CMake Options
98-
99-
- `-DPAG_BUILD_TESTS=ON`: Enable test targets (required for full module compilation)
100-
- `-DCMAKE_BUILD_TYPE=Debug`: Debug build with profiling enabled
101-
102-
## File Conventions
103-
104-
- Headers: `.h`, Implementation: `.cpp`, Objective-C++: `.mm`
105-
- Test files: `*Test.cpp` in `/test/src/`
106-
- Source files auto-collected via `file(GLOB)` - no CMake changes needed for new files
97+
- `UpdateBaseline` or `update_baseline.sh` syncs `test/baseline/version.json` to `.cache/` and generates local baseline cache. CMake warns when version.json files differ. **NEVER run this command automatically**

.codebuddy/rules/Rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ provider:
2020
- 变量命名避免缩写,简短且语义明确
2121
- 变量声明时一律赋初始值(即使是 `={}`),智能指针初始值使用 nullptr。
2222
- 避免 lambda 表达式,改用显式方法或函数
23+
- CPP 文件里的函数实现顺序与头文件中定义的顺序尽可能一致
2324
- `include/` 目录 API 需详细注释含参数描述,其他公开方法一段话描述主要功能,私有方法不加注释
2425
- 函数内代码不加行注释,除非只看代码无法理解设计意图
2526
- 未明确的规范,模仿项目已有风格

0 commit comments

Comments
 (0)