Openharmony build

From openharmonyinsight/openharmony-skills · View interactive version

Openharmony build is an AI agent skill from the GitHub repository openharmonyinsight/openharmony-skills. Use for OpenHarmony build execution and diagnosis, including 编译OpenHarmony/完整代码/测试/SDK/host/最小模拟器/全量模拟器/部件独立编译/测试列表, plus full product builds, targeted component/test builds, fast rebuilds, hb independent builds, and build.log failure analysis.

How to use this skill

Skill file

OpenHarmony Build Skill

Use this skill for OpenHarmony build execution, targeted build verification, and build-log diagnosis. Keep context small: start here, then load only the reference that matches the task.

<skill-dir> means the directory containing this SKILL.md.

Core Rules

Never / Ask Before

Find Root

Use this root test:

find_oh_root() {
    local dir="${1:-$PWD}"
    while [[ "$dir" != "/" ]]; do
        if [[ -f "$dir/.gn" && -f "$dir/build.sh" ]]; then
            echo "$dir"
            return 0
        fi
        dir="$(dirname "$dir")"
    done
    return 1
}

Command Selection

Default full build:

./build.sh --export-para PYCACHE_ENABLE:true --product-name rk3568 --ccache

Targeted build:

./build.sh --export-para PYCACHE_ENABLE:true --product-name <product> --build-target <target> --ccache

Special products:

Read references/build-commands.md for the full command matrix, products, targets, SDK/host/emulator notes, and fast-rebuild examples.

Reference routing:

Fast Rebuild

Use --fast-rebuild only when build configuration did not change. Do not use it after edits to BUILD.gn, *.gni, product config, dependency metadata, or first-time output generation.

Helper:

bash <skill-dir>/scripts/check_fast_rebuild.sh 30 "$OH_ROOT"

Independent Component Build

Use for "部件独立编译", "独立编译部件", or explicit hb build requests.

command -v hb
hb build <component-name> -i
hb build <component-name> -t

Rules:

Reference routing: for hb independent builds, always read references/independent-build.md; do not load references/test-list-builds.md unless the task is specifically about target-list builds.

Test Builds

For ACE Engine development, prefer:

./build.sh --export-para PYCACHE_ENABLE:true --product-name rk3568 --build-target ace_engine_test --ccache

Build all unit tests only when requested or required:

./build.sh --export-para PYCACHE_ENABLE:true --product-name rk3568 --build-target unittest --ccache

For target-list builds:

bash <skill-dir>/scripts/build_test_list.sh rk3568 "$OH_ROOT"

Reference routing: for target-list builds, read references/test-list-builds.md; do not load references/independent-build.md unless the target-list run uses hb build.

Success Check

A successful build usually has:

Use exit code as the first signal. Check artifacts only when the user needs artifact confirmation.

Failure Analysis

Always start from the primary log:

Use scripts before broad manual searching:

bash <skill-dir>/scripts/resolve_build_log.sh <product> "$OH_ROOT"
bash <skill-dir>/scripts/find_recent_errors.sh <product> "$OH_ROOT"
bash <skill-dir>/scripts/analyze_build_error.sh <product> "$OH_ROOT"

For hb build failures, pass standard as the product:

bash <skill-dir>/scripts/find_recent_errors.sh standard "$OH_ROOT"
bash <skill-dir>/scripts/analyze_build_error.sh standard "$OH_ROOT"

Reference routing:

Bundled Resources

Scripts:

References:

Do not load README.md or examples/example-workflow.md during normal skill execution; they are repository-facing summaries, not runtime instructions.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.