Skip to content

Commit

Permalink
Fixes to get compiling on Android.
Browse files Browse the repository at this point in the history
Got Eigen/Ceres to install via Cmake Fetch, for Android; this allows using Relative Activity tools on Android.
Modified Wt patch to compile with latest boost and compilers for Android.
Update build target a little, for Android.
  • Loading branch information
wcjohns committed Jul 15, 2024
1 parent 95e3498 commit b46f8ee
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 14 deletions.
17 changes: 15 additions & 2 deletions cmake/FetchInterSpecDeps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,25 @@ if( USE_REL_ACT_TOOL )
set( EIGEN_BUILD_SHARED_LIBS OFF CACHE INTERNAL "" )
set( EIGEN_BUILD_DOC OFF CACHE INTERNAL "" )
set( EIGEN_BUILD_TESTING OFF CACHE INTERNAL "" )
set( EIGEN_BUILD_PKGCONFIG OFF )
#set( Eigen3_DIR "${FETCHCONTENT_BASE_DIR}/..." CACHE INTERNAL "" )

FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3147391d946bb4b6c68edd901f2add6ac1f31f8c # release-3.4.0
#GIT_TAG 3147391d946bb4b6c68edd901f2add6ac1f31f8c # release-3.4.0
GIT_TAG 9df21dc8b4b576a7aa5c0094daa8d7e8b8be60f0 #Updated 3.4 release, to pickup some CMake fixes
GIT_SHALLOW TRUE
)

FetchContent_MakeAvailable( eigen )

# For Android
if( ANDROID )
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${eigen_BINARY_DIR}" CACHE STRING "Modules for CMake" FORCE )
set( Eigen3_DIR "${eigen_BINARY_DIR}" CACHE PATH "" FORCE ) #${eigen_SOURCE_DIR}
endif( ANDROID )


# Set some Google Ceres options; both to allow compiling without further dependancies, and
# avoid some things we dont need
Expand All @@ -185,8 +197,9 @@ if( USE_REL_ACT_TOOL )
ceres-solver
GIT_REPOSITORY https://ceres-solver.googlesource.com/ceres-solver
GIT_TAG 783637a6ed285abc6c57b16ccd968c594a91b35f # release-2.1.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(eigen ceres-solver)
FetchContent_MakeAvailable( ceres-solver )
endif( USE_REL_ACT_TOOL )

if( BUILD_AS_WX_WIDGETS_APP )
Expand Down
13 changes: 9 additions & 4 deletions src/RelActAutoGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
using namespace Wt;
using namespace std;

#if( ANDROID )
// Defined in target/android/android.cpp
extern void android_download_workaround( Wt::WResource *resource, std::string description );
#endif

