Skip to content
openharmony-rsPublic

About

FFI-Bindings for OpenHarmony

Topics

Resources

Contributing

Stars

30 stars

Watchers

3 watching

Forks

Repository files navigation

ohos-sys

FFI-bindings for the native API of OpenHarmony OS. See the documentation for a list of supported components. This crate is under active development, and not officially affiliated with OpenHarmony OS.

Status of the bindings

Here is an overview of the available C header directories in the OpenHarmony sysroot, and for which of them this crate already provides bindings. The API-level column denotes up to which api level the bindings have already been generated.

API name status API-level crate
AbilityKit ✅ 26 ohos-abilitykit-sys
BasicServicesKit ✅ 26 ohos-basic-services-kit-sys
Background Process Manager
ConnectivityKit
ContentEmbedKit
CryptoArchitectureKit ✅ 26 ohos-crypto-sys
DataProtectionKit
GameControllerKit
IPCKit ✅ 26 ohos-ipckit-sys
LocationKit ✅ 26 ohos-locationkit-sys
NotificationKit
TEEKit
accesstoken ✅ 26 ohos-accesstoken-sys
ace/xcomponent ✅ 26 xcomponent-sys
ark_runtime
arkui ✅ 26 arkui-sys
asset ✅ 26 ohos-asset-store-sys
bundle ✅ 26 ohos-libbundle-sys
database ✅ 26 [ohos-rdb-sys]
ddk
distributedhardware
ffrt
filemanagement
hiappevent ✅ 26 ohos-hiappevent-sys
hicollie
hid
hidebug
hilog ✅ 26 hilog-sys
hitrace ✅ 26 hitrace-sys
huks ✅ 26 ohos-huks-sys
info ✅ 26 ohos-deviceinfo-sys
inputmethod ✅ 26 ohos-ime-sys
mindspore
multimedia/av_session
multimedia/drm_framework
multimedia/image_effect
multimedia/image_framework ✅ 26 ohos-image-kit-sys
multimedia/media_library
multimedia/player_framework ✅ 26 ohos-media-sys
multimedia/video_processing_engine ✅ 26 ohos-video-processing-engine-sys
multimodalinput ✅ 26 ohos-input-sys
napi ✅ 26
native_buffer ✅ 26 ohos-window-sys
native_color_space_manager
native_display_soloist ✅ 26 ohos-native-display-soloist-sys
native_drawing ✅ 26 ohos-drawing-sys
native_effect
native_fence ✅ 26 ohos-window-sys
native_image ✅ 26 ohos-window-sys
native_vsync ✅ 26 ohos-vsync-sys
native_window ✅ 26 ohos-window-sys
network/netmanager ✅ 26 ohos-netmanager-sys
network/netstack ✅ 26 ohos-netstack-sys
network/netstack/net_ssl ✅ 26 ohos-net-ssl-sys
neural_network_runtime
ohaudio ✅ 26 ohaudio-sys
ohcamera
ohmidi
Pasteboard ✅ 26 ohos-pasteboard-sys
purgeable_memory ✅ 26 ohos-purgeable-memory-sys
qos ✅ 26 ohos-libqos-sys
rawfile ✅ 26 ohos-rawfile-sys
resourcemanager
sensors ✅ 26 ohos-sensors-sys
SCSI Peripherals
telephony
transient_task ✅ 26 ohos-transient-task-sys
Unified Data Management Framework(UDMF) ✅ 26 udmf-sys
usb
usb serial
web ✅ 26 arkweb-sys
window_manager ✅ 26 ohos-window-manager-sys

Development

The current bindings are generated with bindgen using scripts/generate_bindings.sh. Bindings are currently generated with the OpenHarmony SDK API level 26 (OpenHarmony 7.0), but with items added after API level 10 feature guarded behind api-XX features. This is handled automatically by the tool based on the documentation comments in the C header files.

Contributing

There are still quite a few OpenHarmony APIs missing. Feel free to contribute missing APIs, but be sure to adapt the script, so your bindings are reproducible! The OpenHarmony SDK can be downloaded from the release notes of the respective release, e.g. the 5.0.0 release notes. Navigate to the Acquiring Source Code from Mirrors section, select the Public SDK package for the standard system for your host Operating System (Windows / Linux / Mac) click download and optionally verify the SHA-256 checksum of the downloaded archive. Extract the archive to a suitable location. Please note that the <os_name> subfolder contains more archives. For the purpose of generating the bindings extracting the native archive is sufficient.

Once you have setup your local SDK, you should set the environment variable OHOS_SDK_NATIVE to /path/to/ohos-sdk/<your_host_os>/native. Afterwards you can run the script to generate the bindings and adapt it to incorporate new modules.

Please also check the following:

  • Preferably generate the bindings with libclang in C mode. However, if a header file is not C-compliant due to an issue of the OpenHarmony SDK, then setting libclang to C++ mode is fine.
  • Be sure to guard the new component behind a cargo feature and document the feature in Cargo.toml.

License

This crate is licensed under the Apache-2.0 license, matching the OpenHarmony OS SDK.

About

FFI-Bindings for OpenHarmony

Topics

Resources

Contributing

Stars

30 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages