harmony

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package harmony assembles the HAP the harmonyos target builds: an ArkTS host whose Web serves the app's web build from the HAP's rawfile directory, with module.json and pack.info named for the app. docs/architecture/harmonyos.md holds the plan and what is not built.

A committed host (host/) is compiled with a fixed placeholder bundle, and Package replaces that placeholder byte for byte with an equally long name built from the app's id: the bytecode's length prefixes stay valid, so one host serves every app without an OpenHarmony SDK at build time. When the build machine has the SDK, CompileHost builds a host for the app's own bundle instead, and PackageWithHost assembles from it, keeping the id.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSDK = errors.New("no OpenHarmony SDK")

ErrNoSDK reports that the machine has no OpenHarmony SDK to build a host with. A caller that only wants the exact bundle name falls back to the committed host.

Functions

func Boot

func Boot() []byte

Boot returns the page that starts an app's module in the host's Web view: it loads wasm_exec.js and app.wasm from the same directory, and the ArkTS side it talks to is nsgoHarmony.

func BundleName

func BundleName(id string) (string, error)

BundleName returns an equally long, legal bundle name for id: the id, a fixed marker that keeps different ids apart, then zero padding. The result is a valid dot-separated name that never ends in a dot.

func BundleOf

func BundleOf(hap string) (string, error)

BundleOf returns the bundle a HAP names for its app, as -run needs it to start: Package pads it without the SDK and keeps the id with it.

func CompileHost

func CompileHost(ctx context.Context, bundle string) (string, error)

CompileHost builds a host for bundle with the SDK and returns the directory holding its files, from the user's cache once it is there. It returns ErrNoSDK when the machine cannot build one.

func Package

func Package(dir, site, name, bundle, version string, code int, perms []string) (string, error)

Package writes the HAP for an app into dir from the committed host and the web build in site, and returns its path. The committed host's bytecode names each module with the placeholder bundle; Package swaps it for an equally long name derived from the app's id, so one host serves every app without the SDK.

func PackageWithHost

func PackageWithHost(dir, site, hostDir, name, bundle, version string, code int, perms []string) (string, error)

PackageWithHost writes the HAP for an app into dir from a host built for the app's own bundle, as CompileHost builds one with the SDK: its bytecode already names the modules with the app's bundle, so only the app's version and label change and the installed bundle keeps the id.

Types

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer uses the SDK's HAP signing tool with the app's own material.

func OpenSigner

func OpenSigner(dir string, config Signing) (*Signer, error)

OpenSigner checks the signing configuration and locates the SDK tool. It reads no passwords, so doctor can check the profile without them.

func (*Signer) CheckProfile

func (s *Signer) CheckProfile(ctx context.Context, bundle string) error

CheckProfile verifies the signed profile with the SDK tool and checks its bundle name. It leaves device trust and provisioning checks to HarmonyOS.

func (*Signer) Sign

func (s *Signer) Sign(ctx context.Context, input, output string) error

Sign writes a signed HAP to output, which must differ from the input.

type Signing

type Signing struct {
	Keystore    string `yaml:"keystore"`
	KeyAlias    string `yaml:"key_alias"`
	Certificate string `yaml:"certificate"`
	Profile     string `yaml:"profile"`
}

Signing names the AppGallery Connect materials for a HarmonyOS HAP. Paths are relative to the app's nsgo.yaml unless absolute.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL