Try to make mingw compilable

This commit is contained in:
Victor Shcherb 2012-06-04 23:49:39 +02:00
parent 01387328a3
commit 8f8b6baecf
20 changed files with 160 additions and 105 deletions

View file

@ -1,4 +1,4 @@
projects := protobuf zlib png skia expat freetype osmand
projects := protobuf zlib png pthread skia expat freetype osmand
.DEFAULT: installr
.PHONY: release debug clean installr installd

View file

@ -40,8 +40,10 @@ debug: build-debug/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE)
# Clean removes all objects
clean:
$(RM) -r build-release
$(RM) -r build-debug
$(RM) -r build-release/obj-$(TARGET)-$(ARCH)/
$(RM) -r build-debug/obj-$(TARGET)-$(ARCH)/
$(RM) -r build-release/$(TARGET)-$(ARCH)
$(RM) -r build-debug/$(TARGET)-$(ARCH)
# This target copies final output file to prebuilt folder
install-%: %
@ -68,7 +70,7 @@ build-debug/obj-$(TARGET)-$(ARCH)/%.cxx.o : % $(LOCAL_C_INCLUDES)
.SECONDEXPANSION:
build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(STATICLIB_EXT): $$(addprefix build-%/,$(OBJECTS))
@mkdir -p `dirname $@`
$(AR) rs $@ $?
$(AR) rs $@ $(addprefix build-$*/,$(OBJECTS))
# This target assembles dynamic library
.SECONDEXPANSION:

View file

