From ebd6f0a0c2c25683e28125140f61c2b757b27c66 Mon Sep 17 00:00:00 2001 From: vsc Date: Thu, 8 Jun 2017 22:16:52 +0100 Subject: [PATCH] windows trouble --- CMakeLists.txt | 1 - os/mem.c | 4 ++-- packages/python/CMakeLists.txt | 6 +++++- packages/python/python.c | 5 +++++ packages/python/python.h | 1 + packages/python/swig/CMakeLists.txt | 6 +++++- packages/python/swig/setup.py.in | 3 ++- packages/real/real.c | 3 +++ packages/swig/yap.i | 12 ++++++------ 9 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd5d142b4..ecd4ef4f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,6 @@ option(BUILD_SHARED_LIBS "Build shared library" ON) set (CMAKE_POSITION_INDEPENDENT_CODE TRUE) set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - include(Prelims NO_POLICY_SCOPE) include(Sources NO_POLICY_SCOPE) diff --git a/os/mem.c b/os/mem.c index 22678ee43..66994073a 100644 --- a/os/mem.c +++ b/os/mem.c @@ -188,7 +188,7 @@ bool Yap_set_stream_to_buf(StreamDesc *st, const char *buf, size_t nchars) { flags = Input_Stream_f | InMemory_Stream_f; st->vfs = NULL; Yap_initStream(st - GLOBAL_Stream, f, NULL, TermNil, LOCAL_encoding, flags, - AtomRead); + AtomRead, NULL); // like any file stream. /* currently these streams are not seekable */ st->status = Input_Stream_f | InMemory_Stream_f; @@ -222,7 +222,7 @@ int Yap_open_buf_read_stream(const char *buf, size_t nchars, encoding_t *encp, st->file = f = NULL; flags = Input_Stream_f | InMemory_Stream_f; st->vfs = NULL; - Yap_initStream(sno, f, NULL, TermNil, encoding, flags, AtomRead); + Yap_initStream(sno, f, NULL, TermNil, encoding, flags, AtomRead, NULL); // like any file stream. /* currently these streams are not seekable */ st->status = Input_Stream_f | InMemory_Stream_f; diff --git a/packages/python/CMakeLists.txt b/packages/python/CMakeLists.txt index f75afb6da..94690608b 100644 --- a/packages/python/CMakeLists.txt +++ b/packages/python/CMakeLists.txt @@ -9,9 +9,13 @@ set (CMAKE_POSITION_INDEPENDENT_CODE TRUE) add_library (YAPPython SHARED ${PYTHON_SOURCES}) +# arithmetic hassle. +set_property(TARGET YAPPython PROPERTY CXX_STANDARD 11) +set_property(TARGET YAPPython PROPERTY CXX_STANDARD_REQUIRED ON) + target_link_libraries(YAPPython libYap ${PYTHON_LIBRARY}) -set_property( SOURCE ${PYTHON_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1) +set_property( SOURCE ${PYTHON_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 _GNU-SOURCE=1) set (PYTHON_PL python.pl) diff --git a/packages/python/python.c b/packages/python/python.c index 31054ee05..5d7ae1e26 100644 --- a/packages/python/python.c +++ b/packages/python/python.c @@ -25,8 +25,13 @@ VFS_t pystream; static void * py_open( const char *name, const char *io_mode) { +#if HAVE_STRCASESTR if (strcasestr(name,"//python/")== name) name += strlen("//python/"); + #else + if (strstr(name,"//python/")== name) + name += strlen("//python/"); +#endif // we assume object is already open, so there is no need to open it. PyObject *stream = string_to_python( name, true, NULL); if (stream == Py_None) diff --git a/packages/python/python.h b/packages/python/python.h index 8eaaddfa8..0469602ec 100644 --- a/packages/python/python.h +++ b/packages/python/python.h @@ -13,6 +13,7 @@ #endif #include + #include #ifdef HAVE_STAT #undef HAVE_STATa diff --git a/packages/python/swig/CMakeLists.txt b/packages/python/swig/CMakeLists.txt index b76a25be8..82a2879ca 100644 --- a/packages/python/swig/CMakeLists.txt +++ b/packages/python/swig/CMakeLists.txt @@ -32,10 +32,14 @@ else() set_target_properties ( ${SWIG_MODULE_Py2YAP_REAL_NAME} PROPERTIES NO_SONAME ON + CXXFLAGS "-include cmath " OUTPUT_NAME _yap LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DEPENDS YAPPython YAPPython YAP++ ) + +SET( CMAKE_CXX_FLAGS " -include cmath ${CMAKE_CXX_FLAGS} " ) + # inform we are compiling YAP # s used in MSYS # @@ -44,7 +48,7 @@ else() # RUNTIME DESTINATION ${PYTHON_MODULE_PATH} # ARCHIVE DESTINATION ${PYTHON_MODULE_PATH} # LIBRARY DESTINATION ${PYTHON_MODULE_PATH} - # ) + # )x set (dlls $ diff --git a/packages/python/swig/setup.py.in b/packages/python/swig/setup.py.in index 1a585c489..e282acdfb 100644 --- a/packages/python/swig/setup.py.in +++ b/packages/python/swig/setup.py.in @@ -78,12 +78,13 @@ extensions=[Extension('_yap', native_sources, define_macros = [('MAJOR_VERSION', '1'), ('MINOR_VERSION', '0'), ('_YAP_NOT_INSTALLED_', '1'), + ('_GNU_SOURCE', '1'), ('YAP_PYTHON', '1')], runtime_library_dirs=['yap4py','${libdir}','${bindir}'], swig_opts=['-modern', '-c++', '-py3','-I${RELATIVE_SOURCE}/CXX'], library_dirs=['../../..','../../../CXX','../../packages/python',"${dlls}","${bindir}", '.'], extra_link_args=my_extra_link_args, - extra_compile_args=['-g3','-O0'], + extra_compile_args=['-std=c++11','-g3','-O0'], libraries=['Yap','${GMP_LIBRARIES}'], include_dirs=['../../..', '${GMP_INCLUDE_DIRS}', diff --git a/packages/real/real.c b/packages/real/real.c index f0521cbb2..fd38bfce0 100644 --- a/packages/real/real.c +++ b/packages/real/real.c @@ -3,6 +3,7 @@ #include "rconfig.h" #if HAVE_R_H || !defined(_YAP_NOT_INSTALLED_) #include +#undef ERROR #if HAVE_R_EMBEDDED_H #include #endif @@ -1873,7 +1874,9 @@ static foreign_t init_R(void) { R_SignalHandlers = 0; #endif Rf_initEmbeddedR(argc, argv); +#ifndef WIN32 R_CStackLimit = -1; +#endif return TRUE; } diff --git a/packages/swig/yap.i b/packages/swig/yap.i index 6804944fe..9956bfe79 100644 --- a/packages/swig/yap.i +++ b/packages/swig/yap.i @@ -1,13 +1,13 @@ -#ifdef SWIGPYTHON -%{ -#include - %} -#endif + %{ +#include #include extern "C"{ - #include "Yap.h" +#ifdef SWIGPYTHON +#include +#endif +#include "Yap.h" } %}