From 7d23cc783cbc20d17853ff2ec9d76f4bf8758d0b Mon Sep 17 00:00:00 2001 From: Richer <32590310+richerfu@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:05:40 +0800 Subject: [PATCH 1/2] Support building for HarmonyOS on arm/x86_64 architecture (#401) --- .cargo/aarch64-unknown-linux-ohos-clang.sh | 7 ------ .cargo/config.toml | 3 --- .github/workflows/rust.yml | 26 +++++++++++----------- .gitignore | 2 ++ src/build.rs | 13 ++++++++--- 5 files changed, 25 insertions(+), 26 deletions(-) delete mode 100755 .cargo/aarch64-unknown-linux-ohos-clang.sh delete mode 100644 .cargo/config.toml diff --git a/.cargo/aarch64-unknown-linux-ohos-clang.sh b/.cargo/aarch64-unknown-linux-ohos-clang.sh deleted file mode 100755 index 5162f1ff..00000000 --- a/.cargo/aarch64-unknown-linux-ohos-clang.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -exec ${OHOS_NDK_HOME}/native/llvm/bin/clang \ - -target aarch64-linux-ohos \ - --sysroot=${OHOS_NDK_HOME}/native/sysroot \ - -D__MUSL__ \ - "$@" diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index d2a1e3bf..00000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,3 +0,0 @@ -[target.aarch64-unknown-linux-ohos] -ar = "${OHOS_NDK_HOME}/native/llvm/bin/llvm-ar" -linker = ".cargo/aarch64-unknown-linux-ohos-clang.sh" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 38f2250d..d91b60fc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -132,20 +132,20 @@ 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/setup-ohos-sdk@v0.1.3 + 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 + run: cargo install ohrs && ohrs build -- --verbose --features ffi --release static_analysis: name: Static analysis diff --git a/.gitignore b/.gitignore index e56acb16..d4f8cf5f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ Cargo.lock # Misc .DS_Store + +dist diff --git a/src/build.rs b/src/build.rs index 9fb7fc52..3e7dc5b2 100644 --- a/src/build.rs +++ b/src/build.rs @@ -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 { @@ -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"); } } From fef154b548f844c7eef1a741a2e0c7cc802aa9e0 Mon Sep 17 00:00:00 2001 From: Sijie Yang Date: Thu, 10 Oct 2024 20:11:59 +0000 Subject: [PATCH 2/2] Update VERSION and CHANGELOG --- CHANGELOG.md | 10 +++++++++- Cargo.toml | 2 +- tools/Cargo.toml | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29771d71..597b7882 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.3.1] - 2024-10-11 + +### Added +- Use ohrs to build tquic for HarmaryOS +- Support building for HarmonyOS on arm/x86_64 architecture + + ## [v1.3.0] - 2024-10-10 ### Added -- Support building for HarmonyOS +- Support building for HarmonyOS on aarch64 architecture - Support disable_1rtt_encryption transport parameter - Support sending 1-RTT packets on the server before handshake completion - Resolve new issues found by cargo clippy @@ -319,6 +326,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Provide example clients and servers. +[v1.3.1]: https://github.com/tencent/tquic/compare/v1.3.0...v1.3.1 [v1.3.0]: https://github.com/tencent/tquic/compare/v1.2.0...v1.3.0 [v1.2.0]: https://github.com/tencent/tquic/compare/v1.1.0...v1.2.0 [v1.1.0]: https://github.com/tencent/tquic/compare/v1.0.0...v1.1.0 diff --git a/Cargo.toml b/Cargo.toml index f2c689ae..21133693 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tquic" -version = "1.3.0" +version = "1.3.1" edition = "2021" rust-version = "1.70.0" license = "Apache-2.0" diff --git a/tools/Cargo.toml b/tools/Cargo.toml index 07d88c48..ebb48ab8 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tquic_tools" -version = "1.3.0" +version = "1.3.1" edition = "2021" rust-version = "1.70.0" license = "Apache-2.0" @@ -22,7 +22,7 @@ slab = "0.4" rand = "0.8.5" statrs = "0.16" signal-hook = "0.3.17" -tquic = { path = "..", version = "1.3.0"} +tquic = { path = "..", version = "1.3.1"} [target."cfg(unix)".dependencies] jemallocator = { version = "0.5", package = "tikv-jemallocator" }