Skip to content

Commit

Permalink
feat: support arm & x86_64 & cleanup ci
Browse files Browse the repository at this point in the history
  • Loading branch information
richerfu committed Oct 10, 2024
1 parent 32bc8fa commit 58f86bd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
7 changes: 0 additions & 7 deletions .cargo/aarch64-unknown-linux-ohos-clang.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .cargo/config.toml

This file was deleted.

26 changes: 14 additions & 12 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,22 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install rust toolchain
run: rustup target add ${{ env.TARGET }}
- name: Download OHOS NDK
run: |
wget https://repo.huaweicloud.com/openharmony/os/4.0-Release/ohos-sdk-windows_linux-public.tar.gz
tar -xvzf ohos-sdk-windows_linux-public.tar.gz
cd ohos-sdk/linux/
unzip -q native-linux-x64-4.0.10.13-Release.zip

- name: Setup OpenHarmony SDK
uses: openharmony-rs/[email protected]
with:
version: '4.1'

- name: Setup Rust environment
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: 'aarch64-unknown-linux-ohos,armv7-unknown-linux-ohos,x86_64-unknown-linux-ohos'

- name: Run cargo build
run: |
OHOS_NDK_HOME=${{ github.workspace }}/ohos-sdk/linux/ \
CC_aarch64_unknown_linux_ohos=${OHOS_NDK_HOME}/native/llvm/bin/clang \
AR_aarch64_unknown_linux_ohos=${OHOS_NDK_HOME}/native/llvm/bin/llvm-ar \
cargo build --target ${{ env.TARGET }} --verbose --features ffi --release
cargo install ohrs \
ohrs build -- --verbose --features ffi --release
static_analysis:
name: Static analysis
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ Cargo.lock

# Misc
.DS_Store

dist
13 changes: 10 additions & 3 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ const CMAKE_PARAMS_IOS: &[(&str, &[(&str, &str)])] = &[
];

/// Additional parameters for Ohos
const CMAKE_PARAMS_OHOS_NDK: &[(&str, &[(&str, &str)])] =
&[("aarch64", &[("OHOS_ARCH", "arm64-v8a")])];
const CMAKE_PARAMS_OHOS_NDK: &[(&str, &[(&str, &str)])] = &[
("aarch64", &[("OHOS_ARCH", "arm64-v8a")]),
("arm", &[("OHOS_ARCH", "armeabi-v7a")]),
("x86_64", &[("OHOS_ARCH", "x86_64")]),
];

/// Create a cmake::Config for building BoringSSL.
fn new_boringssl_cmake_config() -> cmake::Config {
Expand Down Expand Up @@ -112,7 +115,11 @@ fn new_boringssl_cmake_config() -> cmake::Config {
for (name, value) in *params {
boringssl_cmake.define(name, value);
}
break;
// common arguments for ohos help us to ignore some error
boringssl_cmake
.define("CMAKE_C_FLAGS", "-Wno-unused-command-line-argument");
boringssl_cmake
.define("CMAKE_CXX_FLAGS", "-Wno-unused-command-line-argument");
}
}

Expand Down

0 comments on commit 58f86bd

Please sign in to comment.