feat: scaffold --target harmonyos[-simulator] (PR A for #113)#121
Open
proggeramlug wants to merge 1 commit intomainfrom
Open
feat: scaffold --target harmonyos[-simulator] (PR A for #113)#121proggeramlug wants to merge 1 commit intomainfrom
proggeramlug wants to merge 1 commit intomainfrom
Conversation
PR A for #113 — additive scaffolding only. Every edit is a new arm in an existing match, unreachable until the user passes --target harmonyos or --target harmonyos-simulator. No behavior change for any other target. * rust_target_triple / resolve_target_triple: harmonyos → aarch64-unknown-linux-ohos, harmonyos-simulator → x86_64-unknown-linux-ohos (DevEco emulator). * find_library: _harmonyos suffix convention next to the perry binary, mirroring _watchos / _ios / _tvos. * find_ui_library: libperry_ui_harmonyos.a (crate lands in PR C). * parse_native_library_manifest target_key → "harmonyos" so package.json authors can declare perry.nativeLibrary.targets.harmonyos. * UI-crate selector → perry-ui-harmonyos. * is_mobile feature filter includes harmonyos[-simulator] so --features plugins is stripped (dlopen isn't practical under HarmonyOS's sandbox). * __platform__ = 7 (HarmonyOS); ordered before the linux arm since the OHOS triple is *-unknown-linux-ohos — naive contains("linux") would misclassify. Platform enum is deliberately untouched. publish.rs:627 and run.rs:1687-1802 exhaustively match every variant; adding one would force premature behavior decisions (what does `perry publish --platform harmonyos` do?) that belong with PR B alongside the HAP bundler. `compile` takes Option<String>, so --target harmonyos works without the enum change. Verified: * cargo build --release -p perry -p perry-codegen — clean * perry compile hi.ts (default host) — byte-equivalent output, runs * perry compile hi.ts --target harmonyos — fails fast with "Could not find libperry_runtime.a (for target harmonyos)"; search paths include target/aarch64-unknown-linux-ohos/release/... and the _harmonyos suffix, proving both new arms are live. rustc additionally emits "consider: rustup target add aarch64-unknown-linux-ohos", confirming the triple is upstream-recognized (Tier 2 with host tools).
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of three PRs tracking HarmonyOS NEXT support (#113). Pure scaffolding — every change is an additive arm in an existing match, unreachable unless
--target harmonyosor--target harmonyos-simulatoris passed. No behavior change for any other target.What's in scope
rust_target_triple/resolve_target_triple:harmonyos→aarch64-unknown-linux-ohos,harmonyos-simulator→x86_64-unknown-linux-ohos(DevEco emulator).find_librarycandidate suffix (_harmonyos) mirroring the_watchos/_ios/_tvosconvention for npm-distribution library naming.find_ui_library→libperry_ui_harmonyos.a(the crate lands in PR C).parse_native_library_manifesttarget_key→"harmonyos"sopackage.jsonauthors can declareperry.nativeLibrary.targets.harmonyos.perry-ui-harmonyos.is_mobilefeature filter includesharmonyos[-simulator]so--features pluginsis stripped (dlopen isn't practical under HarmonyOS's sandbox).__platform__ = 7reserved for HarmonyOS. Ordered before thelinuxarm in theif t.contains("ohos")chain because the OHOS triple is*-unknown-linux-ohos— naivecontains(\"linux\")would misclassify it as 4.Deliberately not in scope
Platformenum variant:publish.rs:627andrun.rs:1687-1802exhaustively match every variant. Adding one forces premature behavior decisions (what doesperry publish --platform harmonyosdo? what doesperry run --target harmonyosdo?). Those land with PR B.3 alongside the HAP bundler.compiletakesOption<String>, so--target harmonyosworks today without this change..sooutput mode, NAPI entry, ArkTS shim, HAP bundler, OHOS SDK detection, linker invocation — PR B (already in progress onharmony-osbranch).perry-ui-harmonyoscrate + TS→ArkTS emitter — PR C.Verification
cargo build --release -p perry -p perry-codegen— clean.perry compile hi.ts(no target) — byte-equivalent output, runs.perry compile hi.ts --target harmonyos— fails with clear errorCould not find libperry_runtime.a (for target \"harmonyos\"), search paths includetarget/aarch64-unknown-linux-ohos/release/...and the_harmonyossuffix — proving both new arms are wired.rustcadditionally suggestsrustup target add aarch64-unknown-linux-ohos, confirming the triple is upstream-recognized (Tier 2, host tools).rustup target add {aarch64,x86_64}-unknown-linux-ohosboth succeed on stable — no nightly needed (unlike watchOS/tvOS).Test plan
--target {macos,ios,android,watchos,tvos,linux,windows,web}produce byte-equivalent output tomain--target harmonyosfails with the expected "runtime not found" error chain