Skip to content

Commit

Permalink
[+] support harmony (#434)
Browse files Browse the repository at this point in the history
* [+] support harmony

* Update docs/Platforms.md

* Update docs/Platforms.md

* Update docs/Platforms.md

---------

Co-authored-by: Yanmei Liu <[email protected]>
  • Loading branch information
lurker-Chen and Yanmei-Liu committed Jul 4, 2024
1 parent 07b1838 commit 68366f6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 14 deletions.
4 changes: 4 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ if (XQC_ENABLE_EVENT_LOG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXQC_ENABLE_EVENT_LOG ")
endif()

if (DISABLE_WARNINGS)
add_compile_options("-Wno-error")
endif ()

if(ANDROID)
set(DYMAMIC_LINK_OPTION
${DYMAMIC_LINK_OPTION}
Expand Down
10 changes: 5 additions & 5 deletions docs/Platforms.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Platforms docs

XQUIC currently supports `Android` , `iOS` , `Linux` and `macOS` .
XQUIC currently supports `Android` , `iOS` , `HarmonyOS` , `Linux` , `macOS` and `Windows` .

## Android/iOS Compile Script
## Android/iOS/HarmonyOS Compile Script

The Android and iOS use `.so` files, there is a [ `xqc_build.sh` ](../xqc_build.sh) script in the XQUIC library directory, execute the script to compile to complete the corresponding compilation.
The Android, iOS and HarmonyOS use `.so` files, there is a [ `xqc_build.sh` ](../xqc_build.sh) script in the XQUIC library directory, execute the script to compile to complete the corresponding compilation.

```bash
sh xqc_build.sh ios/android <build_dir> <artifact_dir> <ssl_path>
sh xqc_build.sh ios/android/harmony <build_dir> <artifact_dir> <ssl_path>
```
specially, `<ssl_path> can be ${PWD}/third_party/boringssl or ${PWD}/third_party/babassl`

> Note: You need to specify the IOS/android build toolchain before compiling, download and set the environment variable IOS_CMAKE_TOOLCHAIN or ANDROID_NDK, or directly modify CMAKE_TOOLCHAIN_FILE in `xqc_build.sh` .
> Note: You need to specify the IOS/android/harmony build toolchain before compiling, download and set the environment variable IOS_CMAKE_TOOLCHAIN or ANDROID_NDK or HMOS_CMAKE_PATH and HMOS_CMAKE_TOOLCHAIN, or directly modify CMAKE_TOOLCHAIN_FILE and HMOS_CMAKE_TOOLCHAIN in `xqc_build.sh` .
## Linux Release

Expand Down
55 changes: 46 additions & 9 deletions xqc_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

android_archs=(armeabi-v7a arm64-v8a)
ios_archs=(armv7 arm64 x86_64)
hmos_archs=(arm64-v8a)
CMAKE_CMD="cmake"
cur_dir=$(cd "$(dirname "$0")";pwd)

cp -f $cur_dir/cmake/CMakeLists.txt $cur_dir/CMakeLists.txt
Expand Down Expand Up @@ -57,14 +59,16 @@ if [ x"$platform" == xios ] ; then
-DXQC_BUILD_SAMPLE=OFF
-DGCOV=OFF
-DCMAKE_TOOLCHAIN_FILE=${IOS_CMAKE_TOOLCHAIN}
-DENABLE_BITCODE=0
-DXQC_NO_SHARED=1
-DXQC_COMPAT_GENERATE_SR_PKT=1
-DXQC_ENABLE_RENO=1
-DXQC_ENABLE_BBR2=1
-DXQC_ENABLE_COPA=1
-DXQC_ENABLE_UNLIMITED=0
-DXQC_ENABLE_MP_INTEROP=0"
-DENABLE_BITCODE=OFF
-DXQC_NO_SHARED=ON
-DXQC_ENABLE_RENO=OFF
-DXQC_ENABLE_BBR2=ON
-DXQC_ENABLE_COPA=OFF
-DXQC_ENABLE_UNLIMITED=OFF
-DXQC_ENABLE_MP_INTEROP=OFF
-DXQC_DISABLE_LOG=OFF
-DXQC_ONLY_ERROR_LOG=ON
-DXQC_COMPAT_GENERATE_SR_PKT=ON"

elif [ x"$platform" == xandroid ] ; then
if [ x"$ANDROID_NDK" == x ] ; then
Expand All @@ -90,6 +94,37 @@ elif [ x"$platform" == xandroid ] ; then
-DXQC_DISABLE_LOG=OFF
-DXQC_ONLY_ERROR_LOG=ON
-DXQC_COMPAT_GENERATE_SR_PKT=ON"
elif [ x"$platform" == xharmony ] ; then
if [ x"$HMOS_CMAKE_TOOLCHAIN" == x ] ; then
echo "HMOS_CMAKE_TOOLCHAIN MUST be defined"
exit 0
fi
echo "HMOS_CMAKE_TOOLCHAIN: ${HMOS_CMAKE_TOOLCHAIN}"

if [ x"$HMOS_CMAKE_PATH" == x ] ; then
echo "HMOS_CMAKE_PATH MUST be defined"
exit 0
fi
echo "HMOS_CMAKE_PATH: ${HMOS_CMAKE_PATH}"
CMAKE_CMD=${HMOS_CMAKE_PATH}

archs=${hmos_archs[@]}
configures="-DSSL_TYPE=${ssl_type}
-DSSL_PATH=${ssl_path}
-DCMAKE_BUILD_TYPE=Release
-DXQC_ENABLE_TESTING=OFF
-DXQC_BUILD_SAMPLE=OFF
-DGCOV=OFF
-DCMAKE_TOOLCHAIN_FILE=${HMOS_CMAKE_TOOLCHAIN}
-DXQC_ENABLE_RENO=OFF
-DXQC_ENABLE_BBR2=ON
-DXQC_ENABLE_COPA=OFF
-DXQC_ENABLE_UNLIMITED=OFF
-DXQC_ENABLE_MP_INTEROP=OFF
-DXQC_DISABLE_LOG=OFF
-DXQC_ONLY_ERROR_LOG=ON
-DXQC_COMPAT_GENERATE_SR_PKT=ON
-DDISABLE_WARNINGS=ON"
else
echo "no support platform"
exit 0
Expand All @@ -105,6 +140,8 @@ generate_plat_spec() {
elif [ x"$1" == xi386 ] ; then
plat_spec="$plat_spec -DPLATFORM=SIMULATOR"
fi
elif [ x"$platform" == xharmony ] ; then
plat_spec="-DOHOS_ARCH=$1"
else
plat_spec="-DANDROID_ABI=$1"
fi
Expand All @@ -131,7 +168,7 @@ do
rm -rf third_party

echo "compiling xquic on $i arch"
cmake $configures $(generate_plat_spec $i ) -DLIBRARY_OUTPUT_PATH=`pwd`/outputs/ ..
"${CMAKE_CMD}" $configures $(generate_plat_spec $i ) -DLIBRARY_OUTPUT_PATH=`pwd`/outputs/ ..
make -j 4
if [ $? != 0 ] ; then
exit 0
Expand Down

0 comments on commit 68366f6

Please sign in to comment.