ExportMemory
This commit is contained in:
parent
7219992154
commit
1289899918
17
C/text.c
17
C/text.c
@ -185,6 +185,23 @@ void *Realloc(void *pt, size_t sz USES_REGS) {
|
||||
return o + 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export a local memory object as a RO object to the outside world, that is, recovering as much storage as one can.
|
||||
* @param pt pointer to object
|
||||
* @return new object
|
||||
*/
|
||||
const void *MallocExportAsRO(const void *pt USES_REGS) {
|
||||
struct mblock *old = pt, *o;
|
||||
if (o == NULL)
|
||||
return NULL;
|
||||
old--;
|
||||
release_block(old);
|
||||
size_t sz = strlen(pt)+1;
|
||||
memcpy((void*)pt,old,sz);
|
||||
return realloc((void *)pt, sz);
|
||||
}
|
||||
|
||||
void Free(void *pt USES_REGS) {
|
||||
struct mblock *o = pt;
|
||||
o--;
|
||||
|
60
C/yap-args.c
60
C/yap-args.c
@ -176,8 +176,8 @@ static void consult(const char *b_file USES_REGS) {
|
||||
osno = 0;
|
||||
c_stream = YAP_InitConsult(YAP_BOOT_MODE, b_file, full, &oactive);
|
||||
if (c_stream < 0) {
|
||||
pop_text_stack(lvl);
|
||||
fprintf(stderr, "[ FATAL ERROR: could not open stream %s ]\n", b_file);
|
||||
pop_text_stack(lvl);
|
||||
exit(1);
|
||||
}
|
||||
if (!Yap_AddAlias(AtomLoopStream, c_stream)) {
|
||||
@ -456,7 +456,6 @@ char *location(YAP_init_args *iap, const char *inp) {
|
||||
static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
||||
const char *filename) {
|
||||
int lvl = push_text_stack();
|
||||
char *out = Malloc(YAP_FILENAME_MAX + 1);
|
||||
const char *inp;
|
||||
if (filename) {
|
||||
if (Yap_IsAbsolutePath(filename, true)) {
|
||||
@ -466,11 +465,12 @@ static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
||||
int i = 0;
|
||||
while ((inp = paths[i++]) != NULL) {
|
||||
char *o = location(iap, inp);
|
||||
const char *rc;
|
||||
if (filename && o) {
|
||||
strcat(o, "/");
|
||||
strcat(o, filename);
|
||||
if ((o = Yap_AbsoluteFile(o, false))) {
|
||||
return pop_output_text_stack(lvl, o);
|
||||
if ((rc = Yap_AbsoluteFile(o, false))) {
|
||||
return pop_output_text_stack(lvl, rc);
|
||||
}
|
||||
} else if (o && Yap_isDirectory(o)) {
|
||||
return pop_output_text_stack(lvl, o);
|
||||
@ -484,27 +484,51 @@ static void Yap_set_locations(YAP_init_args *iap) {
|
||||
config_t t, *template;
|
||||
|
||||
template = cfg(&t);
|
||||
Yap_ROOTDIR = find_directory(iap, template->root, NULL);
|
||||
Yap_LIBDIR = find_directory(iap, template->lib, NULL);
|
||||
// Yap_BINDIR = find_directory(iap, template->bin, NULL);
|
||||
Yap_SHAREDIR = find_directory(iap, template->share, NULL);
|
||||
Yap_DLLDIR = find_directory(iap, template->dll, NULL);
|
||||
Yap_PLDIR = find_directory(iap, template->pl, NULL);
|
||||
Yap_BOOTPLDIR = find_directory(iap, template->bootpldir, NULL);
|
||||
#if __ANDROID__
|
||||
Yap_ROOTDIR = "/assets";
|
||||
Yap_LIBDIR = "/assets/lib";
|
||||
// Yap_BINDIR = MallocExportAsROfind_directory(iap, template->bin, NULL);
|
||||
Yap_SHAREDIR = "/assets/Yap";
|
||||
Yap_DLLDIR = "/assets/lib";
|
||||
Yap_PLDIR = "/assets/Yap";
|
||||
Yap_BOOTPLDIR = "/assets/Yap/pl";
|
||||
if (iap->PrologBootFile == NULL)
|
||||
iap->PrologBootFile = "boot.yap";
|
||||
Yap_BOOTFILE = "/assets/Yap/pl/boot.yap";
|
||||
Yap_COMMONSDIR =NULL;
|
||||
if (iap->SavedState == NULL) {
|
||||
if (iap->OutputSavedState)
|
||||
iap->SavedState = iap->OutputSavedState;
|
||||
else
|
||||
iap->SavedState = "startup.yss";
|
||||
}
|
||||
Yap_STARTUP = NULL;
|
||||
iap->OutputSavedState = "startup.yss";
|
||||
Yap_OUTPUT_STARTUP = NULL;
|
||||
#else
|
||||
Yap_ROOTDIR = MallocExportAsRO(find_directory(iap, template->root, NULL) );
|
||||
Yap_LIBDIR = MallocExportAsRO( find_directory(iap, template->lib, NULL) );
|
||||
// Yap_BINDIR = MallocExportAsROfind_directory(iap, template->bin, NULL);
|
||||
Yap_SHAREDIR = MallocExportAsRO( find_directory(iap, template->share, NULL) );
|
||||
Yap_DLLDIR = MallocExportAsRO( find_directory(iap, template->dll, NULL) );
|
||||
Yap_PLDIR = MallocExportAsRO( find_directory(iap, template->pl, NULL) );
|
||||
Yap_BOOTPLDIR = MallocExportAsRO( find_directory(iap, template->bootpldir, NULL) );
|
||||
if (iap->PrologBootFile == NULL)
|
||||
iap->PrologBootFile = "boot.yap";
|
||||
Yap_BOOTFILE = find_directory(iap, template->bootpldir, iap->PrologBootFile);
|
||||
Yap_COMMONSDIR = find_directory(iap, template->commons, NULL);
|
||||
Yap_BOOTFILE = MallocExportAsRO( find_directory(iap, template->bootpldir, iap->PrologBootFile) ) ;
|
||||
Yap_COMMONSDIR = MallocExportAsRO( find_directory(iap, template->commons, NULL) );
|
||||
if (iap->SavedState == NULL) {
|
||||
if (iap->OutputSavedState)
|
||||
iap->SavedState = iap->OutputSavedState;
|
||||
else
|
||||
iap->SavedState = "startup.yss";
|
||||
}
|
||||
Yap_STARTUP = find_directory(iap, template->ss, iap->SavedState);
|
||||
Yap_STARTUP = MallocExportAsRO( find_directory(iap, template->ss, iap->SavedState));
|
||||
if (iap->OutputSavedState == NULL)
|
||||
iap->OutputSavedState = "startup.yss";
|
||||
Yap_OUTPUT_STARTUP = find_directory(iap, template->ss, iap->OutputSavedState);
|
||||
Yap_OUTPUT_STARTUP = MallocExportAsRO( find_directory(iap, template->ss, iap->OutputSavedState) );
|
||||
|
||||
#endif
|
||||
if (Yap_ROOTDIR)
|
||||
setAtomicGlobalPrologFlag(HOME_FLAG,
|
||||
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
|
||||
@ -1108,7 +1132,7 @@ static void init_hw(YAP_init_args *yap_init, struct ssz_t *spt) {
|
||||
#if __ANDROID__
|
||||
|
||||
// if (yap_init->assetManager)
|
||||
Yap_InitAssetManager();
|
||||
//Yap_InitAssetManager();
|
||||
|
||||
#endif
|
||||
|
||||
@ -1149,11 +1173,11 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
|
||||
struct ssz_t minfo;
|
||||
|
||||
if (YAP_initialized)
|
||||
return YAP_FOUND_BOOT_ERROR;
|
||||
/* ignore repeated calls to YAP_Init */
|
||||
return YAP_FOUND_BOOT_ERROR;
|
||||
if (!LOCAL_TextBuffer)
|
||||
LOCAL_TextBuffer = Yap_InitTextAllocator();
|
||||
|
||||
/* ignore repeated calls to YAP_Init */
|
||||
Yap_embedded = yap_init->Embedded;
|
||||
|
||||
minfo.Trail = 0, minfo.Stack = 0, minfo.Trail = 0;
|
||||
|
@ -515,19 +515,13 @@ endif (WITH_CALL_TRACER)
|
||||
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1)
|
||||
|
||||
include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src)
|
||||
|
||||
include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src )
|
||||
|
||||
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||
|
||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||
|
||||
if (ANDROID)
|
||||
include_directories(
|
||||
packages/myddas/sqlite3/src/Android/jni/sqlite
|
||||
packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
if (MYSQL_FOUND)
|
||||
@ -572,7 +566,10 @@ if (WIN32 OR ANDROID)
|
||||
if (WIN32 AND WITH_PYTHON)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:Py4YAP>)
|
||||
endif ()
|
||||
if (ANDROID)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAPJava>)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
include(Sources)
|
||||
|
||||
@ -697,8 +694,18 @@ endif ()
|
||||
|
||||
|
||||
IF ( ANDROID)
|
||||
add_subDIRECTORY(packages/swig )
|
||||
target_link_libraries(libYap android log)
|
||||
set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||
set(CMAKE_SWIG_OUTPUT ${YAP_APP_DIR}/src/generated/jni )
|
||||
set( SWIG_MODULE_NAME pt.up.yap.lib )
|
||||
|
||||
add_subDIRECTORY(packages/swig )
|
||||
|
||||
|
||||
|
||||
|
||||
#target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../../../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log )
|
||||
|
||||
target_link_libraries(libYap android log )
|
||||
ENDIF ()
|
||||
|
||||
|
||||
|
@ -99,12 +99,15 @@ X_API extern void YAP_UserBackCutCPredicate(const char *name,
|
||||
|
||||
X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp);
|
||||
|
||||
|
||||
#if YAP_PYTHON
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
extern bool python_in_python;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
class YAPEngine;
|
||||
|
10
CXX/yapq.hh
10
CXX/yapq.hh
@ -187,6 +187,8 @@ public:
|
||||
|
||||
/// @brief Setup all arguments to a new engine
|
||||
struct X_API YAPEngineArgs : YAP_init_args {
|
||||
|
||||
|
||||
public:
|
||||
YAPEngineArgs() {
|
||||
const std::string *s = new std::string("startup.yss");
|
||||
@ -195,6 +197,8 @@ public:
|
||||
#if YAP_PYTHON
|
||||
Embedded = true;
|
||||
python_in_python = Py_IsInitialized();
|
||||
#endif
|
||||
#if __ANDROID__
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -269,11 +273,6 @@ public:
|
||||
|
||||
inline bool getFastBoot() { return FastBoot; };
|
||||
|
||||
#if __ANDROID__
|
||||
//> export ResoourceManager
|
||||
inline void setAssetManager(AAssetManager *mgr) { assetManager = mgr; };
|
||||
#endif
|
||||
|
||||
inline void setArgc(int fl) { Argc = fl; };
|
||||
|
||||
inline int getArgc() { return Argc; };
|
||||
@ -281,6 +280,7 @@ public:
|
||||
inline void setArgv(char **fl) { Argv = fl; };
|
||||
|
||||
inline char **getArgv() { return Argv; };
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ extern void Free(void *buf USES_REGS);
|
||||
|
||||
extern void *MallocAtLevel(size_t sz, int atL USES_REGS);
|
||||
#define BaseMalloc(sz) MallocAtLevel(sz, 1)
|
||||
extern void *export_block(void *blk);
|
||||
extern const void *MallocExportAsRO(const void *blk);
|
||||
|
||||
#ifndef Yap_Min
|
||||
#define Yap_Min(x, y) (x < y ? x : y)
|
||||
|
@ -11,18 +11,18 @@
|
||||
|
||||
if (ANDROID)
|
||||
|
||||
set( GMP_LOC ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
||||
if (EXISTS ${GMP_LOC} )
|
||||
message("Looking good for ${GMP_LOC}")
|
||||
set(GMP_INCLUDE_DIRS ${GMP_LOC} CACHE PATH "include search path")
|
||||
set(GMP_LIBRARIES ${GMP_LOC}/libgmp.so CACHE FILEPATH "include search path")
|
||||
set(GMP_LIBRARIES_DIR ${GMP_LOC} CACHE PATH "include search path")
|
||||
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../../../gmp/${ANDROID_ABI} )
|
||||
if (EXISTS ${GMP_ROOT} )
|
||||
message("Looking good for ${GMP_ROOT}")
|
||||
set(GMP_INCLUDE_DIRS ${GMP_ROOT} CACHE PATH "include search path")
|
||||
set(GMP_LIBRARIES ${GMP_ROOT}/libgmp.so CACHE FILEPATH "include search path")
|
||||
set(GMP_LIBRARIES_DIR ${GMP_ROOT} CACHE PATH "include search path")
|
||||
else()
|
||||
message("Bad call: ${GMP_LOC} does not exist")
|
||||
message("Bad call: ${GMP_ROOT} does not exist")
|
||||
endif()
|
||||
find_path(GMP_INCLUDE_DIRS
|
||||
NAMES gmp.h
|
||||
HINTS ${GMP_LOC}
|
||||
HINTS ${GMP_ROOT}
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
find_library(GMP_LIBRARIES NAMES gmp
|
||||
PATHS
|
||||
|
@ -106,8 +106,6 @@ typedef struct vfs {
|
||||
YAP_Term (*parsers)(int sno); // a set of parsers that can read the
|
||||
// stream and generate a YAP_Term
|
||||
int (*writers)(int ch, int sno);
|
||||
/// convert a YAP_Term into this space
|
||||
const char *virtual_cwd;
|
||||
/** VFS dep
|
||||
endent area */
|
||||
cell_size_t priv[4];
|
||||
|
32
os/assets.c
32
os/assets.c
@ -40,6 +40,10 @@ static char SccsId[] = "%W% %G%";
|
||||
#include <android/asset_manager.h>
|
||||
#include <android/native_activity.h>
|
||||
|
||||
|
||||
extern void
|
||||
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager);
|
||||
|
||||
jobject *Yap_aref;
|
||||
JNIEnv *Yap_env;
|
||||
|
||||
@ -48,11 +52,10 @@ AAssetManager *Yap_assetManager(void)
|
||||
return AAssetManager_fromJava(Yap_env, Yap_aref);
|
||||
}
|
||||
|
||||
jboolean
|
||||
Java_pt_up_yap_app_YAPDroid_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
|
||||
void
|
||||
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
|
||||
Yap_aref = (*env)->NewGlobalRef(env,assetManager);
|
||||
Yap_env = env;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +64,6 @@ open_asset(VFS_t *me, int sno, const char *fname, const char *io_mode) {
|
||||
int mode;
|
||||
const void *buf;
|
||||
|
||||
|
||||
AAsset *am = NULL;
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, io_mode);
|
||||
if (strchr(io_mode, 'B'))
|
||||
@ -83,9 +85,9 @@ open_asset(VFS_t *me, int sno, const char *fname, const char *io_mode) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!am)
|
||||
if (!am) {
|
||||
return NULL;
|
||||
}
|
||||
// try not to use it as an asset
|
||||
off64_t sz = AAsset_getLength64(am), sz0 = 0;
|
||||
int fd;
|
||||
@ -157,10 +159,10 @@ static bool stat_a(VFS_t *me, const char *fname, vfs_stat *out) {
|
||||
out->st_dev = bf.st_dev;
|
||||
out->st_uid = bf.st_uid;
|
||||
out->st_gid = bf.st_gid;
|
||||
memcpy(&out->st_atimespec, (const void *) &out->st_atimespec, sizeof(struct timespec));
|
||||
memcpy(&out->st_mtimespec, (const void *) &out->st_mtimespec, sizeof(struct timespec));
|
||||
memcpy(&out->st_ctimespec, (const void *) &out->st_ctimespec, sizeof(struct timespec));
|
||||
memcpy(&out->st_birthtimespec, (const void *) &out->st_birthtimespec,
|
||||
memcpy(&out->st_atimespec, (const void *) &bf.st_atim, sizeof(struct timespec));
|
||||
memcpy(&out->st_mtimespec, (const void *) &bf.st_mtim, sizeof(struct timespec));
|
||||
memcpy(&out->st_ctimespec, (const void *) &bf.st_ctim, sizeof(struct timespec));
|
||||
memcpy(&out->st_birthtimespec, (const void *) &bf.st_ctim,
|
||||
sizeof(struct timespec));
|
||||
}
|
||||
AAsset *a = AAssetManager_open(Yap_assetManager(), fname, AASSET_MODE_UNKNOWN);
|
||||
@ -201,14 +203,17 @@ bool exists_a(VFS_t *me, const char *dirName) {
|
||||
}
|
||||
|
||||
|
||||
char virtual_cwd[YAP_FILENAME_MAX + 1];
|
||||
char *virtual_cwd;
|
||||
|
||||
static bool set_cwd(VFS_t *me, const char *dirName) {
|
||||
|
||||
chdir("/assets");
|
||||
if (virtual_cwd) {
|
||||
free(virtual_cwd);
|
||||
}
|
||||
virtual_cwd = malloc(strlen(dirName)+1);
|
||||
strcpy(virtual_cwd, dirName);
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid",
|
||||
"chdir %s", virtual_cwd);
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "chdir %s", virtual_cwd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -243,6 +248,7 @@ Yap_InitAssetManager(void) {
|
||||
me->enc = ENC_ISO_UTF8; /// how the file is encoded.
|
||||
me->parsers = NULL; /// a set of parsers that can read the stream and generate a term
|
||||
me->writers = NULL;
|
||||
virtual_cwd = NULL;
|
||||
LOCK(BGL);
|
||||
me->next = GLOBAL_VFS;
|
||||
GLOBAL_VFS = me;
|
||||
|
@ -94,7 +94,7 @@ bool Yap_isDirectory(const char *FileName) {
|
||||
|
||||
bool Yap_Exists(const char *f) {
|
||||
VFS_t *vfs;
|
||||
f = Yap_VFAlloc(f);
|
||||
// f = Yap_VFAlloc(f);
|
||||
if ((vfs = vfs_owner(f))) {
|
||||
return vfs->exists(vfs, f);
|
||||
}
|
||||
@ -340,7 +340,7 @@ static char *PrologPath(const char *Y, char *X) { return (char *)Y; }
|
||||
#define HAVE_REALPATH 1
|
||||
#endif
|
||||
|
||||
char virtual_cwd[YAP_FILENAME_MAX + 1];
|
||||
extern char *virtual_cwd;
|
||||
|
||||
bool Yap_ChDir(const char *path) {
|
||||
bool rc = false;
|
||||
@ -1121,7 +1121,7 @@ static int volume_header(char *file) {
|
||||
int Yap_volume_header(char *file) { return volume_header(file); }
|
||||
|
||||
const char *Yap_getcwd(char *cwd, size_t cwdlen) {
|
||||
if (virtual_cwd[0]) {
|
||||
if (virtual_cwd && virtual_cwd[0]) {
|
||||
if (!cwd) {
|
||||
cwd = malloc(cwdlen + 1);
|
||||
}
|
||||
@ -1135,6 +1135,9 @@ const char *Yap_getcwd(char *cwd, size_t cwdlen) {
|
||||
}
|
||||
return (char *)cwd;
|
||||
#endif
|
||||
if (!cwd) {
|
||||
cwd = malloc(cwdlen + 1);
|
||||
}
|
||||
return getcwd((char *)cwd, cwdlen);
|
||||
}
|
||||
|
||||
|
19
os/yapio.h
19
os/yapio.h
@ -152,30 +152,29 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
||||
return MkAtomTerm(Yap_ULookupAtom(cs));
|
||||
}
|
||||
|
||||
extern char *virtual_cwd;
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN char *Yap_VF(const char *path){
|
||||
char out[YAP_FILENAME_MAX+1], *p = (char *)path;
|
||||
extern char virtual_cwd[];
|
||||
char *out;
|
||||
|
||||
if ( virtual_cwd[0] == 0 || Yap_IsAbsolutePath(path, false)) {
|
||||
return p;
|
||||
out = (char *)malloc(YAP_FILENAME_MAX+1);
|
||||
if ( virtual_cwd == NULL || virtual_cwd[0] == 0 || !Yap_IsAbsolutePath(path, false)) {
|
||||
return (char *) path;
|
||||
}
|
||||
strcpy(out, virtual_cwd);
|
||||
strcat(out, "/" );
|
||||
strcat(out, p);
|
||||
strcpy(p, out);
|
||||
return p;
|
||||
strcat(out, path);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN char *Yap_VFAlloc(const char *path){
|
||||
char *out;
|
||||
extern char virtual_cwd[];
|
||||
|
||||
out = (char *)malloc(YAP_FILENAME_MAX+1);
|
||||
if ( virtual_cwd[0] == 0 || !Yap_IsAbsolutePath(path, false)) {
|
||||
return (char *)path;
|
||||
if ( virtual_cwd == NULL || virtual_cwd[0] == 0 || !Yap_IsAbsolutePath(path, false)) {
|
||||
return (char *) path;
|
||||
}
|
||||
strcpy(out, virtual_cwd);
|
||||
strcat(out, "/" );
|
||||
|
@ -664,15 +664,15 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) {
|
||||
}
|
||||
|
||||
X_API void init_sqlite3(void) {
|
||||
Yap_InitMYDDAS_SQLITE3Preds();
|
||||
Yap_InitBackMYDDAS_SQLITE3Preds();
|
||||
// Yap_InitMYDDAS_SQLITE3Preds();
|
||||
// Yap_InitBackMYDDAS_SQLITE3Preds();
|
||||
}
|
||||
|
||||
#if _ANDROID_
|
||||
JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env);
|
||||
//JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env);
|
||||
|
||||
JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env) {
|
||||
init_sqlite3();
|
||||
// JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env) {
|
||||
// init_sqlite3();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -3,8 +3,7 @@
|
||||
|
||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
||||
set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||
set( SWIG_MODULE_NAME pt.up.yap.lib )
|
||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/jni)
|
||||
set ( pllib ${YAP_APP_DIR}/src/generated/assets/Yap )
|
||||
|
||||
set ( SWIG_SOURCES ${CMAKE_SOURCE_DIR}/packages/swig/yap.i )
|
||||
@ -18,36 +17,41 @@ FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
||||
set (GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
||||
|
||||
|
||||
add_custom_target (pllib ALL
|
||||
add_custom_target (pllib
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib}
|
||||
)
|
||||
DEPENDS ${pl_library}
|
||||
)
|
||||
|
||||
add_custom_target (pllibpl ALL
|
||||
add_custom_target (pllibpl
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/pl
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${pllib}/pl
|
||||
DEPENDS pllib ${pl_boot_library}
|
||||
)
|
||||
add_custom_target (pllibos ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/os
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${pllib}/os
|
||||
|
||||
DEPENDS pllibpl ${pl_os_library}
|
||||
)
|
||||
|
||||
add_custom_command (OUTPUT swig_streamer.cpp
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o swig_streamer.cpp streamer.i
|
||||
add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp -oh ${CMAKE_SWIG_OUTPUT}/swig_streamer.hh streamer.i
|
||||
DEPENDS streamer.i
|
||||
)
|
||||
|
||||
add_custom_command (OUTPUT yap_swig.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/pl
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/os
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o yap_swig.cpp ${SWIG_SOURCES}
|
||||
DEPENDS pllibos ${SWIG_SOURCES} YAP++ ${pl_boot_library}
|
||||
)
|
||||
|
||||
add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp -oh ${CMAKE_SWIG_OUTPUT}/yap_swig.hh ${SWIG_SOURCES}
|
||||
DEPENDS pllibos ${SWIG_SOURCES} YAP++)
|
||||
|
||||
|
||||
|
||||
add_library(YAPJava OBJECT
|
||||
${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp
|
||||
${CMAKE_SWIG_OUTPUT}/yap_swig.cpp
|
||||
streamer.cpp
|
||||
)
|
||||
|
||||
|
||||
# GMP_FOUND - true if GMP/MPIR was found
|
||||
# GMP_INCLUDE_DIRS - include search path
|
||||
# GMP_LIBRARIES - libraries to link with
|
||||
@ -57,17 +61,10 @@ FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
||||
|
||||
|
||||
|
||||
add_lib(YAPJava
|
||||
yap_swig.cpp swig_streamer.cpp streamer.cpp streamer.h
|
||||
)
|
||||
target_link_libraries(YAPJava ${GMP_LIBRARIES} )
|
||||
|
||||
|
||||
target_link_libraries( YAPJava libYap android log)
|
||||
|
||||
if (FALSE)
|
||||
|
||||
set (SWIG_ADD_MODULE YAPJava SHARED CPLUPLUS ${SWIG_SOURCES} )
|
||||
set (SWIG_ADD_MODULE YAPJava SHARED CPLUSPLUS ${SWIG_SOURCES} )
|
||||
# Define swig module with given name and specified language
|
||||
|
||||
|
||||
|
@ -25,12 +25,12 @@ extern "C" {
|
||||
#include <yapio.h>
|
||||
#include <iopreds.h>
|
||||
|
||||
extern void Java_pt_up_yap_lib_streamerJNI_swig_1module_1init__(void);
|
||||
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void);
|
||||
|
||||
static VFS_t andstream;
|
||||
|
||||
void Java_pt_up_yap_lib_streamerJNI_swig_1module_1init__(void) {
|
||||
streamerInstance = 0;
|
||||
void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void) {
|
||||
// streamerInstance = 0;
|
||||
} ;
|
||||
|
||||
static std::string buff0;
|
||||
|
@ -31,6 +31,13 @@ class YAPEngine;
|
||||
|
||||
extern "C"{
|
||||
#include "Yap.h"
|
||||
|
||||
|
||||
|
||||
#if __ANDROID__
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
#include <py4yap.h>
|
||||
|
||||
|
Reference in New Issue
Block a user