@ -1,3 +1,8 @@
ifeq ($(ARCH),)
ARCH := x86
endif
############################################
############# NACL ### TARGET
ifeq ($(TARGET),nacl)
ifndef NACL_SDK_ROOT
$(error Set NACL_SDK_ROOT environment variable)
@ -14,19 +19,16 @@ OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
WARNINGS:=-Wno-long-long -Wall
TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib)
nacl_CFLAGS:=-pthread $(WARNINGS)
nacl_CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS)
nacl_CXX:=$(TC_PATH)/bin/i686-nacl-g++
nacl_CC:=$(TC_PATH)/bin/i686-nacl-gcc
nacl_STATICLIB_EXT := a
nacl_DYNAMICLIB_EXT := nexe
nacl_LIBRARY_PREFIX := lib
nacl_LDFLAGS := -lppapi
nacl_GLOBAL_INCLUDES=-I$(TC_PATH)/i686-nacl/usr/include
ifeq ($(ARCH),)
ARCH := x86
endif
CFLAGS:=-pthread $(WARNINGS)
CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS)
CXX:=$(TC_PATH)/bin/i686-nacl-g++
CC:=$(TC_PATH)/bin/i686-nacl-gcc
STATICLIB_EXT := a
DYNAMICLIB_EXT := nexe
LIBRARY_PREFIX := lib
LDFLAGS := -lppapi
GLOBAL_INCLUDES=-I../zlib/zlib_library -I$(TC_PATH)/i686-nacl/usr/include
RT_NOT_SUPPORTED :=
ifeq ($(ARCH),x86)
nacl_CFLAGS += -m32
@ -42,10 +44,12 @@ endif
else
############################################
### EVERYTHING ELSE REQUIRES JAVA_HOME #####
ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
endif
ARCH := x86
ifeq ($(TARGET),)
ifeq ($(shell uname),Darwin)
TARGET := darwin
@ -57,73 +61,50 @@ ifeq ($(TARGET),)
TARGET := win
endif
endif
ifeq ($(TARGET),)
TARGET := linux
endif
############################################
####### DEFAULT LINUX ########## TARGET
CXX := g++
CC := gcc
STRIP := strip
STATICLIB_EXT := a
DYNAMICLIB_EXT := so
LIBRARY_PREFIX := lib
LDFLAGS := -shared -Wl,-Bsymbolic
# Windows uses different path separators, because they hate me
############################################
####### Windows ########## TARGET
ifeq ($(TARGET),win)
sep := ;
else
sep := :
endif
CXX := i586-mingw32msvc-gcc
CC := i586-mingw32msvc-gcc
STRIP := i586-mingw32msvc-strip
WINDRES :=i586-mingw32msvc-windres
RANLIB := i586-mingw32msvc-ranlib
WINDRES := i586-mingw32msvc-windres
AR := i586-mingw32msvc-ar
GLOBAL_INCLUDES := -I../pthread/pthreads_library -I../zlib/zlib_library
RT_NOT_SUPPORTED := 1
COMMONFLAGS := -D_Windows -DXMD_H -DHAVE_BOOLEAN -DRT_NOT_SUPPORTED
CPP_FLAGS := $(COMMONFLAGS)
CFLAGS := -D_JNI_IMPLEMENTATION $(COMMONFLAGS)
STATICLIB_EXT := a
DYNAMICLIB_EXT := dll
LIBRARY_PREFIX := lib
LDFLAGS := -shared -Wl,-Bsymbolic
else ifeq ($(TARGET),cygwin)
############################################
####### Cygwin ########## TARGET
CXX := i686-pc-cygwin-g++
CC := i686-pc-cygwin-gcc
STRIP := i686-pc-cygwin-strip
LDFLAGS := -shared -Wl,--kill-at
CFLAGS := -D__int64="long long" -D_JNI_IMPLEMENTATION -D_REENTRANT -D_GNU_SOURCE
CXXFLAGS := -D__int64="long long" -D_JNI_IMPLEMENTATION -D_REENTRANT -D_GNU_SOURCE
STATICLIB_EXT := lib
DYNAMICLIB_EXT := dll
LIBRARY_PREFIX := # empty
endif
###########################################
# os=Default is meant to be generic unix/linux
linux_CXX := g++
linux_CC := gcc
linux_STRIP := strip
linux_STATICLIB_EXT := a
linux_DYNAMICLIB_EXT := so
linux_LIBRARY_PREFIX := lib
linux_LDFLAGS := -shared -Wl,-Bsymbolic
#Default_LINKFLAGS := -shared
#
Support10_4 := -isysroot /Developer/SDKs/MacOSX10.4u.sdk
darwin_CXX := gcc -arch $(arch) -mmacosx-version-min=10.4 $(Support10_4)
darwin_CC := gcc -arch $(arch) -mmacosx-version-min=10.4 $(Support10_4)
darwin_STRIP := strip -x
#darwin_CPP_FLAGS := strip -x
#darwin_LINKFLAGS := -dynamiclib $(Support10_4)
win_CXX := i586-mingw32msvc-gcc
win_CC := i586-mingw32msvc-gcc
win_STRIP := i586-mingw32msvc-strip
win_CPP_FLAGS := -D_Windows
win_STATICLIB_EXT := a
win_DYNAMICLIB_EXT := dll
win_LIBRARY_PREFIX := lib
win_LDFLAGS := -shared -Wl,-Bsymbolic
#win_CFLAGS := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -I$(JAVA_HOME)/include -O
#win_LINKFLAGS := -Wl,--kill-at -shared
############################################################################################################################
### Cygwin target ###
cygwin_CXX := i686-pc-cygwin-g++
cygwin_CC := i686-pc-cygwin-gcc
cygwin_STRIP := i686-pc-cygwin-strip
cygwin_LDFLAGS := -shared -Wl,--kill-at
cygwin_CFLAGS := -D__int64="long long" -D_JNI_IMPLEMENTATION -D_REENTRANT -D_GNU_SOURCE
cygwin_CXXFLAGS := -D__int64="long long" -D_JNI_IMPLEMENTATION -D_REENTRANT -D_GNU_SOURCE
cygwin_STATICLIB_EXT := lib
cygwin_DYNAMICLIB_EXT := dll
cygwin_LIBRARY_PREFIX := # empty
# Publish chosen settings as global
CXX := $($(TARGET)_CXX)
CC := $($(TARGET)_CC)
STRIP := $($(TARGET)_STRIP)
CFLAGS := $($(TARGET)_CFLAGS)
CXXFLAGS := $($(TARGET)_CXXFLAGS)
LDFLAGS := $($(TARGET)_LDFLAGS)
LDFLAGS := $($(TARGET)_LDFLAGS)
GLOBAL_INCLUDES=$($(TARGET)_GLOBAL_INCLUDES)
STATICLIB_EXT := $($(TARGET)_STATICLIB_EXT)
DYNAMICLIB_EXT := $($(TARGET)_DYNAMICLIB_EXT)
LIBRARY_PREFIX := $($(TARGET)_LIBRARY_PREFIX)
endif

