Skip to content

HarmonyOS: make the committed host rebuildable (toolchain recipe, or rebuild it in CI) #2015

Closed

Description

@houko

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:

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 with 00306042 Specification Limit Violation.
  • DevEco Studio's hvigor 6.22.9 fails the same way.
  • The public SDK's darwin packages are x86_64 only, so on Apple silicon restool fails with spawn Unknown system error -86 unless 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.

  1. SDK: https://repo.huaweicloud.com/openharmony/os/7.0-Release/ohos-sdk-windows_linux-public.tar.gz. Check its .sha256, then unzip ohos-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 named 26.0.0, not 26: 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 as apiReleaseType: Beta in the host's module.json and pack.info, where the committed host has Release. Changing releaseType to Release in the five oh-uni-package.json files reproduces the committed metadata.
  2. 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-plugin and hvigor/bin, plus the bin/hvigorw wrapper.
    • Set NODE_PATH to the node_modules that holds both. If they are separate copies, hvigor fails with "The root node is not yet available for build".
  3. PATH needs Node 18 or newer and a JDK; PackageHap runs java. Then sh 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.md and in build.sh's header: SDK source and layout, hvigor 6.26.x from repo.harmonyos.com, the releaseType note, and Linux x86_64 or Rosetta.
  • Better: add a workflow like android-runtime.yml that rebuilds the host on depot-ubuntu-24.04 when cmd/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 TestCommittedHostMatchesTemplates passes without a local SDK.

Activity

  1. self-assigned this
    on Nov 23, 2026
  2. houko commented on Nov 23, 2026

    @houko
    CollaboratorAuthor

    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 check passed locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions