Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added htmlparser Luarock for newsdownloader #1110

Merged
merged 8 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ all: $(OUTPUT_DIR)/libs $(if $(ANDROID),,$(LUAJIT)) \
$(GIF_LIB) \
$(if $(USE_LJ_WPACLIENT),$(LJ_WPACLIENT),) \
$(TURBO_FFI_WRAP_LIB) \
$(LUA_HTMLPARSER_ROCK) \
hngt marked this conversation as resolved.
Show resolved Hide resolved
$(LUA_SPORE_ROCK) \
$(if $(ANDROID),$(LPEG_DYNLIB) $(LPEG_RE),) \
$(if $(WIN32),,$(ZMQ_LIB) $(CZMQ_LIB) $(FILEMQ_LIB) $(ZYRE_LIB)) \
Expand Down
17 changes: 11 additions & 6 deletions Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -836,17 +836,22 @@ TURBO_BUILD_DIR=$(THIRDPARTY_DIR)/turbo/build/$(MACHINE)
TURBO_DIR=$(CURDIR)/$(TURBO_BUILD_DIR)/turbo-prefix/src/turbo
TURBO_FFI_WRAP_LIB=$(OUTPUT_DIR)/common/libtffi_wrap$(LIB_EXT)

LUA_SPORE_BUILD_DIR=$(THIRDPARTY_DIR)/lua-Spore/build/$(MACHINE)
LUA_SPORE_DIR=$(CURDIR)/$(LUA_SPORE_BUILD_DIR)/lua-Spore-prefix/src/lua-Spore
SPORE_VER=0.3.1-1
LUA_SPORE_VER=lua-spore-$(SPORE_VER)
# Unversioned LR 2 path
LUAROCKS_DIR=$(OUTPUT_DIR)/rocks/lib/luarocks/rocks
# Versioned LR 3 path, see koreader-base/pull/1003
ifeq ($(LR_GT_3_0),1)
LUAROCKS_DIR=$(OUTPUT_DIR)/rocks/lib/luarocks/rocks-5.1
endif
LUA_SPORE_ROCK=$(LUAROCKS_DIR)/lua-spore/$(SPORE_VER)/$(LUA_SPORE_VER).rockspec

LUA_HTMLPARSER_VER=scm-0
hngt marked this conversation as resolved.
Show resolved Hide resolved
LUA_HTMLPARSER_BUILD_DIR=$(THIRDPARTY_DIR)/lua-htmlparser/build/$(MACHINE)
LUA_HTMLPARSER_ROCK=$(LUAROCKS_DIR)/lua-htmlparser/htmlparser-$(LUA_HTMLPARSER_VER).rockspec

LUA_SPORE_BUILD_DIR=$(THIRDPARTY_DIR)/lua-Spore/build/$(MACHINE)
LUA_SPORE_DIR=$(CURDIR)/$(LUA_SPORE_BUILD_DIR)/lua-Spore-prefix/src/lua-Spore
SPORE_VER=0.3.1-1
LUA_SPORE_VER=$(SPORE_VER)
LUA_SPORE_ROCK=$(LUAROCKS_DIR)/lua-spore/$(SPORE_VER)/lua-spore-$(SPORE_VER).rockspec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see I'd missed the intermediate folder there, nice ;).


SQLITE_BUILD_DIR=$(THIRDPARTY_DIR)/sqlite/build/$(MACHINE)
SQLITE_DIR=$(CURDIR)/$(SQLITE_BUILD_DIR)/sqlite-prefix/src/sqlite-build
Expand Down Expand Up @@ -915,7 +920,7 @@ CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),evernote-sdk-lua,luajit,lpeg,t
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),zyre,czmq,filemq,libzmq
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),libk2pdfopt,tesseract,leptonica
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),lj-wpaclient
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),lua-Spore,luasec,luasocket,libffi,lua-serialize,glib,lodepng,minizip
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),lua-htmlparser,lua-Spore,luasec,luasocket,libffi,lua-serialize,glib,lodepng,minizip
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),djvulibre,mupdf,freetype2,harfbuzz,giflib,libpng,zlib
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),tar,sdcv,libiconv,gettext,libjpeg-turbo,popen-noshell,sqlite
CMAKE_THIRDPARTY_LIBS := $(CMAKE_THIRDPARTY_LIBS),openssl,dropbear,openssh
Expand Down
14 changes: 14 additions & 0 deletions Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,20 @@ ifdef ANDROID
-rm -f $(LPEG_DYNLIB) # so that LPEG can be rebuilt in our control
endif