View file

@ -0,0 +1,2 @@
cd zlib && configure.sh && cd ..
cd pthread && configure.sh && cd ..

View file

@ -15,13 +15,16 @@ LIBNAME = $(LIBRARY_PREFIX)osmand
LIBTYPE = $(DYNAMICLIB_EXT)
LDLIBS += -lskia -lproto -lpthread -lft2 -lexpat -lpng -lz
ifndef RT_NOT_SUPPORTED
LDLIBS += -lrt
endif
ifeq ($(TARGET),nacl)
OSMAND_FLAGS += \
-DRT_NOT_SUPPORTED
LOCAL_SRC_FILES += \
src/osmand_nacl.cpp
else
LDLIBS += -lrt
LOCAL_SRC_FILES += \
src/java_wrap.cpp
# Set library name
@ -44,6 +47,7 @@ ifeq ($(JAVA_OS),)
JAVA_OS := linux
endif
OSMAND_FLAGS += -c -I"$(FIXED_JAVA_HOME)/include" -I"$(FIXED_JAVA_HOME)/include/$(JAVA_OS)"
endif
CFLAGS += $(OSMAND_FLAGS)

View file

@ -4,14 +4,27 @@
#include <string>
#include <vector>
#ifdef _Windows
#include "backward/hash_map.h"
#include "backward/hash_set.h"
#else
#ifndef ANDROID
#define GNU_HASH_MAP
#include <hash_map>
#include <hash_set>
#endif
#endif
#include <SkPath.h>
#include <SkBitmap.h>
#include "osmand_log.h"
#include "math.h"
#ifdef _MSC_VER
typedef __int8 int8;
typedef __int16 int16;
@ -34,7 +47,7 @@ typedef uint32_t uint32;
typedef uint64_t uint64;
#endif
#ifndef ANDROID
#ifdef GNU_HASH_MAP
#define HMAP __gnu_cxx
namespace __gnu_cxx {
@ -131,7 +144,7 @@ struct TextDrawInfo {
float minDistance;
int textColor;
int textShadow;
uint textWrap;
uint32 textWrap;
bool bold;
std::string shieldRes;
int textOrder;

View file

@ -107,8 +107,8 @@ RenderingRule* createRenderingRule(JNIEnv* env, jobject rRule, RenderingRulesSto
void initDictionary(JNIEnv* env, RenderingRulesStorage* storage, jobject javaStorage) {
jobject listDictionary = env->GetObjectField(javaStorage, RenderingRulesStorageClass_dictionary);
uint sz = env->CallIntMethod(listDictionary, List_size);
uint i = 0;
uint32 sz = env->CallIntMethod(listDictionary, List_size);
uint32 i = 0;
for (; i < sz; i++) {
jstring st = (jstring) env->CallObjectMethod(listDictionary, List_get, i);
// if(st != NULL)
@ -128,8 +128,8 @@ void initDictionary(JNIEnv* env, RenderingRulesStorage* storage, jobject javaSto
void initProperties(JNIEnv* env, RenderingRulesStorage* st, jobject javaStorage) {
jobject props = env->GetObjectField(javaStorage, RenderingRulesStorage_PROPS);
jobject listProps = env->GetObjectField(props, RenderingRuleStorageProperties_rules);
uint sz = env->CallIntMethod(listProps, List_size);
uint i = 0;
uint32 sz = env->CallIntMethod(listProps, List_size);
uint32 i = 0;
for (; i < sz; i++) {
jobject rulePrope = env->CallObjectMethod(listProps, List_get, i);
bool input = (env->GetBooleanField(rulePrope, RenderingRuleProperty_input) == JNI_TRUE);

View file

@ -1,7 +1,9 @@
#ifndef _JAVA_WRAP_CPP
#define _JAVA_WRAP_CPP
#ifdef ANDROID_BUILD
#include <dlfcn.h>
#endif
#include <SkBitmap.h>
#include <SkCanvas.h>
#include <SkImageDecoder.h>
@ -19,7 +21,7 @@ void loadJniRenderingContext(JNIEnv* env);
void loadJniRenderingRules(JNIEnv* env);
static const int simplePngSize = 93;
static void* simplePng = new uint8[simplePngSize]{
static uint8 simplePngarray[simplePngSize] = {
0x89 ,0x50 ,0x4E ,0x47 ,0x0D ,0x0A ,0x1A ,0x0A ,
0x00 ,0x00 ,0x00 ,0x0D ,0x49 ,0x48 ,0x44 ,0x52 ,
0x00 ,0x00 ,0x00 ,0x06 ,0x00 ,0x00 ,0x00 ,0x06 ,
@ -33,6 +35,7 @@ static void* simplePng = new uint8[simplePngSize]{
0x1D ,0x00 ,0x00 ,0x00 ,0x00 ,0x49 ,0x45 ,0x4E ,
0x44 ,0xAE ,0x42 ,0x60 ,0x82
};
static void* simplePng = simplePngarray;
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)

View file

@ -529,7 +529,7 @@ HMAP::hash_map<int, std::vector<int> > sortObjectsByProperOrder(std::vector <Map
const int size = mapDataObjects.size();
int i = 0;
for (; i < size; i++) {
uint sh = i << 8;
uint32 sh = i << 8;
MapDataObject* mobj = mapDataObjects[i];
size_t sizeTypes = mobj->types.size();
size_t j = 0;

View file

@ -444,7 +444,7 @@ bool findTextIntersection(SkCanvas* cv, RenderingContext* rc, quad_tree<TextDraw
// for text purposes
// drawTestBox(cv, &text->bounds, text->pathRotate, paintIcon, text->text, NULL/*paintText*/);
boundIntersections.query_in_box(text->bounds, searchText);
for (uint i = 0; i < searchText.size(); i++) {
for (uint32 i = 0; i < searchText.size(); i++) {
TextDrawInfo* t = searchText.at(i);
if (intersects(text, t)) {
return true;
@ -455,7 +455,7 @@ bool findTextIntersection(SkCanvas* cv, RenderingContext* rc, quad_tree<TextDraw
boundsSearch.inset(-rc->getDensityValue(max(5.0f, text->minDistance)), -rc->getDensityValue(15));
boundIntersections.query_in_box(boundsSearch, searchText);
// drawTestBox(cv, &boundsSearch, text->pathRotate, paintIcon, text->text, paintText);
for (uint i = 0; i < searchText.size(); i++) {
for (uint32 i = 0; i < searchText.size(); i++) {
TextDrawInfo* t = searchText.at(i);
if (t->minDistance > 0 && t->text == text->text && intersects(boundsSearch, text->pathRotate, t)) {
return true;
@ -495,8 +495,8 @@ void drawTextOverCanvas(RenderingContext* rc, SkCanvas* cv) {
// 1. Sort text using text order
std::sort(rc->textToDraw.begin(), rc->textToDraw.end(), textOrder);
uint size = rc->textToDraw.size();
for (uint i = 0; i < size; i++) {
uint32 size = rc->textToDraw.size();
for (uint32 i = 0; i < size; i++) {
TextDrawInfo* text = rc->textToDraw.at(i);
if (text->text.length() > 0) {
// sest text size before finding intersection (it is used there)

View file

@ -1,8 +1,6 @@
OSMAND_PNG_LOC := ./png_library
OSMAND_PNG_ABS := $(LOCAL_PATH)/png_library
OSMAND_ZLIB_ABS := $(LOCAL_PATH)/../zlib/zlib_library
LOCAL_SRC_FILES:= \
$(OSMAND_PNG_LOC)/png.c \
$(OSMAND_PNG_LOC)/pngerror.c \
@ -22,7 +20,6 @@ LOCAL_SRC_FILES:= \
$(OSMAND_PNG_LOC)/pngwtran.c \
$(OSMAND_PNG_LOC)/pngwutil.c
LOCAL_C_INCLUDES += \
$(OSMAND_ZLIB_ABS)/
LOCAL_C_INCLUDES +=

View file

@ -10,4 +10,4 @@ LIBNAME = $(LIBRARY_PREFIX)png
LIBTYPE = $(STATICLIB_EXT)
# Finally, include generic rules
include ../Makefile.rules
include ../Makefile.rules

2
Osmand-kernel/pthread/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
pthreads_library
build-*

View file

@ -0,0 +1,40 @@
# Include tools definitions
include ../Makefile.vars
# Include project files
LOCAL_PATH = .
OSMAND_PTHREAD_LOC := ./pthreads_library
OSMAND_PTHREAD_ABS := $(LOCAL_PATH)/pthreads_library
LOCAL_SRC_FILES:= \
$(OSMAND_PTHREAD_LOC)/attr.c \
$(OSMAND_PTHREAD_LOC)/barrier.c \
$(OSMAND_PTHREAD_LOC)/cancel.c \
$(OSMAND_PTHREAD_LOC)/cleanup.c \
$(OSMAND_PTHREAD_LOC)/condvar.c \
$(OSMAND_PTHREAD_LOC)/create.c \
$(OSMAND_PTHREAD_LOC)/dll.c \
$(OSMAND_PTHREAD_LOC)/exit.c \
$(OSMAND_PTHREAD_LOC)/fork.c \
$(OSMAND_PTHREAD_LOC)/global.c \
$(OSMAND_PTHREAD_LOC)/misc.c \
$(OSMAND_PTHREAD_LOC)/mutex.c \
$(OSMAND_PTHREAD_LOC)/private.c \
$(OSMAND_PTHREAD_LOC)/rwlock.c \
$(OSMAND_PTHREAD_LOC)/sched.c \
$(OSMAND_PTHREAD_LOC)/semaphore.c \
$(OSMAND_PTHREAD_LOC)/spin.c \
$(OSMAND_PTHREAD_LOC)/sync.c \
$(OSMAND_PTHREAD_LOC)/tsd.c \
$(OSMAND_PTHREAD_LOC)/nonportable.c
# Set library name
LIBNAME = $(LIBRARY_PREFIX)pthread
LIBTYPE = $(STATICLIB_EXT)
# Finally, include generic rules
ifdef PTHREAD_BUILD
include ../Makefile.rules
endif

View file

@ -0,0 +1,2 @@
wget -qO - ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.tar.gz | tar xzvf -
mv pthreads-w32-2-8-0-release pthreads_library

View file

@ -67,12 +67,12 @@ LOCAL_SRC_FILES := \
$(OSMAND_SKIA_LOC)/src/core/SkGraphics.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkLineClipper.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMallocPixelRef.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMMapStream.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMask.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMaskFilter.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMath.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMatrix.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMetaData.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMMapStream.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPackBits.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPaint.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPath.cpp \
@ -191,7 +191,9 @@ LOCAL_SRC_FILES := \
$(OSMAND_SKIA_LOC)/src/utils/SkParsePath.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkProxyCanvas.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkSfntUtils.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkUnitMappers.cpp
$(OSMAND_SKIA_LOC)/src/utils/SkUnitMappers.cpp
## SkMMapStream is not built in Windows however it is required for Linux version
LOCAL_C_INCLUDES += \
$(LOCAL_PATH) \
@ -206,4 +208,4 @@ LOCAL_C_INCLUDES += \
$(OSMAND_PNG_ABS) \
$(OSMAND_GIF_ABS) \
$(OSMAND_EXPAT_ABS)/lib \
$(OSMAND_JPEG_ABS)
$(OSMAND_JPEG_ABS)

View file

@ -0,0 +1,2 @@
1. SkFontHost_FreeType
ERROR->ERROR_GOTO

View file

@ -1 +1,2 @@
zlib_library
build-*

View file

@ -30,4 +30,6 @@ LIBNAME = $(LIBRARY_PREFIX)z
LIBTYPE = $(STATICLIB_EXT)
# Finally, include generic rules
include ../Makefile.rules
ifdef ZLIB_BUILD
include ../Makefile.rules
endif

View file

@ -0,0 +1,2 @@
wget -qO - http://zlib.net/zlib-1.2.4.tar.gz | tar xzvf -
mv zlib-1.2.4 zlib_library