namespace
{
//DeleteOnClosePopupMenu - same class as from D3SpectrumDisplayDiv... should refactor
Expand Down Expand Up @@ -4031,8 +4036,8 @@ void RelActAutoGui::addDownloadAndUploadLinks( Wt::WContainerWidget *parent )

#if( ANDROID )
// Using hacked saving to temporary file in Android, instead of via network download of file.
m_downloadHtmlReport->clicked().connect( std::bind([this](){
android_download_workaround( m_calpResource, "isotopics_by_nuclide.html");
btn->clicked().connect( std::bind([this](){
android_download_workaround( m_html_download_rsc, "isotopics_by_nuclide.html");
}) );
#endif //ANDROID
#endif
Expand All @@ -4057,8 +4062,8 @@ void RelActAutoGui::addDownloadAndUploadLinks( Wt::WContainerWidget *parent )

#if( ANDROID )
// Using hacked saving to temporary file in Android, instead of via network download of file.
m_downloadHtmlReport->clicked().connect( std::bind([this](){
android_download_workaround( m_calpResource, "isotopics_by_nuclide_config.html");
btn->clicked().connect( std::bind([this](){
android_download_workaround( m_xml_download_rsc, "isotopics_by_nuclide_config.html");
}) );
#endif //ANDROID

Expand Down
7 changes: 6 additions & 1 deletion src/RelActManualGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
using namespace Wt;
using namespace std;

#if( ANDROID )
// Defined in target/android/android.cpp
extern void android_download_workaround( Wt::WResource *resource, std::string description );
#endif

const int RelActManualGui::sm_xmlSerializationMajorVersion = 0;
const int RelActManualGui::sm_xmlSerializationMinorVersion = 1;

Expand Down Expand Up @@ -733,7 +738,7 @@ void RelActManualGui::init()
#if( ANDROID )
// Using hacked saving to temporary file in Android, instead of via network download of file.
m_downloadHtmlReport->clicked().connect( std::bind([this](){
android_download_workaround( m_calpResource, "rel_eff.html");
android_download_workaround( m_htmlResource, "rel_eff.html");
}) );
#endif //ANDROID
#endif
Expand Down
6 changes: 5 additions & 1 deletion target/android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.15...3.23)

set( SpecUtils_JAVA_SWIG OFF CACHE INTERNAL "" )
set( SpecUtils_USE_WT_THREADPOOL ON CACHE INTERNAL "" )
set( SpecUtils_D3_SUPPORT_FILE_STATIC OFF CACHE INTERNAL "" )

set( ANDROID_CPP_FEATURES "rtti exceptions" CACHE INTERNAL "" )
set( ANDROID_PIE ON CACHE INTERNAL "" )
set( ANDROID_STL "c++_static" CACHE INTERNAL "" )
Expand All @@ -20,7 +24,7 @@ set( MAX_SPECTRUM_MEMMORY_SIZE_MB 32 CACHE INTERNAL "" )
set( USE_DB_TO_STORE_SPECTRA ON CACHE INTERNAL "" )
set( USE_SPECRUM_FILE_QUERY_WIDGET OFF CACHE INTERNAL "" )
# Building the RelAct tool currently fails for Android because of erroring finding Eigen (which should be fetched) - I didnt spend time trying to fix.
set( USE_REL_ACT_TOOL OFF CACHE INTERNAL "" )
set( USE_REL_ACT_TOOL ON CACHE INTERNAL "" )
set( USE_LEAFLET_MAP ON CACHE INTERNAL "" )


Expand Down
10 changes: 5 additions & 5 deletions target/android/InterSpec/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ android {
}
}

compileSdkVersion 33
compileSdkVersion 34
ndkVersion '23.1.7779620'

defaultConfig {
applicationId "gov.sandia.interspec"
// Android 4 (Kit Kat) is level 19. Android 6 (Marshmallow - e.x., Nexus 7) is level 23.
minSdkVersion 19
targetSdkVersion 33
versionCode 16
versionName "1.0.11"
targetSdkVersion 34
versionCode 17
versionName "1.0.12"
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

signingConfig signingConfigs.config

externalNativeBuild {
cmake {
arguments "-DUSE_LEAFLET_MAP=ON", "-DUSE_REMOTE_RID=OFF", "-DUSE_REL_ACT_TOOL=OFF"
arguments "-DUSE_LEAFLET_MAP=ON"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion target/android/android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ else

// TODO:
JNIEnv* env = nullptr;
jint status = sm_jvm->AttachCurrentThread( &env, nullptr );
jint status = sm_jvm->AttachCurrentThread( (void **)&env, nullptr );

auto exc = env->ExceptionOccurred();
if (exc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,36 @@ index 0fe20e9f..4a23938d 100644

private:
std::vector<std::string> options_;
diff --git a/src/http/WServer.C b/src/http/WServer.C
index 9eb05058..04a683d7 100644
--- a/src/http/WServer.C
+++ b/src/http/WServer.C
@@ -26,9 +26,9 @@
#include <process.h>
#endif

-#ifdef ANDROID
-#include "Android.h"
-#endif
+//#ifdef ANDROID
+//#include "Android.h"
+//#endif

namespace {
static void parseArgsPartially(int argc, char *argv[],
@@ -59,9 +59,9 @@ struct WServer::Impl
: serverConfiguration_(0),
server_(0)
{
-#ifdef ANDROID
- preventRemoveOfSymbolsDuringLinking();
-#endif
+//#ifdef ANDROID
+// preventRemoveOfSymbolsDuringLinking();
+//#endif
}

~Impl()
diff --git a/src/web/FileUtils.C b/src/web/FileUtils.C
index 5a15b09f..1b8774af 100644
--- a/src/web/FileUtils.C
Expand Down

0 comments on commit b46f8ee

Please sign in to comment.