Adding supporting for harmonyOS.

This commit is contained in:
shuxin   zheng 2024-03-18 15:47:59 +08:00
parent 3a8174ece3
commit cbcbb4085a
5 changed files with 46 additions and 2 deletions

View File

@ -28,6 +28,17 @@ if (CMAKE_SYSTEM_NAME MATCHES "Android")
add_definitions("-Wno-unused-command-line-argument") add_definitions("-Wno-unused-command-line-argument")
string(APPEND CMAKE_C_FLAGS "-Qunused-arguments") string(APPEND CMAKE_C_FLAGS "-Qunused-arguments")
set(UNIX_OS true) 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") elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions("-O2") add_definitions("-O2")
set(UNIX_OS true) set(UNIX_OS true)
@ -161,6 +172,8 @@ endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android") if (CMAKE_SYSTEM_NAME MATCHES "Android")
set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI}) 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() else()
set(lib_output_path ${PROJECT_BINARY_DIR}/../lib) set(lib_output_path ${PROJECT_BINARY_DIR}/../lib)
endif() endif()
@ -186,6 +199,9 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED
set(sys_ldflags "-shared -flto") set(sys_ldflags "-shared -flto")
endif() endif()
target_compile_options(acl_static PRIVATE -fvisibility=hidden) 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}) elseif (${UNIX_OS})
set(sys_ldflags "-shared -lpthread -ldl") set(sys_ldflags "-shared -lpthread -ldl")
target_compile_options(acl_static PRIVATE -fvisibility=hidden) target_compile_options(acl_static PRIVATE -fvisibility=hidden)

View File

@ -317,7 +317,7 @@ void acl_fhandle_close(ACL_FHANDLE *fs, int delay_timeout)
if (fs->nrefer == 0) { if (fs->nrefer == 0) {
acl_debug(__debug_section, 2) acl_debug(__debug_section, 2)
("%s: fpath: %s, when_free: %ld, now: %ld", ("%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); __fhandle_close(fs);
} }
iter = iter_next; iter = iter_next;

View File

@ -74,7 +74,7 @@ int acl_write_wait_ms(ACL_SOCKET fd, int timeout)
end = time(NULL); end = time(NULL);
acl_msg_error("%s(%d), %s: poll return 0, delay=%d, " acl_msg_error("%s(%d), %s: poll return 0, delay=%d, "
"fd=%d, cost=%ld", __FILE__, __LINE__, "fd=%d, cost=%ld", __FILE__, __LINE__,
myname, delay, fd, end - begin); myname, delay, fd, (long) ( end - begin));
return -1; return -1;
default: default:
if (fds.revents & POLLNVAL) { if (fds.revents & POLLNVAL) {

View File

@ -25,6 +25,15 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android")
add_definitions("-fdata-sections -ffunction-sections") add_definitions("-fdata-sections -ffunction-sections")
string(APPEND CMAKE_CXX_FLAGS "-Qunused-arguments") string(APPEND CMAKE_CXX_FLAGS "-Qunused-arguments")
set(UNIX_OS true) 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") elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
# add_definitions("-Wno-invalid-source-encoding") # add_definitions("-Wno-invalid-source-encoding")
add_definitions("-O2") add_definitions("-O2")
@ -225,6 +234,8 @@ endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android") if (CMAKE_SYSTEM_NAME MATCHES "Android")
set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI}) 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() else()
set(lib_output_path ${PROJECT_BINARY_DIR}/../lib) set(lib_output_path ${PROJECT_BINARY_DIR}/../lib)
endif() endif()
@ -251,6 +262,10 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED
endif() endif()
target_compile_options(acl_cpp_static PRIVATE target_compile_options(acl_cpp_static PRIVATE
-fvisibility=hidden -fvisibility-inlines-hidden) -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") elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(sys_ldflags "-shared -lz -liconv -lpthread -ldl") set(sys_ldflags "-shared -lz -liconv -lpthread -ldl")
target_compile_options(acl_cpp_static PRIVATE target_compile_options(acl_cpp_static PRIVATE

View File

@ -23,6 +23,14 @@ if (CMAKE_SYSTEM_NAME MATCHES "Android")
add_definitions("-fdata-sections -ffunction-sections") add_definitions("-fdata-sections -ffunction-sections")
string(APPEND CMAKE_C_FLAGS "-Qunused-arguments") string(APPEND CMAKE_C_FLAGS "-Qunused-arguments")
set(UNIX_OS true) 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") elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions("-O2") add_definitions("-O2")
set(UNIX_OS true) set(UNIX_OS true)
@ -112,6 +120,8 @@ endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android") if (CMAKE_SYSTEM_NAME MATCHES "Android")
set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI}) 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() else()
set(lib_output_path ${PROJECT_BINARY_DIR}/../lib) set(lib_output_path ${PROJECT_BINARY_DIR}/../lib)
endif() 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") set(sys_ldflags "-shared -flto -lz")
endif() endif()
target_compile_options(protocol_static PRIVATE -fvisibility=hidden) 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}) elseif (${UNIX_OS})
set(sys_ldflags "-shared -lz -lpthread -ldl") set(sys_ldflags "-shared -lz -lpthread -ldl")
target_compile_options(protocol_static PRIVATE -fvisibility=hidden) target_compile_options(protocol_static PRIVATE -fvisibility=hidden)