English | 简体中文
This document is for contributors who modify AOPD compiler code, Flutter tool integration, or the example app's AOP demonstrations.
Use the root check script for normal development:
dart bin/check.dartUse the full check after compiler changes or before publishing:
dart bin/check.dart --full--full performs the clean example rebuild path, which matters after editing
compiler/.
AOPD provides a source-level debug entrypoint at bin/debug_server.dart. It
starts AOPD's compiler/frontend_server/server.dart directly, using arguments
derived from the latest example/ Flutter build.
Run dependency resolution for both the root package and the compiler workspace:
dart pub get
cd compiler
dart pub get
cd ..
cd example
flutter pub get
cd ..debug_server.dart reuses the latest Flutter build hash directory and depfile.
Create those files first:
cd example
flutter build apk --debug
cd ..If you only changed AOPD compiler code, clean the example before rebuilding:
cd example
flutter clean
flutter pub get
flutter build apk --debug
cd ..Run the debug entrypoint with the compiler package config:
dart --packages=compiler/.dart_tool/package_config.json bin/debug_server.dart exampleThe custom package config is required. Without it, the Dart VM cannot resolve
workspace packages such as frontend_server, kernel, vm, and front_end.
The script prints:
- the detected Flutter SDK root;
- the build hash directory;
- the depfile path;
- the full frontend server argument list.
It also deletes a stale app.dill before starting so the run forces a fresh AOP
compile.
The repository includes .vscode/launch.json with:
Debug debug_server.dart (example)
That launch config:
- runs
bin/debug_server.dart; - sets
cwdtoexample/; - passes
--packages=<repo>/compiler/.dart_tool/package_config.json; - passes
exampleas the demo project argument.
Set breakpoints in files such as:
compiler/frontend_server/server.dartcompiler/frontend_server/aopd_frontend_compiler.dartcompiler/transformer/aopd_flutter_target.dartcompiler/transformer/aop_transformer.dartcompiler/transformer/rewriters/*.dart
After a debug compile or normal example build, dump the kernel text:
dart bin/dump.dartUseful markers:
PointCut::proceedproceedClosureaopLocation$creationLocationAopd_- aspect class names such as
AutoAnalyticsAspectandPerformanceAspect
Validate the expected markers:
dart bin/validate_example_dill.dartFlutter's build system tracks the app's Dart sources, package config, and engine
artifacts. It does not track AOPD's compiler/ sources. If you edit only
compiler/, Flutter can decide the app kernel step is already up to date and
skip the compile where AOPD would run.
Practical rule:
cd example
flutter clean
flutter pub get
flutter testdart bin/check.dart --full performs this clean path automatically.
When moving to a new Flutter SDK:
- Port the AOPD hook files under
packages/flutter_tools/lib/src/aop/. - Re-apply the compile/build target call-site changes.
- Delete
bin/cache/flutter_tools.stampin the Flutter SDK. - Run an AOPD-enabled app and confirm the log shows the app-local snapshot path.
- Regenerate
flutter_tools.patchfrom the Flutter SDK worktree.
compiler/pkg/* is an upstream SDK mirror. Do not store AOP-specific patches in
it.
When upgrading:
- Identify the Dart SDK revision used by the target Flutter SDK.
- Replace mirrored packages under
compiler/pkg/from that SDK revision. - Keep
compiler/pkg/*pristine. - Update
compiler/pubspec.yamldependency_overridesif upstream package names change. - Run dependency resolution in
compiler/. - Fix compatibility issues in AOPD-owned files under
compiler/. - Rebuild an app-local frontend server snapshot and validate the example app.
English | 简体中文
这份文档面向修改 AOPD compiler、Flutter tool 集成,或 example app AOP demo 的贡献者。
日常开发使用根目录检查脚本:
dart bin/check.dart修改 compiler 后或发布前使用完整检查:
dart bin/check.dart --full--full 会走干净的 example 重建路径。修改 compiler/ 后这点很重要。
AOPD 提供了源码级调试入口:bin/debug_server.dart。它会直接启动 AOPD 的
compiler/frontend_server/server.dart,并从最近一次 example/ Flutter build 中复用
编译参数。
先在根 package、compiler workspace 和 example 中解析依赖:
dart pub get
cd compiler
dart pub get
cd ..
cd example
flutter pub get
cd ..debug_server.dart 会复用最新的 Flutter build hash 目录和 depfile。先创建这些文件:
cd example
flutter build apk --debug
cd ..如果只改了 AOPD compiler 代码,重建前先 clean example:
cd example
flutter clean
flutter pub get
flutter build apk --debug
cd ..使用 compiler package config 运行调试入口:
dart --packages=compiler/.dart_tool/package_config.json bin/debug_server.dart example这个 package config 是必须的。没有它,Dart VM 无法解析 frontend_server、kernel、
vm、front_end 等 workspace package。
脚本会打印:
- 检测到的 Flutter SDK root;
- build hash 目录;
- depfile 路径;
- 完整 frontend server 参数。
启动前它也会删除旧的 app.dill,强制这次运行重新执行 AOP 编译。
仓库里已经包含 .vscode/launch.json:
Debug debug_server.dart (example)
这个 launch config 会:
- 运行
bin/debug_server.dart; - 将
cwd设为example/; - 传入
--packages=<repo>/compiler/.dart_tool/package_config.json; - 将
example作为 demo 工程参数。
常用断点位置:
compiler/frontend_server/server.dartcompiler/frontend_server/aopd_frontend_compiler.dartcompiler/transformer/aopd_flutter_target.dartcompiler/transformer/aop_transformer.dartcompiler/transformer/rewriters/*.dart
调试编译或正常 example build 后,可以 dump kernel 文本:
dart bin/dump.dart常用搜索标记:
PointCut::proceedproceedClosureaopLocation$creationLocationAopd_- aspect class 名称,比如
AutoAnalyticsAspect、PerformanceAspect
验证关键织入标记:
dart bin/validate_example_dill.dartFlutter build system 追踪的是 app Dart 源码、package config 和 engine artifacts。它不追踪
AOPD 的 compiler/ 源码。如果你只改 compiler/,Flutter 可能认为 app kernel step
已经是最新的,从而跳过真正会运行 AOPD 的编译步骤。
实用规则:
cd example
flutter clean
flutter pub get
flutter testdart bin/check.dart --full 会自动走这条 clean 路径。
迁移到新的 Flutter SDK 时:
- 移植
packages/flutter_tools/lib/src/aop/下的 AOPD hook 文件。 - 重新应用 compile/build target 调用点改动。
- 删除 Flutter SDK 中的
bin/cache/flutter_tools.stamp。 - 运行启用 AOPD 的 app,确认日志显示 app 本地 snapshot 路径。
- 从 Flutter SDK worktree 重新生成
flutter_tools.patch。
compiler/pkg/* 是上游 SDK 镜像。不要在里面保存 AOP 专属 patch。
升级时:
- 确认目标 Flutter SDK 使用的 Dart SDK revision。
- 用该 SDK revision 的源码替换
compiler/pkg/下的镜像 package。 - 保持
compiler/pkg/*干净。 - 如果上游 package 名称变化,更新
compiler/pubspec.yaml的dependency_overrides。 - 在
compiler/中解析依赖。 - 修复
compiler/下 AOPD 自有文件的兼容性问题。 - 重建 app 本地 frontend server snapshot,并验证 example app。