$(LUA_HTMLPARSER_ROCK): $(THIRDPARTY_DIR)/lua-htmlparser/*.*
install -d $(LUA_HTMLPARSER_BUILD_DIR)
-rm -f $(LUA_HTMLPARSER_ROCK)
cd $(LUA_HTMLPARSER_BUILD_DIR) && \
$(CMAKE) $(CMAKE_FLAGS) -DOUTPUT_DIR="$(CURDIR)/$(OUTPUT_DIR)" \
-DLUA_HTMLPARSER_VER=$(LUA_HTMLPARSER_VER) -DLD="$(CC)" \
-DCC="$(CC)" -DCFLAGS="$(CFLAGS) -I$(LUAJIT_DIR)/src" \
-DLUAROCKS=$(if $(DARWINHOST),"luarocks --lua-dir=/usr/local/opt/lua@5.1",luarocks) \
-DLUA_INCDIR=$(if $(DARWINHOST),/usr/local/opt/lua@5.1/include/lua5.1,"$(LUAJIT_DIR)/src") \
-DLUA_LIBDIR=$(if $(DARWINHOST),/usr/local/opt/lua@5.1/lib,"$(CURDIR)/$(dir $(LUAJIT_LIB))") \
$(if $(ANDROID),-DLIBFLAG="$(LDFLAGS) $(CURDIR)/$(LUAJIT_LIB) -nostartfiles",) \
$(CURDIR)/$(THIRDPARTY_DIR)/lua-htmlparser && \
$(CMAKE_MAKE_PROGRAM) $(CMAKE_MAKE_PROGRAM_FLAGS)

# override lpeg built by luarocks, this is only necessary for Android
$(LPEG_DYNLIB) $(LPEG_RE): $(LUAJIT_LIB) $(THIRDPARTY_DIR)/lpeg/*.*
install -d $(OUTPUT_DIR)/rocks/lib/lua/5.1
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/lua-Spore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ assert_var_defined(LUAROCKS)

ep_get_source_dir(SOURCE_DIR)

set(LUA_SPORE_ROCKSPEC rockspec/${LUA_SPORE_VER}.rockspec)
set(LUA_SPORE_ROCKSPEC rockspec/lua-spore-${LUA_SPORE_VER}.rockspec)

set(BUILD_CMD sh -c "${LUAROCKS} make --tree=${OUTPUT_DIR}/rocks ${LUA_SPORE_ROCKSPEC}")
if(DEFINED LIBFLAG)
Expand Down
46 changes: 46 additions & 0 deletions thirdparty/lua-htmlparser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
project(lua-htmlparser)
cmake_minimum_required(VERSION 3.5.1)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/../cmake_modules")
include("koreader_thirdparty_common")
include("koreader_thirdparty_git")

enable_language(C)

assert_var_defined(CC)
assert_var_defined(CFLAGS)
assert_var_defined(LD)
assert_var_defined(LUA_INCDIR)
assert_var_defined(LUA_LIBDIR)
assert_var_defined(LUA_HTMLPARSER_VER)
assert_var_defined(OUTPUT_DIR)
assert_var_defined(LUAROCKS)

ep_get_source_dir(SOURCE_DIR)

set(LUA_HTMLPARSER_ROCKSPEC rockspecs/htmlparser-${LUA_HTMLPARSER_VER}.rockspec)

set(BUILD_CMD sh -c "${LUAROCKS} make --tree=${OUTPUT_DIR}/rocks ${LUA_HTMLPARSER_ROCKSPEC}")
if(DEFINED LIBFLAG)
set(BUILD_CMD "${BUILD_CMD} LIBFLAG=\"${LIBFLAG}\"")
endif()
set(BUILD_CMD "${BUILD_CMD} CC=\"${CC}\" CFLAGS=\"${CFLAGS}\" LD=\"${LD}\"")
set(BUILD_CMD "${BUILD_CMD} LUA_INCDIR=\"${LUA_INCDIR}\" LUA_LIBDIR=\"${LUA_LIBDIR}\"")

ko_write_gitclone_script(
GIT_CLONE_SCRIPT_FILENAME
https://github.com/msva/lua-htmlparser
4f6437ebd123c3e552a595fc818fdd952888fff2
${SOURCE_DIR}
)

include(ExternalProject)
ExternalProject_Add(
${PROJECT_NAME}
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P ${GIT_CLONE_SCRIPT_FILENAME}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ${BUILD_CMD}
# skip install
INSTALL_COMMAND ""
)