Skip to content

Commit

Permalink
Make Clucene compilable with MXE
Browse files Browse the repository at this point in the history
This patch is mostly based on the work of GoldenCeetha devs:
http://gc.stand2surf.net/mxe.cc/
  • Loading branch information
bag0 committed Oct 15, 2018
1 parent e8e3d20 commit dbbe188
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -163,7 +163,7 @@ IF ( BUILD_CONTRIBS )
SET(BUILD_CONTRIBS_LIB 1)
ENDIF ( BUILD_CONTRIBS )
IF ( BUILD_CONTRIBS_LIB )
ADD_SUBDIRECTORY (src/contribs-lib EXCLUDE_FROM_ALL)
ADD_SUBDIRECTORY (src/contribs-lib)
ENDIF ( BUILD_CONTRIBS_LIB )


Expand Down
4 changes: 4 additions & 0 deletions src/core/CLucene/store/FSDirectory.cpp
Expand Up @@ -582,7 +582,9 @@ void FSDirectory::FSIndexInput::readInternal(uint8_t* b, const int32_t len) {
void FSDirectory::close(){
SCOPED_LOCK_MUTEX(DIRECTORIES_LOCK)
{
#if !defined(_CL_DISABLE_MULTITHREADING)
THIS_LOCK.lock();
#endif

CND_PRECONDITION(directory[0]!=0,"directory is not open");

Expand All @@ -595,7 +597,9 @@ void FSDirectory::FSIndexInput::readInternal(uint8_t* b, const int32_t len) {
return;
}
}
#if !defined(_CL_DISABLE_MULTITHREADING)
THIS_LOCK.unlock();
#endif
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/libclucene-core.pc.cmake
Expand Up @@ -6,6 +6,6 @@ includedir=${prefix}/include:${prefix}/include/CLucene/ext
Name: libclucene
Description: CLucene - a C++ search engine, ported from the popular Apache Lucene
Version: @CLUCENE_VERSION_MAJOR@.@CLUCENE_VERSION_MINOR@.@CLUCENE_VERSION_REVISION@.@CLUCENE_VERSION_PATCH@
Libs: -L${prefix}/@LIB_DESTINATION@/ -lclucene-core
Cflags: -I${prefix}/include -I${prefix}/include/CLucene/ext
Libs: -L${prefix}/@LIB_DESTINATION@/ -lclucene-core -lclucene-shared
Cflags: -I${prefix}/include -I${prefix}/include/CLucene/ext -I@LUCENE_SYS_INCLUDES@
~
3 changes: 3 additions & 0 deletions src/shared/CLucene/LuceneThreads.h
Expand Up @@ -30,6 +30,9 @@ class CLuceneThreadIdCompare;
#define _LUCENE_ATOMIC_INC(theInteger) (++(*theInteger))
#define _LUCENE_ATOMIC_DEC(theInteger) (--(*theInteger))
#define _LUCENE_ATOMIC_INT int

#define _LUCENE_ATOMIC_INT_SET(x, v) x=v
#define _LUCENE_ATOMIC_INT_GET(x) x
#else
#if defined(_LUCENE_DONTIMPLEMENT_THREADMUTEX)
//do nothing
Expand Down
3 changes: 3 additions & 0 deletions src/shared/CLucene/util/Misc.cpp
Expand Up @@ -466,6 +466,8 @@ bool Misc::listFiles(const char* directory, std::vector<std::string>& files, boo
std::string Misc::toString(const bool value){
return value ? "true" : "false";
}

#if !defined(_CL_DISABLE_MULTITHREADING)
std::string Misc::toString(_LUCENE_THREADID_TYPE value){
static int32_t nextindex = 0;
static std::map<_LUCENE_THREADID_TYPE, int32_t> ids;
Expand All @@ -474,6 +476,7 @@ std::string Misc::toString(_LUCENE_THREADID_TYPE value){
}
return toString(ids[value]);
}
#endif
std::string Misc::toString(const int32_t value){
char buf[20];
TCHAR tbuf[20];
Expand Down
4 changes: 3 additions & 1 deletion src/shared/CLucene/util/Misc.h
Expand Up @@ -67,7 +67,9 @@ CL_NS_DEF(util)

static std::string toString(const int32_t value);
static std::string toString(const int64_t value);
static std::string toString(const _LUCENE_THREADID_TYPE value);
#if !defined(_CL_DISABLE_MULTITHREADING)
static std::string toString(const _LUCENE_THREADID_TYPE value);
#endif
static std::string toString(const bool value);
static std::string toString(const float_t value);
static std::string toString(const TCHAR* s, int32_t len=-1);
Expand Down
4 changes: 2 additions & 2 deletions src/shared/CMakeLists.txt
Expand Up @@ -214,9 +214,9 @@ ENDIF ( NOT HAVE_SYMBOL__T )
IF ( CMAKE_USE_WIN32_THREADS_INIT )
SET ( _CL_HAVE_WIN32_THREADS 1 )
ENDIF ( CMAKE_USE_WIN32_THREADS_INIT )
IF ( CMAKE_USE_PTHREADS_INIT )
IF ( CMAKE_USE_PTHREADS_INIT AND NOT _CL_HAVE_WIN32_THREADS)
SET ( _CL_HAVE_PTHREAD 1 )
ENDIF (CMAKE_USE_PTHREADS_INIT)
ENDIF (CMAKE_USE_PTHREADS_INIT AND NOT _CL_HAVE_WIN32_THREADS)
IF ( CMAKE_USE_SPROC_INIT OR CMAKE_HP_PTHREADS_INIT )
MESSAGE(FATAL_ERROR "Threads library not implemented")
ENDIF( CMAKE_USE_SPROC_INIT OR CMAKE_HP_PTHREADS_INIT )
Expand Down
2 changes: 1 addition & 1 deletion src/shared/cmake/MacroCheckGccVisibility.cmake
Expand Up @@ -15,7 +15,7 @@ macro(MACRO_CHECK_GCC_VISIBILITY GccVisibility)
# get the gcc version
exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)

string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
string (REGEX MATCH "[3-9]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
if (NOT _gcc_version)

# clang reports: clang version 1.1 (trunk 95754)
Expand Down

0 comments on commit dbbe188

Please sign in to comment.