diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..a6071fd
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,56 @@
+name: CI
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+
+jobs:
+ code_quality:
+ name: Code Quality
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ - run: cargo fmt --check
+ - run: cargo clippy
+ build-toolchains:
+ strategy:
+ matrix:
+ toolchain: [stable, beta, nightly]
+ name: Build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ matrix.toolchain }}
+ - run: cargo build
+ name: Build default features
+ - run: cargo build --all-features
+ name: Build all features
+ api_feature_levels:
+ strategy:
+ matrix:
+ # Add API level 12, once APIs have been added.
+ api_level: ["api-10", "api-11"]
+ name: Build with API feature levels
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ - run: cargo build --features ${{ matrix.api_level }} --features all-components
+ name: Build with API features
+ api_minimal_featueres:
+ strategy:
+ matrix:
+ api_level: ["api-10"]
+ component: ["drawing", "hilog", "napi", "native_buffer", "native_window", "xcomponent"]
+ name: Build with minimal features
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ - run: cargo build --features ${{ matrix.api_level }} --features ${{ matrix.component }}
+ name: Build minimal features
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 7580466..e4e0178 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,11 +5,13 @@ edition = "2021"
description = "Bindings to the native API of OpenHarmony OS"
license = "Apache-2.0"
repository = "https://github.com/openharmony-rs/ohos-sys"
+keywords = ["OpenHarmony", "HarmonyOS", "ffi"]
[dependencies]
document-features = { version = "0.2", optional = true }
[features]
+default = ["api-10"]
## Enables bindings to `native_drawing`
drawing = []
## Enables bindings to `hilog`
@@ -22,14 +24,25 @@ native_buffer = []
native_window = []
## Enables bindings to `native_xcomponent`
xcomponent = []
+## Enables all components listed above. Orthogonal to `api-XX` features.
+all-components = [
+ "drawing",
+ "hilog",
+ "napi",
+ "native_buffer",
+ "native_window",
+ "xcomponent"]
#! ### OpenHarmony API level
#! This crate by default exposes bindings for API-level 10.
#! Optionally enable one of the `api-*` features to get access to bindings for newer
#! OpenHarmony versions.
+## Enables bindings for OpenHarmony API-level 10. Enabled by default.
+## Note: this crate is empty if this feature is not selected.
+api-10 = []
## Enables bindings for OpenHarmony API-level 11
-api-11 = []
+api-11 = ["api-10"]
## Enables bindings for OpenHarmony API-level 12
api-12 = ["api-11"]
## Document available features when building the documentation
@@ -37,3 +50,4 @@ document-features = ["dep:document-features"]
[package.metadata.docs.rs]
features = ["document-features"]
+targets = ["aarch64-unknown-linux-ohos", "armv7-unknown-linux-ohos", "x86_64-unknown-linux-ohos"]
\ No newline at end of file
diff --git a/src/native_window/api11_additions.rs b/src/native_window/api11_additions.rs
index e891483..1674fae 100644
--- a/src/native_window/api11_additions.rs
+++ b/src/native_window/api11_additions.rs
@@ -14,13 +14,13 @@ pub struct OH_NativeBuffer {
extern "C" {
/** @brief Creates a OHNativeWindowBuffer instance.
- A new OHNativeWindowBuffer instance is created each time this function is called.
+ A new OHNativeWindowBuffer instance is created each time this function is called.
- @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
- @param nativeBuffer Indicates the pointer to a native buffer. The type is OH_NativeBuffer*.
- @return Returns the pointer to the OHNativeWindowBuffer instance created.
- @since 11
- @version 1.0*/
+ @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
+ @param nativeBuffer Indicates the pointer to a native buffer. The type is OH_NativeBuffer*.
+ @return Returns the pointer to the OHNativeWindowBuffer instance created.
+ @since 11
+ @version 1.0*/
pub fn OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(
nativeBuffer: *mut OH_NativeBuffer,
) -> *mut OHNativeWindowBuffer;
@@ -29,14 +29,14 @@ extern "C" {
extern "C" {
/** @brief Get the last flushed OHNativeWindowBuffer from a OHNativeWindow instance.
- @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
- @param window Indicates the pointer to a OHNativeWindow instance.
- @param buffer Indicates the pointer to a OHNativeWindowBuffer pointer.
- @param fenceFd Indicates the pointer to a file descriptor handle.
- @param matrix Indicates the retrieved 4*4 transform matrix.
- @return Returns an error code, 0 is success, otherwise, failed.
- @since 11
- @version 1.0*/
+ @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
+ @param window Indicates the pointer to a OHNativeWindow instance.
+ @param buffer Indicates the pointer to a OHNativeWindowBuffer pointer.
+ @param fenceFd Indicates the pointer to a file descriptor handle.
+ @param matrix Indicates the retrieved 4*4 transform matrix.
+ @return Returns an error code, 0 is success, otherwise, failed.
+ @since 11
+ @version 1.0*/
pub fn OH_NativeWindow_GetLastFlushedBuffer(
window: *mut OHNativeWindow,
buffer: *mut *mut OHNativeWindowBuffer,
@@ -44,4 +44,3 @@ extern "C" {
matrix: *mut f32,
) -> i32;
}
-
diff --git a/src/xcomponent/api11_additions.rs b/src/xcomponent/api11_additions.rs
index 93560b5..ced804a 100644
--- a/src/xcomponent/api11_additions.rs
+++ b/src/xcomponent/api11_additions.rs
@@ -22,11 +22,11 @@ pub struct OH_NativeXComponent_ExpectedRateRange {
extern "C" {
/** @brief Set the Expected FrameRateRange.
- @param component Indicates the pointer to this OH_NativeXComponent instance.
- @param callback Indicates the pointer to a expected rate range.
- @return Returns the status code of the execution.
- @since 11
- @version 1.0*/
+ @param component Indicates the pointer to this OH_NativeXComponent instance.
+ @param callback Indicates the pointer to a expected rate range.
+ @return Returns the status code of the execution.
+ @since 11
+ @version 1.0*/
pub fn OH_NativeXComponent_SetExpectedFrameRateRange(
component: *mut OH_NativeXComponent,
range: *mut OH_NativeXComponent_ExpectedRateRange,
@@ -35,11 +35,11 @@ extern "C" {
extern "C" {
/** @brief Registers a callback for this OH_NativeXComponent instance.
- @param component Indicates the pointer to this OH_NativeXComponent instance.
- @param callback Indicates the pointer to a onFrame callback.
- @return Returns the status code of the execution.
- @since 11
- @version 1.0*/
+ @param component Indicates the pointer to this OH_NativeXComponent instance.
+ @param callback Indicates the pointer to a onFrame callback.
+ @return Returns the status code of the execution.
+ @since 11
+ @version 1.0*/
pub fn OH_NativeXComponent_RegisterOnFrameCallback(
component: *mut OH_NativeXComponent,
callback: ::core::option::Option<
@@ -54,10 +54,10 @@ extern "C" {
extern "C" {
/** @brief UnRegister a callback for this OH_NativeXComponent instance.
- @param component Indicates the pointer to this OH_NativeXComponent instance.
- @return Returns the status code of the execution.
- @since 11
- @version 1.0*/
+ @param component Indicates the pointer to this OH_NativeXComponent instance.
+ @return Returns the status code of the execution.
+ @since 11
+ @version 1.0*/
pub fn OH_NativeXComponent_UnregisterOnFrameCallback(
component: *mut OH_NativeXComponent,
) -> i32;