Skip to content

Commit

Permalink
Merge pull request #171 from chrox/master
Browse files Browse the repository at this point in the history
fix Android build of luasocket luasec and thrift
  • Loading branch information
houqp committed May 29, 2014
2 parents dbdd845 + 3565578 commit 664db11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ all: $(OUTPUT_DIR)/libs $(if $(ANDROID),,$(LUAJIT)) \
$(if $(ANDROID),,$(OUTPUT_DIR)/sdcv) \
libs $(OUTPUT_DIR)/spec/base $(OUTPUT_DIR)/common \
$(OUTPUT_DIR)/plugins $(LUASOCKET) $(LUASEC) \
$(if $(ANDROID),luacompat52,) \
$(if $(ANDROID),luacompat52 lualongnumber,) \
$(EVERNOTE_LIB) $(LUASERIAL_LIB)
ifndef EMULATE_READER
$(STRIP) --strip-unneeded \
Expand Down Expand Up @@ -287,8 +287,15 @@ endif
# ===========================================================================
# common lua library for networking
$(LUASOCKET):
cd $(LUA_SOCKET_DIR) && sed -i 's|socket\.core|socket\.score|' src/*
cd $(LUA_SOCKET_DIR) && sed -i 's|socket_core|socket_score|' src/*
cd $(LUA_SOCKET_DIR) && sed -i 's|mime\.core|mime\.mcore|' src/*
cd $(LUA_SOCKET_DIR) && sed -i 's|mime_core|mime_mcore|' src/*
cd $(LUA_SOCKET_DIR) && sed -i 's|SOCKET_CDIR)/core|SOCKET_CDIR)/score|' src/*
cd $(LUA_SOCKET_DIR) && sed -i 's|MIME_CDIR)/core|MIME_CDIR)/mcore|' src/*
$(MAKE) -C $(LUA_SOCKET_DIR) PLAT=linux \
CC="$(CC) $(CFLAGS)" LD="$(CC)" \
$(if $(ANDROID),MYLDFLAGS=$(CURDIR)/$(LUAJIT_LIB),) \
LUAINC="$(CURDIR)/$(LUA_DIR)/src" \
INSTALL_TOP_LDIR="$(CURDIR)/$(OUTPUT_DIR)/common" \
INSTALL_TOP_CDIR="$(CURDIR)/$(OUTPUT_DIR)/common" \
Expand All @@ -298,22 +305,21 @@ $(OPENSSL_LIB):
cd $(OPENSSL_DIR) && \
$(if $(EMULATE_READER),./config,./Configure linux-generic32) \
shared no-asm && $(MAKE) -j$(PROCESSORS) CC="$(CC) $(CFLAGS)" \
LD=$(LD) RANLIB=$(RANLIB) \
LD=$(LD) RANLIB=$(RANLIB) SHLIB_EXT=.so LIBVERSION="" \
build_crypto build_ssl

$(LUASEC): $(OPENSSL_LIB)
# -O -fPIC will break compiling for Android toolchain
cd $(LUA_SEC_DIR) && sed -i 's|LNX_LDFLAGS=-O -fPIC |LNX_LDFLAGS=|' src/Makefile
$(MAKE) -C $(LUA_SEC_DIR) CC="$(CC) $(CFLAGS)" LD=$(LD) \
$(MAKE) -C $(LUA_SEC_DIR) CC="$(CC) $(CFLAGS)" LD="$(CC)" \
$(if $(ANDROID),LIBS="-lssl -lcrypto -lluasocket $(CURDIR)/$(LUAJIT_LIB)",) \
INC_PATH="-I$(CURDIR)/$(LUA_DIR)/src -I$(CURDIR)/$(OPENSSL_DIR)/include" \
LIB_PATH="-L$(CURDIR)/$(OPENSSL_DIR)" \
LUAPATH="$(CURDIR)/$(OUTPUT_DIR)/common" \
LUACPATH="$(CURDIR)/$(OUTPUT_DIR)/common" \
linux install
cd $(LUA_SEC_DIR) && sed -i 's|LNX_LDFLAGS=|LNX_LDFLAGS=-O -fPIC |' src/Makefile

$(EVERNOTE_LIB):
$(MAKE) -C $(EVERNOTE_SDK_DIR)/thrift CC="$(CC) $(CFLAGS)" \
$(if $(ANDROID),LDFLAGS="-lm $(CURDIR)/$(LUAJIT_LIB)",) \
OUTPUT_DIR=$(CURDIR)/$(EVERNOTE_PLUGIN_DIR)/lib

$(LUASERIAL_LIB):
Expand All @@ -322,9 +328,14 @@ $(LUASERIAL_LIB):
OUTPUT_DIR=$(CURDIR)/$(OUTPUT_DIR)/common

luacompat52: $(LUASERIAL_LIB)
mv $(CURDIR)/$(OUTPUT_DIR)/common/libluacompat52.so \
cp $(CURDIR)/$(OUTPUT_DIR)/common/libluacompat52.so \
$(CURDIR)/$(OUTPUT_DIR)/libs

lualongnumber: $(EVERNOTE_LIB)
cp $(CURDIR)/$(EVERNOTE_PLUGIN_DIR)/lib/liblualongnumber.so \
$(CURDIR)/$(OUTPUT_DIR)/libs


# ===========================================================================
# helper target for creating standalone android toolchain from NDK
# NDK variable should be set in your environment and it should point to
Expand Down
2 changes: 2 additions & 0 deletions ffi/koptcontext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ function KOPTContext_mt.__index:getTOCRWord(bmp, x, y, w, h, datadir, lang, ocr_
end

function KOPTContext_mt.__index:getAutoBBox()
-- fall back to default writing direction when detecting bbox
self:setWritingDirection(0)
k2pdfopt.k2pdfopt_crop_bmp(self)
local x0 = self.bbox.x0/self.zoom
local y0 = self.bbox.y0/self.zoom
Expand Down

0 comments on commit 664db11

Please sign in to comment.