Skip to content

Commit

Permalink
ci: add openharmony ci
Browse files Browse the repository at this point in the history
  • Loading branch information
richerfu committed Nov 25, 2024
1 parent aab6d91 commit 396adf7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
36 changes: 35 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,41 @@ jobs:
cargo lipo --verbose --all-features --features="async tokio/rt-multi-thread"
- name: Abort on error
if: ${{ failure() }}
run: echo "iOs build job failed" && false
run: echo "iOS build job failed" && false

build_n_test_openharmony:
strategy:
matrix:
target:
[
aarch64-unknown-linux-ohos,
armv7-unknown-linux-ohos,
x86_64-unknown-linux-ohos,
]
fail-fast: false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: openharmony-rs/[email protected]
id: setup-ohos
with:
version: "5.0"
- name: Install ohrs and rust compiler for ohos target
if: ${{ !cancelled() }}
run: |
cargo install --locked ohrs
rustup target add ${{ matrix.target }}
- name: clippy
if: ${{ !cancelled() }}
run: ohrs cargo --disable-target -- clippy --target ${{matrix.target}} --all-features --features="async tokio/rt-multi-thread" -- -D warnings
- name: Build
if: ${{ !cancelled() }}
run: |
ohrs cargo --disable-target -- rustc --target ${{matrix.target}} --verbose --all-features --features="async tokio/rt-multi-thread" --lib --crate-type=cdylib
- name: Abort on error
if: ${{ failure() }}
run: echo "OpenHarmony build job failed" && false

semver:
name: Check semver
Expand Down
11 changes: 9 additions & 2 deletions src/platform/posix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
//! POSIX compliant support.

mod sockaddr;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
#[cfg(any(
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "macos"
))]
pub(crate) use sockaddr::sockaddr_union;

#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(
all(target_os = "linux", not(target_env = "ohos")),
target_os = "macos"
))]
pub(crate) use sockaddr::ipaddr_to_sockaddr;

mod fd;
Expand Down
5 changes: 4 additions & 1 deletion src/platform/posix/sockaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ fn rs_addr_to_sockaddr(addr: std::net::SocketAddr) -> sockaddr_union {

/// # Safety
/// Fill the `addr` with the `src_addr` and `src_port`, the `size` should be the size of overwriting
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(
all(target_os = "linux", not(target_env = "ohos")),
target_os = "macos"
))]
pub(crate) unsafe fn ipaddr_to_sockaddr<T>(
src_addr: T,
src_port: u16,
Expand Down

0 comments on commit 396adf7

Please sign in to comment.