133 Building CEDA core libraries to target Android
Boost for Android
See build ceda core libs for android under windows
Build CEDA core libraries on Ubuntu VM
The CEDA source code is located under ~/developer/_root_/Ceda
See long int64 overloads.
See filter-abi to only build for arm64-v8a.
Created a project MyApplication on Ubuntu VM. Enabled C++ support with C++11 and enabled exceptions and RTTI
Note the C++ compiler switches passed through to CMake from a build.gradle file:
externalNativeBuild {
cmake {
cppFlags "-std=c++11 -frtti -fexceptions"
}
}
Added the following to CMakeLists.txt
# Specifies a path to native header files.
include_directories(~/developer/_root_/Ceda/Core/cxUtils/)
include_directories(~/boost/Boost-for-Android-master/build/boost/1_60.0/include/)
file(GLOB cxUtils_SRC
"~/developer/_root_/Ceda/Core/cxUtils/*.h"
"~/developer/_root_/Ceda/Core/cxUtils/src/*.h"
"~/developer/_root_/Ceda/Core/cxUtils/src/*.cpp"
)
native-lib was written to ~/AndroidStudioProjects/MyApplication/app/build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so
CMakeLists.txt
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
set( root-path /home/david/developer/_root_ )
set( xcppsource-root-path /home/david/developer/build_ceda_core_android/build/xcppsource/Android/Release )
set( boost-path /home/david/boost/Boost-for-Android-master/build/boost/1.60.0 )
# Specifies a path to native header files.
# Note that xcppsource-root-path should precede root-path so #include IObject.h etc finds the generated one
include_directories(${xcppsource-root-path}/)
include_directories(${xcppsource-root-path}/Ceda/Core/cxObject/)
include_directories(${xcppsource-root-path}/Ceda/Core/cxPersistStore/)
include_directories(${xcppsource-root-path}/Ceda/Core/cxRmi/)
include_directories(${xcppsource-root-path}/Ceda/Core/cxOperation/)
include_directories(${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/)
include_directories(${xcppsource-root-path}/Ceda/Core/cxOperation/src)
include_directories(${root-path}/)
include_directories(${root-path}/Ceda/Core/cxUtils/)
include_directories(${root-path}/Ceda/Core/cxThread/)
include_directories(${root-path}/Ceda/Core/cxLss/)
include_directories(${root-path}/Ceda/Core/cxSocket/)
include_directories(${root-path}/Ceda/Core/cxMessage/)
include_directories(${boost-path}/include/)
add_definitions(
-DMAXIMUM_ARCHIVE_COMPRESSION
-DCEDA_CHECK_ASSERTIONS
-DCEDA_ASSERTION_FAILURE_THROWS_EXCEPTION
)
# _CRT_SECURE_NO_DEPRECATE
# _SCL_SECURE_NO_WARNINGS
# MAXIMUM_ARCHIVE_COMPRESSION
# _WINDOWS
# _WINDLL
# cxOperation_EXPORTS
# _UNICODE
# UNICODE
# WIN32
# _WIN32_WINNT=0x0501
# _SECURE_SCL=0
# NDEBUG
# CEDA_CHECK_ASSERTIONS
# CEDA_ASSERTION_FAILURE_THROWS_EXCEPTION
file(GLOB cxUtils_SRC
"${root-path}/Ceda/Core/cxUtils/*.h"
"${root-path}/Ceda/Core/cxUtils/src/*.h"
"${root-path}/Ceda/Core/cxUtils/src/*.cpp"
)
file(GLOB cxThread_SRC
"${root-path}/Ceda/Core/cxThread/*.h"
"${root-path}/Ceda/Core/cxThread/src/*.h"
"${root-path}/Ceda/Core/cxThread/src/*.cpp"
)
file(GLOB cxLss_SRC
"${root-path}/Ceda/Core/cxLss/*.h"
"${root-path}/Ceda/Core/cxLss/src/*.h"
"${root-path}/Ceda/Core/cxLss/src/*.cpp"
)
file(GLOB cxSocket_SRC
"${root-path}/Ceda/Core/cxSocket/*.h"
"${root-path}/Ceda/Core/cxSocket/src/*.h"
"${root-path}/Ceda/Core/cxSocket/src/*.cpp"
)
file(GLOB cxMessage_SRC
"${root-path}/Ceda/Core/cxMessage/*.h"
"${root-path}/Ceda/Core/cxMessage/src/*.h"
"${root-path}/Ceda/Core/cxMessage/src/*.cpp"
)
file(GLOB cxMessage_SRC
"${root-path}/Ceda/Core/cxMessage/*.h"
"${root-path}/Ceda/Core/cxMessage/src/*.h"
"${root-path}/Ceda/Core/cxMessage/src/*.cpp"
)
file(GLOB cxObject_SRC
"${xcppsource-root-path}/Ceda/Core/cxObject/*.h"
"${xcppsource-root-path}/Ceda/Core/cxObject/src/*.h"
"${xcppsource-root-path}/Ceda/Core/cxObject/src/*.cpp"
)
file(GLOB cxPersistStore_SRC
"${xcppsource-root-path}/Ceda/Core/cxPersistStore/*.h"
"${xcppsource-root-path}/Ceda/Core/cxPersistStore/src/*.h"
"${xcppsource-root-path}/Ceda/Core/cxPersistStore/src/*.cpp"
)
file(GLOB cxRmi_SRC
"${xcppsource-root-path}/Ceda/Core/cxRmi/*.h"
"${xcppsource-root-path}/Ceda/Core/cxRmi/src/*.h"
"${xcppsource-root-path}/Ceda/Core/cxRmi/src/*.cpp"
)
file(GLOB cxOperation_SRC
"${xcppsource-root-path}/Ceda/Core/cxOperation/*.h"s
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/*.h"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/Util/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/Rod/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/WorkingSet/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/WorkingSet/CompOp/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/WorkingSetMachine/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/Delta/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/DeltaReader/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxOperation/src/DeltaWriter/*.cpp"
)
file(GLOB cxWorkingSetIpc_SRC
"${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/*.h"
"${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/src/*.h"
"${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/src/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/src/WorkingSetIPC/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/src/Wsipc/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/src/Mwsipc/*.cpp"
"${xcppsource-root-path}/Ceda/Core/cxWorkingSetIpc/src/ReposIpc/*.cpp"
)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( cxUtils SHARED ${cxUtils_SRC} )
add_library( cxThread SHARED ${cxThread_SRC} )
add_library( cxLss SHARED ${cxLss_SRC} )
add_library( cxSocket SHARED ${cxSocket_SRC} )
add_library( cxMessage SHARED ${cxMessage_SRC} )
add_library( cxObject SHARED ${cxObject_SRC} )
add_library( cxPersistStore SHARED ${cxPersistStore_SRC} )
add_library( cxRmi SHARED ${cxRmi_SRC} )
add_library( cxOperation SHARED ${cxOperation_SRC} )
add_library( cxWorkingSetIpc SHARED ${cxWorkingSetIpc_SRC} )
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
set(boost-lib-system-path ${boost-path}/libs/arm64-v8a/gnu-4.9/libboost_system.so)
set(boost-lib-filesystem-path ${boost-path}/libs/arm64-v8a/gnu-4.9/libboost_filesystem.so)
set(boost-lib-thread-path ${boost-path}/libs/arm64-v8a/gnu-4.9/libboost_thread.so)
set(boost-lib-chrono-path ${boost-path}/libs/arm64-v8a/gnu-4.9/libboost_chrono.so)
set(boost-lib-atomic-path ${boost-path}/libs/arm64-v8a/gnu-4.9/libboost_atomic.so)
set(boost-libs ${boost-lib-system-path}
${boost-lib-filesystem-path}
${boost-lib-thread-path}
${boost-lib-chrono-path}
${boost-lib-atomic-path})
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( cxUtils ${boost-libs} )
target_link_libraries( cxThread ${boost-libs} cxUtils )
target_link_libraries( cxLss cxUtils )
target_link_libraries( cxSocket cxUtils )
target_link_libraries( cxMessage ${boost-libs} cxUtils cxSocket )
target_link_libraries( cxObject cxUtils cxThread )
target_link_libraries( cxPersistStore cxUtils cxLss cxObject )
target_link_libraries( cxRmi cxUtils cxSocket cxMessage cxObject )
target_link_libraries( cxOperation cxUtils cxThread cxLss cxObject cxPersistStore )
target_link_libraries( cxWorkingSetIpc ${boost-libs} cxUtils cxThread cxSocket cxMessage cxLss cxObject cxPersistStore cxRmi cxOperation )
Building the AAR
To build the AAR file the following is needed at the top of the module build.grade:
apply plugin: 'com.android.library'
Then select the menu item "Buuld APK" in the Build menu.
This creates the 2.9MB file ~/AndroidStudioProjects/MyApplication/app/build/outputs/aar/app-release.aar
app-release.aar
├── aidl
├── AndroidManifest.xml
├── assets
├── classes.jar
├── jni
│ └── arm64-v8a
│ ├── libcxLss.so
│ ├── libcxMessage.so
│ ├── libcxObject.so
│ ├── libcxOperation.so
│ ├── libcxPersistStore.so
│ ├── libcxRmi.so
│ ├── libcxSocket.so
│ ├── libcxThread.so
│ ├── libcxUtils.so
│ └── libcxWorkingSetIpc.so
├── libs
├── res
│ ├── layout
│ │ └── activity_main.xml
│ ├── mipmap-hdpi-v4
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-mdpi-v4
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-xhdpi-v4
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi-v4
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi-v4
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ └── values
│ └── values.xml
└── R.txt
Making ceda header files available
The following commands were used to tar the (translated) CEDA header files and upload to the cedanet website:
tar -C ~/developer/build_ceda_core_android/include -cvzf ~/developer/ceda-includes.tar.gz .
wput -nc -u ~/developer/ceda-includes.tar.gz ftp://user:[email protected]/public_html/ceda/xcpp/android/