Skip to content

Add OHOS (OpenHarmony / HarmonyOS) platform support#2004

Open
jobor wants to merge 2 commits intomicrosoft:mainfrom
jobor:ohos
Open

Add OHOS (OpenHarmony / HarmonyOS) platform support#2004
jobor wants to merge 2 commits intomicrosoft:mainfrom
jobor:ohos

Conversation

@jobor
Copy link
Copy Markdown

@jobor jobor commented Apr 30, 2026

This adds the ohos identifier for the HamonyOS / OpenHarmony platform.

See microsoft/vcpkg#51302 and microsoft/vcpkg#51470

jobor and others added 2 commits April 2, 2026 14:06
Add OHOS as a recognized platform in vcpkg-tool:
- Platform expression identifier "ohos" maps to VCPKG_CMAKE_SYSTEM_NAME "OHOS"
- Toolchain file mapping for OHOS to scripts/toolchains/ohos.cmake
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class recognition of the ohos platform (OpenHarmony / HarmonyOS) within vcpkg’s platform expression evaluation and toolchain selection logic, enabling ports/triplets to target OHOS via VCPKG_CMAKE_SYSTEM_NAME=OHOS.

Changes:

  • Add ohos as a recognized platform-expression identifier and evaluate it via VCPKG_CMAKE_SYSTEM_NAME == "OHOS".
  • Route PreBuildInfo::toolchain_file() to scripts/toolchains/ohos.cmake when cmake_system_name is OHOS.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/vcpkg/platform-expression.cpp Adds ohos identifier parsing and evaluation based on VCPKG_CMAKE_SYSTEM_NAME.
src/vcpkg/commands.build.cpp Selects an OHOS-specific toolchain file when cmake_system_name is OHOS.

case Identifier::watchos: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "watchOS");
case Identifier::visionos:
return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "visionOS");
case Identifier::ohos: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "OHOS");
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new ohos identifier behavior isn’t covered by unit tests. Since this file already has Catch2 coverage for platform-expression identifiers, please add a test case that validates ohos evaluates true when VCPKG_CMAKE_SYSTEM_NAME is OHOS (and false for a non-OHOS value).

Copilot uses AI. Check for mistakes.
@BillyONeal
Copy link
Copy Markdown
Member

Do you have a screenshot or a photo of the end-to-end scenario working (e.g. vcpkg install zlib on OHOS)? We're generally happy to merge platforms someone is willing to add but because we don't know how to validate this ourselves and there are multiple parts like the toolchain that need to be in place for things to work. I think you covered all the pieces but if someone cares enough to add this hopefully they can actually try it :)

You might also want to write a PR adding this to the community supported documentation over in https://github.com/MicrosoftDocs/vcpkg-docs/blob/45b52d047aadf711d377f4e5ae6665282bb21876/vcpkg/concepts/supported-hosts.md?plain=1#L122

@jobor
Copy link
Copy Markdown
Author

jobor commented May 2, 2026

Do you have a screenshot or a photo of the end-to-end scenario working (e.g. vcpkg install zlib on OHOS)? We're generally happy to merge platforms someone is willing to add but because we don't know how to validate this ourselves and there are multiple parts like the toolchain that need to be in place for things to work. I think you covered all the pieces but if someone cares enough to add this hopefully they can actually try it :)

Sure, here's a screenshot of installing zlib with the arm64-ohos triplet:
Screenshot_20260502_121702

That's with exactly this branch.

If you want, I could also provide vcpkg installation logs from Qt's CI which covers much more libraries, albeit with a few modified ports.

You might also want to write a PR adding this to the community supported documentation over in https://github.com/MicrosoftDocs/vcpkg-docs/blob/45b52d047aadf711d377f4e5ae6665282bb21876/vcpkg/concepts/supported-hosts.md?plain=1#L122

Oh right! Done here: MicrosoftDocs/vcpkg-docs#575

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants