From 682e29e32ea7ca33192e66c079bcaa30aaf3c75f Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 15 Jul 2024 19:58:15 +0200 Subject: [PATCH 1/4] Update Cargo.toml Metadata Signed-off-by: Jonathan Schwender --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 7580466..51a22bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ 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 } @@ -37,3 +38,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 From c2594f05451ee5b0cf1c914507e5c0f8fe3256b2 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 15 Jul 2024 19:59:01 +0200 Subject: [PATCH 2/4] cargo fmt Signed-off-by: Jonathan Schwender --- src/native_window/api11_additions.rs | 29 ++++++++++++++-------------- src/xcomponent/api11_additions.rs | 28 +++++++++++++-------------- 2 files changed, 28 insertions(+), 29 deletions(-) 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; From 019d6657d19dc06acf51838be1f8a18a234ef4f8 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 15 Jul 2024 20:05:27 +0200 Subject: [PATCH 3/4] Add convenience all-components feature Signed-off-by: Jonathan Schwender --- Cargo.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 51a22bc..6dfaa5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,14 @@ 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. From 7af301efb36517eea1190dce03c3fdc1a6aa0852 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 15 Jul 2024 20:19:22 +0200 Subject: [PATCH 4/4] Add CI configuration Signed-off-by: Jonathan Schwender --- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 6 ++++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml 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 6dfaa5d..e4e0178 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ keywords = ["OpenHarmony", "HarmonyOS", "ffi"] document-features = { version = "0.2", optional = true } [features] +default = ["api-10"] ## Enables bindings to `native_drawing` drawing = [] ## Enables bindings to `hilog` @@ -37,8 +38,11 @@ all-components = [ #! 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