Android aupport
This commit is contained in:
parent
51359cb175
commit
c49165a7af
2
C/text.c
2
C/text.c
@ -917,7 +917,7 @@ static unsigned char *concat(int n, void *sv[] USES_REGS) {
|
||||
buf = Malloc(room + 1);
|
||||
buf0 = buf;
|
||||
for (i = 0; i < n; i++) {
|
||||
#if _WIN32
|
||||
#if _WIN32 || defined( __ANDROID__ )
|
||||
strcpy(buf, sv[i]);
|
||||
buf = (char*)buf + strlen(buf);
|
||||
#else
|
||||
|
@ -9,8 +9,9 @@
|
||||
project( YAP )
|
||||
|
||||
if (ANDROID)
|
||||
set(YAP_APP_DIR "$CMAKE_SOURCE_DIR/../..")
|
||||
set(YAP_APP_DIR "${CMAKE_SOURCE_DIR}/../..")
|
||||
cmake_policy(VERSION 3.4)
|
||||
|
||||
else ()
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CMakeToolsHelpers OPTIONAL)
|
||||
@ -38,6 +39,19 @@ include (GNUInstallDirs)
|
||||
# You can define multiple libraries, and CMake builds it for you.
|
||||
# Gradle automatically packages shared libraries with your APK.
|
||||
|
||||
#cross-compilation support
|
||||
# Search packages for host system instead of packages for target system
|
||||
# in case of cross compilation these macro should be defined by toolchain file
|
||||
if(NOT COMMAND find_host_package)
|
||||
macro(find_host_package)
|
||||
find_package(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
if(NOT COMMAND find_host_program)
|
||||
macro(find_host_program)
|
||||
find_program(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
|
||||
include(Prelims NO_POLICY_SCOPE)
|
||||
|
||||
@ -45,11 +59,10 @@ include(Sources NO_POLICY_SCOPE)
|
||||
|
||||
include(Model NO_POLICY_SCOPE)
|
||||
|
||||
include_directories ( utf8proc packages/myddas packages/myddas/sqlite3 )
|
||||
if (ANDROID)
|
||||
|
||||
include_directories ( packages/myddas/sqlite3/Android/jni/sqlite/nativehelper packages/myddas/sqlite3/Android/jni/sqlite )
|
||||
endif (ANDROID)
|
||||
include_directories ( utf8proc packages/myddas packages/myddas/sqlite3
|
||||
packages/myddas/sqlite3/Android/jni/sqlite
|
||||
packages/myddas/sqlite3/Android/jni/sqlite/nativehelper
|
||||
)
|
||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||
|
||||
if (MYSQL_FOUND)
|
||||
@ -66,21 +79,6 @@ if (MYSQL_POSTGRES)
|
||||
|
||||
if (ANDROID)
|
||||
|
||||
#
|
||||
# SWIG_FOUND - set to true if SWIG is found
|
||||
# SWIG_DIR - t he directory where swig is installed
|
||||
# SWIG_EXECUTABLE - the path to the swig executable
|
||||
# SWIG_VERSION - the version number of the swig executable
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
|
||||
set (SWIG_CXX ${CMAKE_BINARY_DIR}/packages/swig/android/yap_swig.cpp)
|
||||
|
||||
|
||||
add_subdirectory("packages/swig")
|
||||
|
||||
ADD_SUBDIRECTORY(os)
|
||||
ADD_SUBDIRECTORY(OPTYap)
|
||||
ADD_SUBDIRECTORY(packages/myddas)
|
||||
@ -114,7 +112,7 @@ add_library( # Sets the name of the library.
|
||||
SHARED
|
||||
|
||||
${ENGINE_SOURCES}
|
||||
${SWIG_CXX}
|
||||
${CMAKE_SOURCE_DIR}/../generated/jni/yap_wrap.cpp
|
||||
${C_INTERFACE_SOURCES}
|
||||
${STATIC_SOURCES}
|
||||
${ALL_SOURCES}
|
||||
@ -131,7 +129,7 @@ endif (USE_READLINE)
|
||||
|
||||
|
||||
if (ANDROID)
|
||||
add_dependencies(libYap plmyddas swig)
|
||||
add_dependencies(libYap plmyddas )
|
||||
|
||||
target_link_libraries(libYap android log)
|
||||
|
||||
|
11
CXX/yapi.cpp
11
CXX/yapi.cpp
@ -480,8 +480,9 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) {
|
||||
YAP_dogoalinfo q;
|
||||
Term terr;
|
||||
jmp_buf q_env;
|
||||
|
||||
for (arity_t i = 0; i < arity; i++)
|
||||
Yap_XREGS[i + 1] = ts[i].term();
|
||||
XREGS[i + 1] = ts[i].term();
|
||||
q.CurSlot = Yap_StartSlots();
|
||||
q.p = P;
|
||||
q.cp = CP;
|
||||
@ -624,7 +625,7 @@ Term YAPEngine::fun(Term t) {
|
||||
Yap_CloseHandles(q.CurSlot);
|
||||
throw YAPError();
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result);
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %ld", o);
|
||||
|
||||
t = Yap_GetFromSlot(q.CurSlot);
|
||||
Yap_CloseHandles(q.CurSlot);
|
||||
@ -665,14 +666,14 @@ YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]) : YAPPredicate(p.ap) {
|
||||
|
||||
YAPListTerm YAPQuery::namedVars() {
|
||||
CACHE_REGS
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %s %d",
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %s %ld",
|
||||
vnames.text(), LOCAL_CurSlot);
|
||||
return vnames; // should be o
|
||||
}
|
||||
|
||||
YAPListTerm YAPQuery::namedVarsCopy() {
|
||||
CACHE_REGS
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %s %d",
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %s %ld",
|
||||
vnames.text(), LOCAL_CurSlot);
|
||||
return YAPListTerm(YAP_CopyTerm(vnames.term())); // should be o
|
||||
}
|
||||
@ -703,7 +704,7 @@ bool YAPQuery::next() {
|
||||
result = (bool)YAP_RetryGoal(&q_h);
|
||||
}
|
||||
if (result) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %d",
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %ld",
|
||||
q_state, vnames.text(), LOCAL_CurSlot);
|
||||
} else {
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "fail");
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
/// goal.
|
||||
inline YAPQuery(const char *s) : YAPPredicate(s, tgoal, names) {
|
||||
BACKUP_H();
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %d",
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %ld",
|
||||
LOCAL_CurSlot);
|
||||
if (!ap)
|
||||
return;
|
||||
|
@ -120,7 +120,7 @@ struct page_statistics {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
long pages_in_use; /* same as struct pages (opt.structs.h) */
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
long structs_in_use; /* same as struct pages (opt.structs.h) */
|
||||
size_t structs_in_use; /* same as struct pages (opt.structs.h) */
|
||||
long bytes_in_use;
|
||||
};
|
||||
|
||||
|
@ -95,7 +95,7 @@ struct threads_dependency_frame {
|
||||
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
typedef struct page_header {
|
||||
volatile int structs_in_use;
|
||||
volatile size_t structs_in_use;
|
||||
void *allocated_area;
|
||||
void *first_free_struct;
|
||||
struct page_header *previous;
|
||||
@ -125,7 +125,7 @@ struct global_page_entry {
|
||||
int structs_per_page;
|
||||
volatile long pages_in_use;
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
volatile long structs_in_use;
|
||||
volatile size_t structs_in_use;
|
||||
};
|
||||
|
||||
struct local_page_entry {
|
||||
@ -133,9 +133,10 @@ struct local_page_entry {
|
||||
struct page_header *first_page;
|
||||
struct page_header *last_page;
|
||||
int structs_per_page;
|
||||
long pages_in_use;
|
||||
|
||||
size_t pages_in_use;
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
long structs_in_use;
|
||||
size_t structs_in_use;
|
||||
};
|
||||
|
||||
#define PgEnt_lock(X) ((X).lock)
|
||||
|
@ -105,20 +105,6 @@ else()
|
||||
endif()
|
||||
|
||||
|
||||
#cross-compilation support
|
||||
# Search packages for host system instead of packages for target system
|
||||
# in case of cross compilation these macro should be defined by toolchain file
|
||||
if(NOT COMMAND find_host_package)
|
||||
macro(find_host_package)
|
||||
find_package(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
if(NOT COMMAND find_host_program)
|
||||
macro(find_host_program)
|
||||
find_program(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
|
||||
# where we have most scripts
|
||||
# set path to additional CMake modules
|
||||
|
||||
@ -142,10 +128,10 @@ endif(POLICY CMP0043)
|
||||
|
||||
|
||||
if (ANDROID)
|
||||
set ( prefix ${YAP_APP_DIR}/app/build/generated )
|
||||
set ( datarootdir ${YAP_APP_DIR}/app/build/generated/assets )
|
||||
set ( prefix ${YAP_APP_DIR}/app/src/generated )
|
||||
set ( datarootdir ${YAP_APP_DIR}/app/src/generated/assets )
|
||||
set ( includedir "${prefix}/assets/include")
|
||||
set ( libpl ${YAP_APP_DIR}/app/build/generated/assets/Yap)
|
||||
set ( libpl ${YAP_APP_DIR}/app/src/generated/assets/Yap)
|
||||
else()
|
||||
set ( prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
set ( datarootdir "${prefix}/share")
|
||||
|
@ -60,7 +60,7 @@ include_directories (H
|
||||
include_directories (BEFORE ${CMAKE_BINARY_DIR})
|
||||
|
||||
if (ANDROID)
|
||||
include_directories (CXX)
|
||||
include_directories (CXX ${CMAKE_SOURCE_DIR}/../generated/src/jni)
|
||||
endif()
|
||||
|
||||
find_package (GMP)
|
||||
|
@ -11,7 +11,6 @@ set(MYDDAS_SOURCES
|
||||
myddas_shared.c
|
||||
myddas_statistics.c
|
||||
myddas_top_level.c
|
||||
|
||||
)
|
||||
|
||||
include_directories(. sqlite3)
|
||||
|
@ -9,9 +9,9 @@ set(MYDDAS_YPP
|
||||
myddas_prolog2sql_optimizer.ypp)
|
||||
|
||||
set(MYDDAS_DRIVERS
|
||||
myddas_driver.ypp
|
||||
"myddas_driver.ypp"
|
||||
)
|
||||
|
||||
message("libpl ${libpl}")
|
||||
if (ANDROID)
|
||||
set (PREFIX ${libpl} )
|
||||
else()
|
||||
@ -30,7 +30,7 @@ function(cpp_compile output filename)
|
||||
OUTPUT ${outfile}
|
||||
COMMAND ${CMAKE_C_COMPILER} ${MYDDAS_FLAGS} /EP /P ${outfile} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
|
||||
else ()
|
||||
ELSE (MSVC)
|
||||
add_custom_command(
|
||||
OUTPUT ${outfile}
|
||||
COMMAND ${CMAKE_C_COMPILER} ${MYDDAS_FLAGS} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/${filename} -o ${outfile}
|
||||
@ -40,7 +40,11 @@ function(cpp_compile output filename)
|
||||
endfunction()
|
||||
|
||||
function(cpp_driver output dbms filename)
|
||||
if (ANDROID)
|
||||
set(outfile ${libpl}/myddas_${dbms}.yap)
|
||||
else()
|
||||
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/myddas_${dbms}.yap)
|
||||
endif()
|
||||
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
||||
IF (MSVC)
|
||||
add_custom_command(
|
||||
|
@ -1,3 +1,4 @@
|
||||
message( " * Sqlite3 Data-Base (http://www.sqlite3ql.org), distributed with MYDDAS" )
|
||||
|
||||
set( YAPSQLITE3_SOURCES
|
||||
myddas_sqlite3.c
|
||||
@ -5,8 +6,30 @@ set( YAPSQLITE3_SOURCES
|
||||
sqlite3.h
|
||||
)
|
||||
|
||||
#sqlite3 is now in the system
|
||||
|
||||
set (SQLITE3_FOUND ON CACHE PRIVATE "")
|
||||
|
||||
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA=1 )
|
||||
|
||||
add_definitions(-DSQLITE_ENABLE_JSON1=1 )
|
||||
|
||||
add_definitions(-DSQLITE_ENABLE_RBU=1 )
|
||||
|
||||
add_definitions(-DSQLITE_ENABLE_RTREE=1 )
|
||||
|
||||
add_definitions(-DSQLITE_ENABLE_FTS5=1 )
|
||||
|
||||
|
||||
if (ANDROID)
|
||||
set( YAPSQLITE3_ANDROID_SOURCES
|
||||
|
||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. Android/jni/sqlite Android/jni/sqlite/nativehelper )
|
||||
|
||||
|
||||
set(YAPSQLITE3_SOURCES
|
||||
${YAPSQLITE3_SOURCES}
|
||||
Android/jni/sqlite/JNIHelp.cpp
|
||||
Android/jni/sqlite/JniConstants.cpp
|
||||
Android/jni/sqlite/android_database_SQLiteCommon.cpp
|
||||
@ -14,39 +37,13 @@ Android/jni/sqlite/android_database_SQLiteCommon.h
|
||||
Android/jni/sqlite/android_database_SQLiteConnection.cpp
|
||||
Android/jni/sqlite/android_database_SQLiteDebug.cpp
|
||||
Android/jni/sqlite/android_database_SQLiteGlobal.cpp
|
||||
Android/jni/sqlite/nativehelper/jni.h
|
||||
Android/jni/sqlite/nativehelper/jniConstants.h
|
||||
Android/jni/sqlite/nativehelper/JNIHelp.h
|
||||
Android/jni/sqlite/nativehelper/ScopedLocalRef.h
|
||||
)
|
||||
set( YAPSQLITE3_ANDROID_DIRS
|
||||
Android/jni/sqlite
|
||||
Android/jni/sqlite/nativehelper
|
||||
)
|
||||
|
||||
add_component( sqlite3
|
||||
${YAPSQLITE3_SOURCES} )
|
||||
endif (ANDROID)
|
||||
|
||||
#sqlite3 is now in the system
|
||||
|
||||
set (SQLITE3_FOUND ON CACHE PRIVATE "")
|
||||
message (
|
||||
" * Sqlite3 Data-Base (http://www.sqlite3ql.org) is distributed with
|
||||
MYDDAS" )
|
||||
|
||||
list (APPEND MYDDAS_FLAGS -DMYDDAS_SQLITE3=1)
|
||||
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
|
||||
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
-DMYDDAS_SQLITE3=1)
|
||||
|
||||
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR} ${YAPSQLITE3_ANDROID_DIRS})
|
||||
|
||||
|
||||
add_component (Yapsqlite3 ${YAPSQLITE3_SOURCES} ${YAPSQLITE3_ANDROID_SOURCES})
|
||||
if (NOT ANDROID)
|
||||
#target_link_libraries(Yapsqlite3 libYap)
|
||||
set_target_properties (Yapsqlite3 PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
PREFIX ""
|
||||
)
|
||||
|
||||
# install(TARGETS Yapsqlite3
|
||||
# LIBRARY DESTINATION ${dlls}
|
||||
# ARCHIVE DESTINATION ${dlls}
|
||||
# )
|
||||
endif()
|
||||
|
||||
|
@ -11,11 +11,11 @@
|
||||
${CMAKE_SOURCE_DIR}/CXX
|
||||
)
|
||||
|
||||
add_custom_target ( swig ALL
|
||||
DEPENDS ${SWIG_CXX}
|
||||
add_custom_command (OUTPUT yap_swig.cpp
|
||||
COMMAND ${SWIG} -java -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_SOURCE_DIR}/CXX ${SWIG_SOURCES} -o yap_swig.cpp
|
||||
)
|
||||
|
||||
add_custom_command (OUTPUT ${SWIG_CXX}
|
||||
COMMAND ${SWIG} -java -outdir ${CMAKE_SWIG_OUTDIR} -c++ -addextern -I${CMAKE_SOURCE_DIR}/CXX -o ${SWIG_CXX}${SWIG_SOURCES}
|
||||
add_custom_target ( swig ALL
|
||||
DEPENDS yap_swig.cpp
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user