Repository navigation
Description
Context
cmd/nsgo/harmony/host/build.sh rebuilds the committed HAP host. It needs hvigorw on PATH and OHOS_BASE_SDK_HOME pointing at an API 26 SDK. Every change to cmd/nsgo/harmony/templates needs that rebuild, or TestCommittedHostMatchesTemplates fails. Several changes have been held back or split because no build machine could run it:
- HarmonyOS: the committed host is older than its templates #907: the committed host fell behind its templates.
- harmonyos: tint canvas images and rebuild the committed host #2003: HarmonyOS image tinting was taken out of feat(canvas): add per-draw image tinting #1200.
- The HarmonyOS halves of Canvas: Drawing.DrawAtlas, many images from one source in one op #1103, Phones: immersive full screen, hiding the status and navigation bars #1124, Canvas: nearest-neighbour image sampling for pixel art #1209 and Canvas: Drawing.DrawVertices for textured, colored triangle meshes #1211.
The script's header names the SDK, but nothing says which hvigor works with it or how to get it. The usual sources fail:
- Command Line Tools 6.1.1 ships hvigor 6.24.2 and an API 24 SDK. With the templates' string
compileSdkVersion: "26.0.0"in OpenHarmony mode, it fails with00306042 Specification Limit Violation. - DevEco Studio's hvigor 6.22.9 fails the same way.
- The public SDK's
darwinpackages are x86_64 only, so on Apple siliconrestoolfails withspawn Unknown system error -86unless Rosetta is installed.
A recipe that works
Built on Ubuntu x86_64. The resulting module.json and pack.info are byte-identical to the previously committed host.
- SDK:
https://repo.huaweicloud.com/openharmony/os/7.0-Release/ohos-sdk-windows_linux-public.tar.gz. Check its.sha256, then unzipohos-sdk/linux/{ets,js,native,previewer,toolchains}-linux-x64-26.0.0.38-Beta.zip.- Put them in
$OHOS_BASE_SDK_HOME/26.0.0/. The directory must be named26.0.0, not26: sdkmanager-common expects<root>/<fullApiVersion>/<path>and otherwise reports "The SDK management mode has changed". - All five components are needed. If one is missing, hvigor tries to download it and stops with "The SDK license agreement is not accepted".
- The public archive labels these components
releaseType: Beta. That label ends up asapiReleaseType: Betain the host'smodule.jsonandpack.info, where the committed host hasRelease. ChangingreleaseTypetoReleasein the fiveoh-uni-package.jsonfiles reproduces the committed metadata.
- Put them in
- hvigor:
npm install @ohos/[email protected] @ohos/[email protected] --@ohos:registry=https://repo.harmonyos.com/npm/. Both packages bundle their own dependencies.- Lay them out as Command Line Tools does:
hvigor/hvigor,hvigor/hvigor-ohos-pluginandhvigor/bin, plus thebin/hvigorwwrapper. - Set
NODE_PATHto thenode_modulesthat holds both. If they are separate copies, hvigor fails with "The root node is not yet available for build".
- Lay them out as Command Line Tools does:
PATHneeds Node 18 or newer and a JDK;PackageHaprunsjava. Thensh cmd/nsgo/harmony/host/build.sh.
Repeated builds give byte-identical .abc files. Rebuilding an unchanged main reproduces the committed module.json, pack.info and template digest. Its .abc files differ from the committed ones in about 2 KB, which looks like a different hvigor-arkts-compose build.
Proposal
- Document the toolchain in
docs/architecture/harmonyos.mdand inbuild.sh's header: SDK source and layout, hvigor 6.26.x fromrepo.harmonyos.com, thereleaseTypenote, and Linux x86_64 or Rosetta. - Better: add a workflow like
android-runtime.ymlthat rebuilds the host ondepot-ubuntu-24.04whencmd/nsgo/harmony/templates/**changes, so contributors no longer need the toolchain.
Acceptance
- A contributor can rebuild the host from the docs alone.
- Or a template change on a PR gets its host rebuilt by CI, and
TestCommittedHostMatchesTemplatespasses without a local SDK.
Activity
houko commentedon Nov 23, 2026
Implemented in PR #2190: #2190
The HarmonyOS host rebuild recipe now documents the API 26 SDK layout, hvigor versions, release metadata adjustment, Node/JDK requirements, and x86_64/Rosetta constraint.
go tool nsgo checkpassed locally.