find iconv by cmake, dont use and build iconv for android
This commit is contained in:
parent
17f3f11b7e
commit
7cad479837
@ -812,7 +812,7 @@ clean_iconv :
|
||||
|
||||
apk: $(PATHCFGFILE) assets $(IRRLICHT_LIB) $(CURL_LIB) $(LEVELDB_TARGET) \
|
||||
$(OPENAL_LIB) $(OGG_LIB) prep_srcdir $(ROOT)/jni/src/android_version.h \
|
||||
$(MSGPACK_TARGET) $(ICONV_LIB) \
|
||||
$(MSGPACK_TARGET) \
|
||||
sqlite3_download
|
||||
@export NDEBUG=$$NDEBUG; $(MAKE) manifest; \
|
||||
export PATH=$$PATH:${SDKFOLDER}/platform-tools:${ANDROID_NDK}; \
|
||||
|
@ -49,10 +49,10 @@ LOCAL_MODULE := crypto
|
||||
LOCAL_SRC_FILES := deps/openssl/libcrypto.a
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := iconv
|
||||
LOCAL_SRC_FILES := deps/libiconv/lib/.libs/libiconv.a
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
#include $(CLEAR_VARS)
|
||||
#LOCAL_MODULE := iconv
|
||||
#LOCAL_SRC_FILES := deps/libiconv/lib/.libs/libiconv.a
|
||||
#include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := msgpack
|
||||
@ -105,7 +105,6 @@ endif
|
||||
LOCAL_C_INCLUDES := \
|
||||
jni/src/enet/include \
|
||||
deps/msgpack/include \
|
||||
deps/libiconv/include \
|
||||
deps/msgpack/src \
|
||||
jni/src jni/src/sqlite \
|
||||
jni/src/script \
|
||||
@ -119,9 +118,10 @@ LOCAL_C_INCLUDES := \
|
||||
deps/libvorbis-libogg-android/jni/include \
|
||||
deps/leveldb/include \
|
||||
deps/sqlite/
|
||||
# deps/libiconv/include \
|
||||
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
jni/src/util/utf8.cpp \
|
||||
jni/src/gsmapper.cpp \
|
||||
jni/src/guiTextInputMenu.cpp \
|
||||
jni/src/FMColoredString.cpp \
|
||||
@ -367,8 +367,8 @@ LOCAL_SRC_FILES += \
|
||||
jni/src/enet/protocol.c \
|
||||
jni/src/enet/unix.c
|
||||
|
||||
LOCAL_STATIC_LIBRARIES += iconv msgpack
|
||||
|
||||
LOCAL_STATIC_LIBRARIES += msgpack
|
||||
# iconv
|
||||
|
||||
ifeq ($(HAVE_LEVELDB), 1)
|
||||
LOCAL_STATIC_LIBRARIES += LevelDB
|
||||
|
16
cmake/Modules/FindIconv.cmake
Normal file
16
cmake/Modules/FindIconv.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY)
|
||||
find_path(ICONV_INCLUDE_DIR iconv.h)
|
||||
|
||||
if(APPLE)
|
||||
find_library(ICONV_LIBRARY
|
||||
NAMES libiconv.dylib
|
||||
PATHS "/usr/lib"
|
||||
DOC "IConv library")
|
||||
endif(APPLE)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
||||
FIND_LIBRARY(ICONV_LIBRARY NAMES iconv)
|
||||
endif()
|
||||
|
||||
#include(FindPackageHandleStandardArgs)
|
||||
#find_package_handle_standard_args(iconv DEFAULT_MSG ICONV_INCLUDE_DIR)
|
@ -231,6 +231,14 @@ else()
|
||||
mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
find_package(Iconv)
|
||||
if(ICONV_INCLUDE_DIR)
|
||||
set(USE_ICONV 1)
|
||||
message(STATUS "iconv.h found: ${ICONV_INCLUDE_DIR}")
|
||||
else()
|
||||
set(USE_ICONV 0)
|
||||
message(STATUS "iconv.h NOT found")
|
||||
endif()
|
||||
|
||||
if(BUILD_CLIENT)
|
||||
OPTION(ENABLE_GETTEXT "Use GetText for internationalization" TRUE)
|
||||
@ -255,7 +263,6 @@ else()
|
||||
message(STATUS "GetText disabled.")
|
||||
endif()
|
||||
|
||||
|
||||
if(BUILD_CLIENT)
|
||||
option(ENABLE_SOUND "Enable sound" TRUE)
|
||||
else()
|
||||
|
@ -32,6 +32,7 @@
|
||||
#cmakedefine01 ENABLE_THREADS
|
||||
#cmakedefine01 MINETEST_PROTO
|
||||
#cmakedefine01 STATIC_BUILD
|
||||
#cmakedefine01 USE_ICONV
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -34,13 +34,34 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <iconv.h>
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
std::wstring narrow_to_wide(const std::string &input) {
|
||||
size_t outbuf_size = input.size() + 1;
|
||||
wchar_t *outbuf = new wchar_t[outbuf_size];
|
||||
memset(outbuf, 0, outbuf_size * sizeof(wchar_t));
|
||||
MultiByteToWideChar(CP_UTF8, 0, input.c_str(), input.size(), outbuf, outbuf_size);
|
||||
std::wstring out(outbuf);
|
||||
delete[] outbuf;
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string wide_to_narrow(const std::wstring &input) {
|
||||
size_t outbuf_size = (input.size() + 1) * 6;
|
||||
char *outbuf = new char[outbuf_size];
|
||||
memset(outbuf, 0, outbuf_size);
|
||||
WideCharToMultiByte(CP_UTF8, 0, input.c_str(), input.size(), outbuf, outbuf_size, NULL, NULL);
|
||||
std::string out(outbuf);
|
||||
delete[] outbuf;
|
||||
return out;
|
||||
}
|
||||
|
||||
#elif USE_ICONV
|
||||
|
||||
#include <iconv.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
size_t convert(const char *to, const char *from, char *outbuf, size_t outbuf_size, char *inbuf, size_t inbuf_size) {
|
||||
iconv_t cd = iconv_open(to, from);
|
||||
|
||||
@ -57,7 +78,6 @@ size_t convert(const char *to, const char *from, char *outbuf, size_t outbuf_siz
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
std::wstring narrow_to_wide(const std::string &input) {
|
||||
size_t inbuf_size = input.length() + 1;
|
||||
// maximum possible size, every character is sizeof(wchar_t) bytes
|
||||
@ -95,13 +115,16 @@ std::string wide_to_narrow(const std::wstring &input) {
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "utf8.cpp"
|
||||
|
||||
std::wstring narrow_to_wide(const std::string &input) {
|
||||
size_t outbuf_size = input.size() + 1;
|
||||
wchar_t *outbuf = new wchar_t[outbuf_size];
|
||||
memset(outbuf, 0, outbuf_size * sizeof(wchar_t));
|
||||
irr::core::utf8ToWchar(input.c_str(), outbuf, outbuf_size * sizeof(wchar_t));
|
||||
/* irr::core:: */ utf8ToWchar(input.c_str(), outbuf, outbuf_size * sizeof(wchar_t));
|
||||
std::wstring out(outbuf);
|
||||
delete[] outbuf;
|
||||
return out;
|
||||
@ -114,34 +137,13 @@ std::string wide_to_narrow(const std::wstring &input) {
|
||||
size_t inbuf_size = (input.length() + 1);
|
||||
wchar_t *inbuf = new wchar_t[inbuf_size];
|
||||
memcpy(inbuf, input.c_str(), inbuf_size * sizeof(wchar_t));
|
||||
irr::core::wcharToUtf8(inbuf, outbuf, outbuf_size);
|
||||
/* irr::core:: */ wcharToUtf8(inbuf, outbuf, outbuf_size);
|
||||
std::string out(outbuf);
|
||||
delete[] outbuf;
|
||||
delete[] inbuf;
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
std::wstring narrow_to_wide(const std::string &input) {
|
||||
size_t outbuf_size = input.size() + 1;
|
||||
wchar_t *outbuf = new wchar_t[outbuf_size];
|
||||
memset(outbuf, 0, outbuf_size * sizeof(wchar_t));
|
||||
MultiByteToWideChar(CP_UTF8, 0, input.c_str(), input.size(), outbuf, outbuf_size);
|
||||
std::wstring out(outbuf);
|
||||
delete[] outbuf;
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string wide_to_narrow(const std::wstring &input) {
|
||||
size_t outbuf_size = (input.size() + 1) * 6;
|
||||
char *outbuf = new char[outbuf_size];
|
||||
memset(outbuf, 0, outbuf_size);
|
||||
WideCharToMultiByte(CP_UTF8, 0, input.c_str(), input.size(), outbuf, outbuf_size, NULL, NULL);
|
||||
std::string out(outbuf);
|
||||
delete[] outbuf;
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -13,13 +13,14 @@ now used only for android
|
||||
// This file is part of the "Irrlicht Engine". The UTF-8 functions are from physfs,
|
||||
// under the zlib license, reproduced below.
|
||||
|
||||
#include "irrTypes.h"
|
||||
#include "irrString.h"
|
||||
//#include <irrTypes.h>
|
||||
//#include <irrString.h>
|
||||
#include "../irrlichttypes.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
//namespace irr
|
||||
//{
|
||||
//namespace core
|
||||
//{
|
||||
|
||||
/*
|
||||
Copyright (c) 2001-2011 Ryan C. Gordon and others.
|
||||
@ -386,6 +387,6 @@ void wcharToUtf8(const wchar_t *in, char *out, const u64 len)
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
//} // end namespace core
|
||||
//} // end namespace irr
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user