diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index 496069fe9..b067d1413 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -35,6 +35,7 @@ set(third_party_ndk build/third-party-ndk) set(libfolly_DIR ${third_party_ndk}/folly/) set(glog_DIR ${third_party_ndk}/glog) set(BOOST_DIR ${third_party_ndk}/boost/boost_1_63_0/) +set(LIBEVENT_DIR ${third_party_ndk}/LibEvent/libevent-1.0.0/include/) set(build_DIR ${CMAKE_SOURCE_DIR}/build) @@ -58,6 +59,7 @@ target_include_directories(${PACKAGE_NAME} PRIVATE ${glog_DIR}/glog-0.3.5/src/ ${BOOST_DIR} ${BOOST_DIR}/../ + ${LIBEVENT_DIR} ) target_link_libraries(${PACKAGE_NAME} fb sonarcpp) diff --git a/android/build.gradle b/android/build.gradle index d1fa06e66..a50f62218 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -104,11 +104,28 @@ task prepareFolly(dependsOn: [downloadFolly], type: Copy) { into "$thirdPartyNdkDir/folly" } +task downloadLibEvent(dependsOn: [prepareFolly], type: Download) { + src 'https://github.com/libevent/libevent/archive/release-2.1.8-stable.tar.gz' + onlyIfNewer true + overwrite false + dest new File(downloadsDir, 'libevent-release-2.1.8-stable.tar.gz'); +} + +task prepareLibEvent(dependsOn: [downloadLibEvent], type: Copy) { + from tarTree(downloadLibEvent.dest) + from './third-party/LibEvent/' + include 'libevent-release-2.1.8-stable/**/*', 'build.gradle', 'CMakeLists.txt', 'ApplicationManifest.xml' + includeEmptyDirs = false + into "$thirdPartyNdkDir/LibEvent" +} + task prepareAllLibs() { dependsOn finalizeGlog dependsOn prepareDoubleConversion dependsOn prepareBoost dependsOn prepareFolly + dependsOn downloadLibEvent + dependsOn prepareLibEvent } android { diff --git a/android/third-party/Folly/CMakeLists.txt b/android/third-party/Folly/CMakeLists.txt index ee9c054ea..716feb27e 100644 --- a/android/third-party/Folly/CMakeLists.txt +++ b/android/third-party/Folly/CMakeLists.txt @@ -15,14 +15,17 @@ list(APPEND dir_list ${FOLLY_DIR}/memory/detail) set(BOOST_DIR ../boost/boost_1_63_0/) set(GLOG_DIR ../glog/) +set(LIBEVENT_DIR ../LibEvent/libevent-1.0.0/include) set(DOUBLECONVERSION_DIR ../double-conversion/double-conversion-3.0.0/) list(APPEND dir_list ${BOOST_DIR}) list(APPEND dir_list ${BOOST_DIR}/../) +list(APPEND dir_list ${LIBEVENT_DIR}/) include_directories(${dir_list}) add_compile_options( + -DFOLLY_HAVE_PTHREAD=1 -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_MEMRCHR -DFOLLY_MOBILE=1 @@ -41,6 +44,25 @@ add_compile_options( -Wno-tautological-constant-compare ) +file(GLOB SRC_FILES ${FOLLY_DIR}/*.cpp + ${FOLLY_DIR}/detail/*.cpp + ${FOLLY_DIR}/hash/*.cpp + ${FOLLY_DIR}/portability/*.cpp + ${FOLLY_DIR}/io/async/*.cpp + ${FOLLY_DIR}/io/async/ssl/*.cpp + ${FOLLY_DIR}/io/*.cpp + ${FOLLY_DIR}/synchronization/*.cpp + ${FOLLY_DIR}/lang/*.cpp + ${FOLLY_DIR}/memory/*.cpp + ${FOLLY_DIR}/futures/*.cpp + ${FOLLY_DIR}/futures/detail/*.cpp + ${FOLLY_DIR}/experimental/hazptr/*.cpp + ${FOLLY_DIR}/executors/*.cpp + ${FOLLY_DIR}/concurrency/*.cpp + ${FOLLY_DIR}/ssl/*.cpp + ${FOLLY_DIR}/ssl/detail/*.cpp + ${FOLLY_DIR}/system/*.cpp + ) list(APPEND SRC_FILES ${FOLLY_DIR}/Executor.cpp ${FOLLY_DIR}/lang/ColdClass.cpp ${FOLLY_DIR}/lang/Assume.cpp @@ -55,8 +77,10 @@ list(APPEND SRC_FILES ${FOLLY_DIR}/Executor.cpp ${FOLLY_DIR}/json_pointer.cpp ${FOLLY_DIR}/FormatArg.cpp ${FOLLY_DIR}/Format.cpp + ${FOLLY_DIR}/memory/detail/MallocImpl.cpp ) +message(STATUS "SRC FILES:- " ${SRC_FILES}) add_library(${PACKAGE_NAME} SHARED ${SRC_FILES}) set(build_DIR ${CMAKE_SOURCE_DIR}/build) @@ -70,6 +94,8 @@ add_subdirectory(${GLOG_DIR} ${libglog_build_DIR}) add_subdirectory(${DOUBLECONVERSION_DIR} ${doubleconversion_build_DIR}) target_include_directories(${PACKAGE_NAME} PRIVATE + ${LIBEVENT_DIR} + ${LIBEVENT_DIR}/../ ${BOOST_DIR} ${BOOST_DIR}/../ ${GLOG_DIR}/../ diff --git a/android/third-party/LibEvent/ApplicationManifest.xml b/android/third-party/LibEvent/ApplicationManifest.xml new file mode 100644 index 000000000..07b394959 --- /dev/null +++ b/android/third-party/LibEvent/ApplicationManifest.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/third-party/LibEvent/CMakeLists.txt b/android/third-party/LibEvent/CMakeLists.txt new file mode 100644 index 000000000..1a009d04e --- /dev/null +++ b/android/third-party/LibEvent/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 3.6.0) + +PROJECT(libevent C) +enable_language(C) +set(PACKAGE_NAME libevent) +set(LIBEVENT_DIR libevent-release-2.1.8-stable/) +list(APPEND DIR_LIST ${LIBEVENT_DIR} ${LIBEVENT_DIR}/include) +include_directories(${DIR_LIST}) +file(GLOB SRCFILES ${LIBEVENT_DIR}/*.c) +message(STATUS "SRC FILES :- " ${SRCFILES}) +add_library(${PACKAGE_NAME} SHARED ${SRCFILES}) +install(TARGETS ${PACKAGE_NAME} DESTINATION ./build/) +target_link_libraries(${PACKAGE_NAME}) diff --git a/android/third-party/LibEvent/build.gradle b/android/third-party/LibEvent/build.gradle new file mode 100644 index 000000000..09a727005 --- /dev/null +++ b/android/third-party/LibEvent/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion rootProject.compileSdkVersion + buildToolsVersion rootProject.buildToolsVersion + + defaultConfig { + minSdkVersion rootProject.minSdkVersion + targetSdkVersion rootProject.targetSdkVersion + ndk { + abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' + } + + externalNativeBuild { + cmake { + arguments '-DANDROID_TOOLCHAIN=clang' + } + } + } + lintOptions { + abortOnError false + } + sourceSets { + main { + manifest.srcFile './ApplicationManifest.xml' + } + } + externalNativeBuild { + cmake { + path './CMakeLists.txt' + } + } +} diff --git a/settings.gradle b/settings.gradle index f004675f2..b903bd44c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,6 +17,7 @@ include ':sonarcpp' include ':sample' include ':doubleconversion' include ':glog' +include ':libevent' project(':fbjni').projectDir = file('libs/fbjni') @@ -27,3 +28,4 @@ project(':android').projectDir = file('android') project(':doubleconversion').projectDir = file('android/build/third-party-ndk/double-conversion/') project(':glog').projectDir = file('android/build/third-party-ndk/glog/') project(':folly').projectDir = file('android/build/third-party-ndk/folly/') +project(':libevent').projectDir = file('android/build/third-party-ndk/LibEvent/')