Repository navigation
build: generate the cross-platform constants and binding tables from one source - #683
Conversation
…one source Values every platform must agree on were copied by hand into C++, Java, ArkTS and JS and held together by regex checkers, and several groups had no guard at all (state operation codes, archive patch types, round statuses, storage keys, the ABI and vendored-source lists). scripts/contract.ts is now the single source of those values, and scripts/generate-contract.ts rewrites every `<generated:NAME>` region from it: error codes (C++, Java, ArkTS, src/error.ts), archive limits, install record constants, the query budget, state operations, archive patch types (C++, Java and ArkTS task types, iOS PushyType), the Android/Harmony storage keys, the round statuses, the Android ABIs and the vendored decoder sources (Android.mk, CMakeLists.txt, test-patch-core.sh, check-packlist.js). Binding tables are generated from the calling-side declarations: the Harmony PUSHY_METHODS table and the old-architecture NativePushySpec from src/NativePushy.ts, the JNI registration table and prototypes from the Java `native` declarations, the NAPI exports from NativePatchCore.ts; the contract only names the C++ function behind each. `bun lint` runs the generator with --check instead of check-constant-parity.js (removed); check-native-spec-parity.js keeps only what no generator can write, the per-platform implementations. Generated values are byte-identical to the hand-kept ones (the JNI table included); the method table is reordered to spec order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
A comment line inside the backslash continuation ended the assignment and turned the source lines into recipe lines (ndk-build: recipe commences before first target). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ource error_codes.h is generated from scripts/contract.ts since #683; the reset contract comment this PR changed by hand belongs in the source, or the generator's --check fails lint once this lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the state is reset (#671) * test(cpp): compile the shared cores with each platform's release flags The unit tests build cpp/patch_core and cpp/update_flow_core with the host c++ (on CI g++/libstdc++), C++17, RTTI and asserts on. No shipped binary is built that way: Android uses -fno-rtti -fexceptions, iOS compiles with the C++20 React Native selects, and every release defines NDEBUG. A construct only one platform rejects first failed in that platform's build. scripts/test-core-platform-flags.sh syntax-checks every core source with the three release flag sets under -Werror, preferring clang (the compiler of every shipped binary). test.yml's C++ job runs it; `bun run test:core-flags` locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(test): run the core flag check when a platform's flag file changes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ios): resolve resetToPackagedBundle once the state is reset Android and HarmonyOS settle the reset promise once the reset state is persisted and delete the downloaded versions best-effort afterwards; iOS waited for that cleanup and rejected with RESET_FAILED when it failed (its comment claimed Android parity). Align iOS with the other two: the reset is complete once the state is (the next launch resolves to the packaged bundle), and a directory a failed delete leaves behind is unreferenced, so the regular cleanup removes it later. Waiting instead would have put Android's and Harmony's reset behind an in-flight download on their serial queues. RESET_FAILED now means only that the reset state could not be persisted (error_codes.h, the client's doc comment); the purge-restore test asserts the new contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ios): pin that reset resolves even when its cleanup fails The cleanup stub now fails: the reset promise must still resolve, and the cleanup must still run. A reset that waited for the delete again rejects here (checked by restoring the previous behavior: reset_wins fails). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(contract): carry the new RESET_FAILED meaning in the contract source error_codes.h is generated from scripts/contract.ts since #683; the reset contract comment this PR changed by hand belongs in the source, or the generator's --check fails lint once this lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Bump package.json and harmony/pushy/oh-package.json5 together, with the bilingual release notes. Ships everything since 10.60.0: the shared native round engine (#673-#681), the cross-platform alignment and fixes (#664, #666, #671, #687, #688), the JS client fixes and split (#667, #684, #685), the bounded host prepareBundle (#669), the generated cross-platform contract (#683, #686) and the trimmed npm package (#670). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
架构审查"对等性改为单一来源生成"的第一个 PR。
为什么
跨端必须一致的值,原先是手抄到 C++ / Java / ArkTS / JS 几份,再靠正则检查器去对。盘点下来共 20 组,其中有好几组完全没有守卫:状态操作码、补丁类型枚举、宿主结果状态、存储键、ABI 列表、vendored 源文件列表。
怎么做
scripts/contract.ts是唯一来源。scripts/generate-contract.ts负责改写各文件里<generated:NAME>…</generated:NAME>标记之间的内容,共 36 个区块:src/error.tsPushyTypeAndroid.mk、CMakeLists.txt、test-patch-core.sh、check-packlist.jsPUSHY_METHODS和 oldarchNativePushySpec←src/NativePushy.tsjni_natives.h原型 ← Javanative声明NativePatchCore.tsbun lint改跑generate-contract.ts --check,有区块不是最新时报错并列出文件。check-constant-parity.js删除。check-native-spec-parity.js只保留生成器写不了的部分,即三端各自的实现是否存在。jniRegistration和 NAPI 导出两个测试保留,它们独立解码生成物做交叉验证。jni 测试去掉了写死的数量 19。scripts/contract.ts,然后运行bun run contract。生成出来的值与原先手写的逐字节一致,JNI 编码表也完全一致,所以
.so不需要重编。变化只有三处:PUSHY_METHODS改成按 spec 的顺序排列。jni_natives.h里的参数名统一成 snake_case。ARCHIVE_PATCH_TYPE_FULL常量,目前没有地方用。验证
bun run lint通过,bun test458 个用例全部通过。--check报错并指出文件;改 contract 里的一个值,所有副本一起变。.mm用 Pods 头文件做-fsyntax-only通过。pushy.cpp用 DevEco SDK 的 clang 编译通过。testReleaseUnitTest编译通过,单测全部通过。下一个 PR 做编码明文登记表:把散在各端的编码字面量和默认服务地址也收进同一来源。
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit