From c4981cd87ebae1c31e9de1c130f85aa6c0e5b808 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 14 Mar 2021 19:21:58 -0700 Subject: [PATCH] tesseract: update to 4.1.1 Switch to AUTORELEASE for simplicity. Add libarchive dependency since it's now used. Build with ninja for faster compilation. Refresh SIMD CMake patch and add musl patch. Signed-off-by: Rosen Penev --- utils/tesseract/Makefile | 11 +++-- utils/tesseract/patches/010-cmake.patch | 56 +++++++------------------ utils/tesseract/patches/020-musl.patch | 10 +++++ 3 files changed, 30 insertions(+), 47 deletions(-) create mode 100644 utils/tesseract/patches/020-musl.patch diff --git a/utils/tesseract/Makefile b/utils/tesseract/Makefile index b3aebe5a0..8911bf65c 100644 --- a/utils/tesseract/Makefile +++ b/utils/tesseract/Makefile @@ -7,22 +7,21 @@ include $(TOPDIR)/rules.mk PKG_NAME:=tesseract -PKG_VERSION:=4.0.0 -PKG_RELEASE:=2 +PKG_VERSION:=4.1.1 +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/tesseract-ocr/tesseract/tar.gz/$(PKG_VERSION)? -PKG_HASH:=a1f5422ca49a32e5f35c54dee5112b11b99928fc9f4ee6695cdc6768d69f61dd +PKG_HASH:=2a66ff0d8595bff8f04032165e6c936389b1e5727c3ce5a27b3e059d218db1cb PKG_MAINTAINER:=Valentin Kivachuk PKG_LICENSE:=Apache-2.0 PKG_LICENSE_FILES:=LICENSE -PKG_BUILD_PARALLEL:=1 CMAKE_BINARY_SUBDIR:=openwrt-build include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/cmake.mk +include ../../devel/ninja/ninja-cmake.mk define Package/tesseract MENU:=1 @@ -30,7 +29,7 @@ define Package/tesseract CATEGORY:=Utilities TITLE:=Tesseract Open Source OCR Engine URL:=https://github.com/tesseract-ocr/tesseract - DEPENDS:=+libleptonica +libpthread +libstdcpp + DEPENDS:=+libleptonica +libarchive +libpthread +libstdcpp endef TARGET_CFLAGS:=$(filter-out -O%,$(TARGET_CFLAGS)) -O3 diff --git a/utils/tesseract/patches/010-cmake.patch b/utils/tesseract/patches/010-cmake.patch index 5b77e57bf..2a9f88c79 100644 --- a/utils/tesseract/patches/010-cmake.patch +++ b/utils/tesseract/patches/010-cmake.patch @@ -1,44 +1,18 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -224,41 +224,6 @@ set(tesseract_src ${tesseract_src} - src/api/pdfrenderer.cpp - ) - --if (WIN32) -- if (MSVC) -- include_directories(src/vs2010/tesseract) -- set(tesseract_hdr -- ${tesseract_hdr} -- ${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/resource.h) -- set(tesseract_rsc ${CMAKE_BINARY_DIR}/vs2010/tesseract/libtesseract.rc) -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductsse.cpp -- PROPERTIES COMPILE_DEFINITIONS __SSE4_1__) -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixsse.cpp -- PROPERTIES COMPILE_DEFINITIONS __SSE4_1__) -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductavx.cpp -- PROPERTIES COMPILE_FLAGS "/arch:AVX") -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixavx2.cpp -- PROPERTIES COMPILE_FLAGS "/arch:AVX2") +@@ -252,15 +252,6 @@ set(AVX2_OPT OFF) + set(FMA_OPT OFF) + set(SSE41_OPT OFF) + set(MARCH_NATIVE_OPT OFF) +-foreach(flag ${_enable_vector_unit_list}) # from OptimizeForArchitecture() +- string(TOUPPER "${flag}" flag) +- string(REPLACE "\." "_" flag "${flag}") +- set(simd_flags "${simd_flags} -D${flag}") +- string(REPLACE "_" "" flag "${flag}") +- if("${flag}" MATCHES "AVX|AVX2|FMA|SSE41") +- set("${flag}_OPT" ON) - endif() --else() -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductsse.cpp -- PROPERTIES COMPILE_FLAGS "-msse4.1") -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixsse.cpp -- PROPERTIES COMPILE_FLAGS "-msse4.1") -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductavx.cpp -- PROPERTIES COMPILE_FLAGS "-mavx") -- set_source_files_properties( -- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixavx2.cpp -- PROPERTIES COMPILE_FLAGS "-mavx2") --endif() -- - add_library (libtesseract ${LIBRARY_TYPE} ${tesseract_src} ${tesseract_hdr} - ${tesseract_rsc} - ) +-endforeach(flag) + if (NOT MSVC) + set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -O3 -ffast-math") + endif() diff --git a/utils/tesseract/patches/020-musl.patch b/utils/tesseract/patches/020-musl.patch new file mode 100644 index 000000000..821a51d06 --- /dev/null +++ b/utils/tesseract/patches/020-musl.patch @@ -0,0 +1,10 @@ +--- a/src/ccutil/ocrclass.h ++++ b/src/ccutil/ocrclass.h +@@ -28,6 +28,7 @@ + + #include + #include ++#include + #ifdef _WIN32 + #include // for timeval + #endif