From cbcbb4085a051f9b078d65c720d82b3f3219e34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?shuxin=20=E3=80=80=E3=80=80zheng?= Date: Mon, 18 Mar 2024 15:47:59 +0800 Subject: [PATCH] Adding supporting for harmonyOS. --- lib_acl/CMakeLists.txt | 16 ++++++++++++++++ lib_acl/src/stdlib/filedir/acl_fhandle.c | 2 +- lib_acl/src/stdlib/iostuff/acl_write_wait.c | 2 +- lib_acl_cpp/CMakeLists.txt | 15 +++++++++++++++ lib_protocol/CMakeLists.txt | 13 +++++++++++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib_acl/CMakeLists.txt b/lib_acl/CMakeLists.txt index badc8a383..4e5550117 100644 --- a/lib_acl/CMakeLists.txt +++ b/lib_acl/CMakeLists.txt @@ -28,6 +28,17 @@ if (CMAKE_SYSTEM_NAME MATCHES "Android") add_definitions("-Wno-unused-command-line-argument") string(APPEND CMAKE_C_FLAGS "-Qunused-arguments") set(UNIX_OS true) +elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + add_definitions("-DANDROID") + add_definitions("-DACL_OHOS") + add_definitions("-O3 -flto") + add_definitions("-DHAS_ATOMIC") + add_definitions("-DACL_CLIENT_ONLY") + add_definitions("-fdata-sections -ffunction-sections") + add_definitions("-Wno-unused-command-line-argument") + add_definitions("-Wno-c99-extensions") + string(APPEND CMAKE_C_FLAGS "-Qunused-arguments") + set(UNIX_OS true) elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") add_definitions("-O2") set(UNIX_OS true) @@ -161,6 +172,8 @@ endif() if (CMAKE_SYSTEM_NAME MATCHES "Android") set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI}) +elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../harmony/lib/${OHOS_ARCH}) else() set(lib_output_path ${PROJECT_BINARY_DIR}/../lib) endif() @@ -186,6 +199,9 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED set(sys_ldflags "-shared -flto") endif() target_compile_options(acl_static PRIVATE -fvisibility=hidden) + elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + set(sys_ldflags "-shared -flto") + target_compile_options(acl_static PRIVATE -fvisibility=hidden) elseif (${UNIX_OS}) set(sys_ldflags "-shared -lpthread -ldl") target_compile_options(acl_static PRIVATE -fvisibility=hidden) diff --git a/lib_acl/src/stdlib/filedir/acl_fhandle.c b/lib_acl/src/stdlib/filedir/acl_fhandle.c index a28f02ece..e32fba925 100644 --- a/lib_acl/src/stdlib/filedir/acl_fhandle.c +++ b/lib_acl/src/stdlib/filedir/acl_fhandle.c @@ -317,7 +317,7 @@ void acl_fhandle_close(ACL_FHANDLE *fs, int delay_timeout) if (fs->nrefer == 0) { acl_debug(__debug_section, 2) ("%s: fpath: %s, when_free: %ld, now: %ld", - myname, PATH(fs->fp), fs->when_free, now); + myname, PATH(fs->fp), (long) fs->when_free, (long) now); __fhandle_close(fs); } iter = iter_next; diff --git a/lib_acl/src/stdlib/iostuff/acl_write_wait.c b/lib_acl/src/stdlib/iostuff/acl_write_wait.c index cab026ed1..a226fc302 100644 --- a/lib_acl/src/stdlib/iostuff/acl_write_wait.c +++ b/lib_acl/src/stdlib/iostuff/acl_write_wait.c @@ -74,7 +74,7 @@ int acl_write_wait_ms(ACL_SOCKET fd, int timeout) end = time(NULL); acl_msg_error("%s(%d), %s: poll return 0, delay=%d, " "fd=%d, cost=%ld", __FILE__, __LINE__, - myname, delay, fd, end - begin); + myname, delay, fd, (long) ( end - begin)); return -1; default: if (fds.revents & POLLNVAL) { diff --git a/lib_acl_cpp/CMakeLists.txt b/lib_acl_cpp/CMakeLists.txt index 3f439f43a..7faa9ad2f 100644 --- a/lib_acl_cpp/CMakeLists.txt +++ b/lib_acl_cpp/CMakeLists.txt @@ -25,6 +25,15 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android") add_definitions("-fdata-sections -ffunction-sections") string(APPEND CMAKE_CXX_FLAGS "-Qunused-arguments") set(UNIX_OS true) +elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + add_definitions("-O3 -flto") + add_definitions("-DANDROID") + add_definitions("-DACL_CPP_LOG_SKIP_FILE") + add_definitions("-fdata-sections -ffunction-sections") + add_definitions("-Wno-unused-command-line-argument") + add_definitions("-Wno-c99-extensions") + string(APPEND CMAKE_CXX_FLAGS "-Qunused-arguments") + set(UNIX_OS true) elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") # add_definitions("-Wno-invalid-source-encoding") add_definitions("-O2") @@ -225,6 +234,8 @@ endif() if (CMAKE_SYSTEM_NAME MATCHES "Android") set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI}) +elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../harmony/lib/${OHOS_ARCH}) else() set(lib_output_path ${PROJECT_BINARY_DIR}/../lib) endif() @@ -251,6 +262,10 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED endif() target_compile_options(acl_cpp_static PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden) + elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + set(sys_ldflags "-shared -flto -lz") + target_compile_options(acl_cpp_static PRIVATE + -fvisibility=hidden -fvisibility-inlines-hidden) elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") set(sys_ldflags "-shared -lz -liconv -lpthread -ldl") target_compile_options(acl_cpp_static PRIVATE diff --git a/lib_protocol/CMakeLists.txt b/lib_protocol/CMakeLists.txt index e6f6e9c3e..8ef7edfc9 100644 --- a/lib_protocol/CMakeLists.txt +++ b/lib_protocol/CMakeLists.txt @@ -23,6 +23,14 @@ if (CMAKE_SYSTEM_NAME MATCHES "Android") add_definitions("-fdata-sections -ffunction-sections") string(APPEND CMAKE_C_FLAGS "-Qunused-arguments") set(UNIX_OS true) +elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + add_definitions("-DANDROID") + add_definitions("-O3 -flto") + add_definitions("-Wno-unused-command-line-argument") + add_definitions("-fdata-sections -ffunction-sections") + add_definitions("-Wno-c99-extensions") + string(APPEND CMAKE_C_FLAGS "-Qunused-arguments") + set(UNIX_OS true) elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") add_definitions("-O2") set(UNIX_OS true) @@ -112,6 +120,8 @@ endif() if (CMAKE_SYSTEM_NAME MATCHES "Android") set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI}) +elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../harmony/lib/${OHOS_ARCH}) else() set(lib_output_path ${PROJECT_BINARY_DIR}/../lib) endif() @@ -137,6 +147,9 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED set(sys_ldflags "-shared -flto -lz") endif() target_compile_options(protocol_static PRIVATE -fvisibility=hidden) + elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS") + set(sys_ldflags "-shared -flto -lz") + target_compile_options(protocol_static PRIVATE -fvisibility=hidden) elseif (${UNIX_OS}) set(sys_ldflags "-shared -lz -lpthread -ldl") target_compile_options(protocol_static PRIVATE -fvisibility=hidden)