├── .ci ├── build_script.sh ├── common.sh ├── helper_shellchecks.sh ├── lint_script.sh └── test_script.sh ├── .circleci └── config.yml ├── .cmakelintrc ├── .github └── workflows │ └── build.yml ├── .gitignore ├── .gitmodules ├── .luacheckrc ├── .luarc.json ├── CMakeLists.txt ├── COPYING ├── Makefile ├── Makefile.defs ├── README.md ├── blitbuffer.c ├── blitbuffer.h ├── button-listen.c ├── cache-key.base ├── cmake ├── CMakeLists.txt ├── crengine │ └── CMakeLists.txt └── koreader │ └── CMakeLists.txt ├── cre.cpp ├── cre.h ├── djvu.c ├── djvu.h ├── drawcontext.h ├── ev_replay.py ├── extr.c ├── ffi-cdecl ├── SDL2_0_decl.c ├── android-luajit-launcher_cdecl.c ├── blitbuffer_cdecl.c ├── crypto_decl.c ├── einkfb_decl.c ├── freetype2_decl.c ├── giflib_decl.c ├── harfbuzz_cdecl.c ├── include │ ├── README │ ├── einkfb.h │ ├── frontlight-kindle.h │ ├── ion-kobo.h │ ├── mtk-kindle.h │ ├── mtk-kobo.h │ ├── mxcfb-cervantes.h │ ├── mxcfb-kindle.h │ ├── mxcfb-kobo.h │ ├── mxcfb-pb.h │ ├── mxcfb-pocketbook.h │ ├── mxcfb-remarkable.h │ ├── mxcfb-sony.h │ └── sunxi-kobo.h ├── inkview_decl.c ├── inotify_decl.c ├── ion_kobo_decl.c ├── koptcontext_cdecl.c ├── koreader-cre_cdecl.c ├── koreader-djvu_cdecl.c ├── koreader-input_cdecl.c ├── koreader-lfs_cdecl.c ├── koreader-nnsvg_cdecl.c ├── koreader-xtext_cdecl.c ├── leptonica_cdecl.c ├── libarchive_cdecl.c ├── libwebp_decl.c ├── linux_fb_decl.c ├── linux_input_decl.c ├── lodepng_decl.c ├── lpeg_cdecl.c ├── lua-rapidjson_cdecl.c ├── luasec_cdecl.c ├── luasocket_cdecl.c ├── mxcfb_cervantes_decl.c ├── mxcfb_kindle_decl.c ├── mxcfb_kobo_decl.c ├── mxcfb_pb_decl.c ├── mxcfb_remarkable_decl.c ├── mxcfb_sony_decl.c ├── openlipclua_cdecl.c ├── posix_decl.c ├── rtc_cdecl.c ├── sqlite3_cdecl.c ├── sunxi_kobo_decl.c ├── tffi_wrap_cdecl.c ├── turbojpeg_decl.c ├── utf8proc_decl.c ├── wrap-mupdf_cdecl.c ├── zeromq_cdecl.c ├── zlib_decl.c └── zstd_decl.c ├── ffi ├── MD5.lua ├── SDL2_0.lua ├── SDL2_0_h.lua ├── __gc.lua ├── archiver.lua ├── bitser.lua ├── blitbuffer.lua ├── crypto.lua ├── crypto_h.lua ├── drawcontext.lua ├── einkfb_h.lua ├── fbink_input_h.lua ├── framebuffer.lua ├── framebuffer_SDL2_0.lua ├── framebuffer_android.lua ├── framebuffer_dummy.lua ├── framebuffer_einkfb.lua ├── framebuffer_ion.lua ├── framebuffer_linux.lua ├── framebuffer_mxcfb.lua ├── framebuffer_pocketbook.lua ├── framebuffer_sunxi.lua ├── freetype.lua ├── freetype_h.lua ├── giflib_h.lua ├── harfbuzz.lua ├── harfbuzz_coverage.lua ├── harfbuzz_h.lua ├── inkview_h.lua ├── inotify_h.lua ├── input_SDL2_0.lua ├── input_android.lua ├── input_pocketbook.lua ├── ion_kobo_h.lua ├── jpeg.lua ├── kobolight.lua ├── koptcontext.lua ├── koptcontext_h.lua ├── leptonica_h.lua ├── libarchive_h.lua ├── libwebp_h.lua ├── linux_fb_h.lua ├── linux_input_h.lua ├── loadlib.lua ├── lodepng_h.lua ├── lru.lua ├── mupdf.lua ├── mupdf_h.lua ├── mxcfb_cervantes_h.lua ├── mxcfb_kindle_h.lua ├── mxcfb_kobo_h.lua ├── mxcfb_pocketbook_h.lua ├── mxcfb_remarkable_h.lua ├── mxcfb_sony_h.lua ├── pic.lua ├── png.lua ├── posix_h.lua ├── posix_types_64b_h.lua ├── posix_types_def_h.lua ├── posix_types_x64_h.lua ├── posix_types_x86_h.lua ├── pthread_h.lua ├── qrencode.lua ├── rtc.lua ├── rtc_h.lua ├── serpent.lua ├── sha2.lua ├── sunxi_kobo_h.lua ├── turbojpeg_h.lua ├── utf8proc.lua ├── utf8proc_h.lua ├── util.lua ├── webp.lua ├── zeromq_h.lua ├── zlib.lua ├── zlib_h.lua ├── zstd.lua └── zstd_h.lua ├── input ├── .clang-format ├── atomicio.h ├── inkview-compat.c ├── input-cervantes.h ├── input-kindle.h ├── input-kobo.h ├── input-remarkable.h ├── input-sony-prstux.h ├── input.c ├── input.h ├── libue.h └── timerfd-callbacks.h ├── koptcontext.h ├── libxss-dummy.c ├── monolibtic.cpp ├── nnsvg.c ├── nnsvg.h ├── origin.ldflags ├── osx_loader.c ├── patches ├── lfs-pushnumber-for-wide-types.patch └── lfs-visibility.patch ├── spec └── unit │ ├── blitbuffer_spec.lua │ ├── common_spec.lua │ ├── data │ ├── 2col.jbig2.pdf │ ├── Alice.pdf │ ├── Paper.pdf │ ├── encrypted-aes.zip │ ├── encrypted-none.zip │ ├── encrypted-plain.zip │ ├── sample.jpg │ ├── simple-out-annotated.pdf │ ├── simple-out-annotation-deleted.pdf │ ├── simple-out.pdf │ ├── simple.pdf │ ├── simple.svg │ ├── testdocument.odt │ ├── testdocument.pdf │ ├── testfont.ttf │ └── transparency_various_bg.png │ ├── ffi_wrapper.lua │ ├── font_spec.lua │ ├── framebuffer_spec.lua │ ├── freetype_spec.lua │ ├── koptcontext_spec.lua │ ├── md5_spec.lua │ ├── mupdf_spec.lua │ ├── nnsvg_spec.lua │ ├── pic_spec.lua │ ├── png_spec.lua │ ├── qrencode_spec.lua │ ├── spore_spec.lua │ └── util_spec.lua ├── test-runner ├── busted_config.lua ├── busted_helper.lua ├── meson.build └── runtests ├── thirdparty ├── android-luajit-launcher │ └── CMakeLists.txt ├── cmake_modules │ ├── koenv.sh │ ├── koreader_external_project.cmake │ ├── koreader_targets.cmake │ ├── koreader_thirdparty_common.cmake │ └── koreader_thirdparty_libs.cmake ├── cpu_features │ └── CMakeLists.txt ├── curl │ ├── CMakeLists.txt │ ├── clock_gettime_needs_rt.patch │ ├── curl-8.5.0-mpd-stream-http-adjust_pollset.patch │ ├── fetch-ca-bundle.sh │ └── use_-pthread.patch ├── czmq │ ├── CMakeLists.txt │ ├── android.patch │ └── cmake_tweaks.patch ├── djvulibre │ ├── CMakeLists.txt │ ├── android.patch │ ├── djvulibre-no-locale-mangling.patch │ └── no_references_to_install_dir.patch ├── dkjson │ └── CMakeLists.txt ├── dropbear │ ├── CMakeLists.txt │ ├── dbscp-path.patch │ ├── localoptions.h.cmake │ ├── nochdir-hack.patch │ ├── nopasswd-hack.patch │ ├── pubkey-hack.patch │ └── reduce_build_verbosity.patch ├── fbink │ └── CMakeLists.txt ├── ffi-cdecl │ ├── CMakeLists.txt │ ├── ffi-cdecl.patch │ ├── ffi-cdecl.sh.in │ └── gcc15.patch ├── freetype2 │ ├── CMakeLists.txt │ ├── fix_meson_bzip2_option.patch │ └── ftcalc_gcc12_arm_neon_fix.patch ├── fribidi │ └── CMakeLists.txt ├── giflib │ ├── CMakeLists.txt │ └── overlay │ │ └── CMakeLists.txt ├── glib │ ├── CMakeLists.txt │ ├── libglib-only.patch │ ├── no_glibc_2.6_or_above_symbols.patch │ └── no_regex_support.patch ├── harfbuzz │ ├── CMakeLists.txt │ ├── android.patch │ └── no-subset.patch ├── kobo-usbms │ └── CMakeLists.txt ├── kpvcrlib │ ├── CMakeLists.txt │ ├── cr3.css │ └── crsetup.h.cmake ├── leptonica │ ├── CMakeLists.txt │ ├── cmake_tweaks.patch │ ├── fmemopen-arm-compat-symbol.patch │ └── k2pdfopt.patch ├── libarchive │ ├── CMakeLists.txt │ └── android.patch ├── libiconv │ └── CMakeLists.txt ├── libjpeg-turbo │ ├── CMakeLists.txt │ └── no_cmake_rpath_shenanigans.patch ├── libk2pdfopt │ └── CMakeLists.txt ├── libpng │ ├── CMakeLists.txt │ └── math_library.patch ├── libressl │ ├── CMakeLists.txt │ ├── android.patch │ └── cmake_tweaks.patch ├── libunibreak │ └── CMakeLists.txt ├── libwebp │ ├── CMakeLists.txt │ └── cmake_tweaks.patch ├── libzmq │ ├── CMakeLists.txt │ ├── cmake_tweaks.patch │ └── disable_eventfd.patch ├── lj-wpaclient │ └── CMakeLists.txt ├── lodepng │ ├── CMakeLists.txt │ └── overlay │ │ └── CMakeLists.txt ├── lpeg │ ├── CMakeLists.txt │ ├── luajit.patch │ └── overlay │ │ └── CMakeLists.txt ├── lua-Spore │ ├── CMakeLists.txt │ └── content-type-detection.patch ├── lua-htmlparser │ └── CMakeLists.txt ├── lua-ljsqlite3 │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── __meta.lua │ ├── init.lua │ └── notes.txt ├── lua-rapidjson │ ├── CMakeLists.txt │ └── cmake_tweaks.patch ├── luajit │ ├── CMakeLists.txt │ ├── koreader-luajit-enable-table_pack.patch │ ├── koreader-luajit-makefile-tweaks.patch │ ├── koreader-luajit-mcode-debug.patch │ ├── koreader-luajit-mcode-reserve-hack.patch │ └── koreader-luajit-verbose-build.patch ├── luajson │ └── CMakeLists.txt ├── luarocks │ └── CMakeLists.txt ├── luasec │ ├── CMakeLists.txt │ ├── overlay │ │ └── CMakeLists.txt │ └── visibility.patch ├── luasocket │ ├── CMakeLists.txt │ ├── enforce-cloexec.patch │ ├── export-api-for-luasec.patch │ ├── luajit-compat.patch │ ├── namespace.patch │ └── overlay │ │ └── CMakeLists.txt ├── lunasvg │ ├── CMakeLists.txt │ ├── cmake_tweaks.patch │ ├── extended.patch │ └── xtended │ │ ├── CMakeLists.txt │ │ ├── ximageelement.cpp │ │ ├── ximageelement.h │ │ ├── xlunasvg.h │ │ ├── xtextelement.cpp │ │ ├── xtextelement.h │ │ ├── xtspanelement.cpp │ │ └── xtspanelement.h ├── md4c │ ├── CMakeLists.txt │ └── cmake_tweaks.patch ├── minizip │ ├── CMakeLists.txt │ └── overlay │ │ └── CMakeLists.txt ├── mupdf │ ├── CMakeLists.txt │ ├── css_color_names.patch │ ├── encrypted_zip.patch │ ├── external_fonts.patch │ ├── free-html-doc-fonts-on-close.patch │ ├── honor_cflags.patch │ ├── mupdf_cbz_chapter_support.patch │ ├── no_arm_asm.patch │ ├── relink_on_xlibs_change.patch │ ├── visibility.patch │ └── webp-upstream-697749.patch ├── nanosvg │ ├── CMakeLists.txt │ └── stb_image_write.h ├── openlipclua │ └── CMakeLists.txt ├── openssh │ └── CMakeLists.txt ├── popen-noshell │ ├── CMakeLists.txt │ ├── kindle_legacy.patch │ └── overlay │ │ └── CMakeLists.txt ├── proxy-libintl │ └── CMakeLists.txt ├── sdcv │ ├── CMakeLists.txt │ ├── compat_with_newer_glib.patch │ ├── sdcv-locale-hack.patch │ └── sdcv-no-unknown-dict-warning.patch ├── sdl2 │ ├── CMakeLists.txt │ ├── appimage.patch │ ├── cmake_tweaks.patch │ └── cocoa.patch ├── spec │ ├── busted │ │ └── CMakeLists.txt │ ├── cluacov │ │ └── CMakeLists.txt │ ├── lua-term │ │ └── CMakeLists.txt │ ├── lua_cliargs │ │ └── CMakeLists.txt │ ├── luacov │ │ └── CMakeLists.txt │ ├── luafilesystem │ │ └── CMakeLists.txt │ ├── luassert │ │ └── CMakeLists.txt │ ├── luasystem │ │ └── CMakeLists.txt │ ├── mediator_lua │ │ └── CMakeLists.txt │ ├── penlight │ │ └── CMakeLists.txt │ └── say │ │ └── CMakeLists.txt ├── sqlite │ ├── CMakeLists.txt │ └── overlay │ │ └── CMakeLists.txt ├── srell │ ├── history_en.txt │ ├── history_ja.txt │ ├── license.txt │ ├── misc │ │ └── sample01.cpp │ ├── readme_en.txt │ ├── readme_ja.txt │ ├── single-header │ │ └── srell.hpp │ ├── srell.hpp │ ├── srell_ucfdata2.hpp │ ├── srell_updata.hpp │ └── unicode │ │ ├── readme_en.txt │ │ ├── readme_ja.txt │ │ ├── ucfdataout2.cpp │ │ └── updataout.cpp ├── tar │ ├── CMakeLists.txt │ ├── tar-1.31-revert-wordsplit-for-android-glob.patch │ └── tar-1.33-remove-o_path-usage.patch ├── tesseract │ ├── CMakeLists.txt │ ├── cmake_tweaks.patch │ ├── fix-old-tc-build.patch │ ├── k2pdfopt.patch │ └── no_debug_fonts.patch ├── turbo │ ├── CMakeLists.txt │ ├── d7a8a247a4a2689b0f207162eb804141c87c4899.patch │ ├── overlay │ │ └── CMakeLists.txt │ └── turbo.patch ├── utf8proc │ └── CMakeLists.txt ├── xz │ └── CMakeLists.txt ├── zlib │ └── CMakeLists.txt ├── zstd │ ├── CMakeLists.txt │ └── no_qsort_r.patch └── zsync2 │ ├── CMakeLists.txt │ └── cmake_tweaks.patch ├── toolchain └── Makefile ├── utils ├── bincheck.py ├── bincheck │ ├── libinkview.c │ ├── liblipc.c │ └── stub.h ├── binfind.py ├── bininfo.py ├── fake_tty.py ├── gen_linker_exports.sh ├── pdfattach └── shellcheck.sh ├── wrap-mupdf.c ├── wrap-mupdf.h ├── xtext.cpp └── xtext.h /.ci/build_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | docker-make() { 8 | local cmdlist=( 9 | 'source /home/ko/.bashrc' 10 | 'cd /home/ko/base' 11 | 'sudo chown -R ko:ko .' 12 | "env MAKEFLAGS='${MAKEFLAGS}' make $(printf '%q ' "$@")" 13 | ) 14 | if [[ -z "${CCACHE_DIR}" ]]; then 15 | CCACHE_DIR="$(ccache --get-config cache_dir)" 16 | fi 17 | mkdir -p "${CCACHE_DIR}" 18 | echo "using host cache dir: ${CCACHE_DIR}" 19 | sudo chmod -R 777 "${CCACHE_DIR}" 20 | DOCKER_HOME=/home/ko 21 | DOCKER_CCACHE_DIR="${DOCKER_HOME}/.cache/ccache" 22 | echo "using docker cache dir: ${DOCKER_CCACHE_DIR}" 23 | docker run --rm -t \ 24 | -e CCACHE_DIR="${DOCKER_CCACHE_DIR}" \ 25 | -v "${CCACHE_DIR}:${DOCKER_CCACHE_DIR}" \ 26 | -v "${PWD}:${DOCKER_HOME}/base" "${DOCKER_IMG}" \ 27 | /bin/bash -c "$(printf '%s && ' "${cmdlist[@]}")true" 28 | } 29 | 30 | if [[ -z "${DOCKER_IMG}" ]]; then 31 | make TARGET="${TARGET}" "$@" 32 | else 33 | docker-make TARGET="${TARGET}" VERBOSE=1 "$@" 34 | fi 35 | 36 | # vim: sw=4 37 | -------------------------------------------------------------------------------- /.ci/common.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | ANSI_RED="\033[31;1m" 7 | # shellcheck disable=SC2034 8 | ANSI_GREEN="\033[32;1m" 9 | ANSI_RESET="\033[0m" 10 | 11 | travis_retry() { 12 | local result=0 13 | local count=1 14 | set +e 15 | 16 | while [ ${count} -le 3 ]; do 17 | [ ${result} -ne 0 ] && { 18 | echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, ${count} of 3.${ANSI_RESET}\n" >&2 19 | } 20 | "$@" 21 | result=$? 22 | [ ${result} -eq 0 ] && break 23 | count=$((count + 1)) 24 | sleep 1 25 | done 26 | 27 | [ ${count} -gt 3 ] && { 28 | echo -e "\n${ANSI_RED}The command \"$*\" failed 3 times.${ANSI_RESET}\n" >&2 29 | } 30 | 31 | set -e 32 | return ${result} 33 | } 34 | -------------------------------------------------------------------------------- /.ci/helper_shellchecks.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | # shellcheck disable=2016 8 | mapfile -t shellscript_locations < <({ git grep -lE '^#!(/usr)?/bin/(env )?(bash|sh)' && git submodule --quiet foreach '[ "$path" = "thirdparty/kpvcrlib/crengine" ] && git grep -lE "^#!(/usr)?/bin/(env )?(bash|sh)" | grep .ci | sed "s|^|$path/|" || git grep -lE "^#!(/usr)?/bin/(env )?(bash|sh)" | sed "s|^|$path/|"' && git ls-files './*.sh'; } | sort | uniq) 9 | 10 | ./utils/shellcheck.sh "${shellscript_locations[@]}" 11 | -------------------------------------------------------------------------------- /.ci/lint_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | exit_code=0 8 | 9 | "${CI_DIR}/helper_shellchecks.sh" || exit_code=1 10 | 11 | echo -e "\n${ANSI_GREEN}Luacheck results${ANSI_RESET}" 12 | luacheck -q ffi spec || exit_code=1 13 | 14 | echo -e "\n${ANSI_GREEN}CMakeLint results${ANSI_RESET}" 15 | mapfile -t cmake_files < <(git ls-files '*.cmake' '*/CMakeLists.txt') 16 | cmakelint "${cmake_files[@]}" || exit_code=1 17 | 18 | exit ${exit_code} 19 | -------------------------------------------------------------------------------- /.ci/test_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | exit_code=0 8 | 9 | echo -e "${ANSI_GREEN}Bincheck results${ANSI_RESET}" 10 | make bincheck || exit_code=1 11 | 12 | if [ "${EMULATE_READER}" = "1" ]; then 13 | echo -e "\n${ANSI_GREEN}Testsuite${ANSI_RESET}" 14 | ( 15 | # install test data 16 | travis_retry make test-data 17 | # finally make test 18 | travis_retry make --assume-old=all test T="-o '${PWD}/test-results.xml'" 19 | ) || exit_code=1 20 | else 21 | if [ "${TARGET}" = "android" ] && [ -f build/luajit ]; then 22 | echo -e "\n${ANSI_RED}ERROR${ANSI_RESET}: android build should not include luajit binary." 23 | exit_code=1 24 | fi 25 | fi 26 | 27 | exit ${exit_code} 28 | -------------------------------------------------------------------------------- /.cmakelintrc: -------------------------------------------------------------------------------- 1 | filter=-linelength 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_* 2 | ._* 3 | *.gz 4 | *.swp 5 | *.swo 6 | cscope.* 7 | *.orig 8 | tags 9 | 10 | /.cproject 11 | /.project 12 | 13 | /toolchain/android-ndk-r* 14 | /toolchain/android-sdk-linux 15 | /build 16 | 17 | /thirdparty/**/build 18 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "luafilesystem"] 2 | path = luafilesystem 3 | url = https://github.com/lunarmodules/luafilesystem.git 4 | [submodule "kpvcrlib/crengine"] 5 | path = thirdparty/kpvcrlib/crengine 6 | url = https://github.com/koreader/crengine.git 7 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | unused_args = false 2 | unused_secondaries = false 3 | std = "luajit" 4 | -- ignore implicit self 5 | self = false 6 | 7 | globals = { 8 | "G_defaults", 9 | "table.pack", 10 | "table.unpack", 11 | } 12 | 13 | exclude_files = { 14 | "build/*", 15 | "ffi/sha2.lua", 16 | "luafilesystem/*", 17 | "thirdparty/*", 18 | } 19 | 20 | files["spec/unit/*"].std = "+busted" 21 | 22 | -- TODO: clean up and enforce max line width (631) 23 | ignore = { 24 | "631", 25 | "dummy", 26 | } 27 | -------------------------------------------------------------------------------- /.luarc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", 3 | "runtime.version": "LuaJIT", 4 | } 5 | 6 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(koreader LANGUAGES C CXX) 3 | 4 | include(${CMAKE_KOVARS}) 5 | include(koreader_targets) 6 | 7 | foreach(NAME IN LISTS KOREADER_TARGETS) 8 | setup_target(${NAME}) 9 | endforeach() 10 | 11 | # vim: foldmethod=marker foldlevel=0 12 | -------------------------------------------------------------------------------- /cache-key.base: -------------------------------------------------------------------------------- 1 | # Includes. 2 | *.[ch] 3 | *.cpp 4 | *.patch 5 | /CMakeLists.txt 6 | /Makefile 7 | /Makefile.defs 8 | /cmake 9 | /luafilesystem 10 | /origin.ldflags 11 | /thirdparty/*/* 12 | /utils/gen_linker_exports.sh 13 | 14 | # Excludes. 15 | !*.lua 16 | !/ffi-cdecl/** 17 | !/test-runner/** 18 | !/utils/bincheck/* 19 | 20 | # Exceptions. 21 | /ffi-cdecl/koptcontext_cdecl.c 22 | /ffi-cdecl/wrap-mupdf_cdecl.c 23 | 24 | # vim: ft=gitignore 25 | -------------------------------------------------------------------------------- /cmake/crengine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS -DCMAKE_KOVARS=${CMAKE_KOVARS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 2 | 3 | list(APPEND BUILD_CMD COMMAND ninja) 4 | 5 | external_project( 6 | BUILD_ALWAYS 7 | CMAKE_ARGS ${CMAKE_ARGS} 8 | BUILD_COMMAND ${BUILD_CMD} 9 | ) 10 | -------------------------------------------------------------------------------- /cmake/koreader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(koreader_targets) 2 | 3 | list(APPEND CMAKE_ARGS -DCMAKE_KOVARS=${CMAKE_KOVARS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 4 | 5 | list(APPEND BUILD_CMD COMMAND ninja) 6 | 7 | external_project( 8 | BUILD_ALWAYS 9 | CMAKE_ARGS ${CMAKE_ARGS} 10 | BUILD_COMMAND ${BUILD_CMD} 11 | ) 12 | 13 | function(add_target_build_step NAME) 14 | cmake_parse_arguments("" "EXCLUDE_FROM_ALL" "" "DEPENDS" ${ARGN}) 15 | foreach(DEP IN LISTS _DEPENDS) 16 | if(NOT ${DEP} IN_LIST PROJECTS) 17 | message(FATAL_ERROR "trying to add ${PROJECT_NAME} step '${NAME}' with a dependency on undeclared project: ${DEP}") 18 | endif() 19 | endforeach() 20 | if(NOT _EXCLUDE_FROM_ALL AND _DEPENDS) 21 | add_dependencies(${PROJECT_NAME}-build ${_DEPENDS}) 22 | endif() 23 | set(COMMENT "Performing build step for '${NAME}'") 24 | add_custom_target(${NAME}-deps DEPENDS ${_DEPENDS}) 25 | add_custom_target( 26 | ${NAME} 27 | COMMENT ${COMMENT} 28 | COMMAND set -- ${PROJECT_NAME} ${COMMENT} 0 29 | COMMAND . ${KOENV} 30 | COMMAND ninja ${NAME} 31 | DEPENDS ${PROJECT_NAME}-configure ${NAME}-deps 32 | WORKING_DIRECTORY ${BINARY_DIR} 33 | USES_TERMINAL 34 | VERBATIM 35 | ) 36 | endfunction() 37 | 38 | function(add_targets) 39 | foreach(NAME IN LISTS KOREADER_TARGETS) 40 | if(${NAME}_EXCLUDE_FROM_ALL) 41 | set(EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL) 42 | else() 43 | set(EXCLUDE_FROM_ALL) 44 | endif() 45 | set(DEPENDS) 46 | foreach(DEP IN LISTS ${NAME}_DEPENDS) 47 | string(REGEX MATCH "^([^:]+)::([^:])+$" MATCHES ${DEP}) 48 | list(APPEND DEPENDS ${CMAKE_MATCH_1}) 49 | endforeach() 50 | add_target_build_step(${NAME} ${EXCLUDE_FROM_ALL} DEPENDS ${DEPENDS}) 51 | endforeach() 52 | endfunction() 53 | 54 | add_targets() 55 | -------------------------------------------------------------------------------- /cre.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: CREngine abstraction for Lua 3 | Copyright (C) 2012 Hans-Werner Hilse 4 | Qingping Hou 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #ifndef _CRENGING_H 21 | #define _CRENGING_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | // Symbol visibility 28 | #define DLL_PUBLIC __attribute__((visibility("default"))) 29 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 30 | 31 | DLL_PUBLIC int luaopen_cre(lua_State *L); 32 | #endif 33 | -------------------------------------------------------------------------------- /djvu.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: DjvuLibre abstraction for Lua 3 | Copyright (C) 2011 Hans-Werner Hilse 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _DJVU_H 19 | #define _DJVU_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | // Symbol visibility 26 | #define DLL_PUBLIC __attribute__((visibility("default"))) 27 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 28 | 29 | DLL_PUBLIC int luaopen_djvu(lua_State *L); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /drawcontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: a DC abstraction 3 | Copyright (C) 2012 Hans-Werner Hilse 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _DRAWCONTEXT_H 19 | #define _DRAWCONTEXT_H 20 | 21 | typedef struct DrawContext { 22 | int rotate; 23 | double zoom; 24 | double gamma; 25 | int offset_x; 26 | int offset_y; 27 | } DrawContext; 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /ev_replay.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | 4 | import pprint 5 | import struct 6 | import argparse 7 | 8 | EV_LOG = "ev_double.log" 9 | EV_PIPE = "/tmp/emu_event" 10 | 11 | def gen_ev_from_log_entry(line): 12 | values = line.split("|") 13 | return { 14 | "time": { 15 | "sec": int(values[3]), 16 | "usec": int(values[4]), 17 | }, 18 | "type": int(values[0]), 19 | "code": int(values[1]), 20 | "value": int(values[2]), 21 | } 22 | 23 | if __name__ == "__main__": 24 | parser = argparse.ArgumentParser() 25 | parser.add_argument("ev_log", type=str, 26 | help="event log file to replay") 27 | args = parser.parse_args() 28 | 29 | # parse ev log into dictionaries 30 | evs = [gen_ev_from_log_entry(line.strip()) 31 | for line in open(args.ev_log)] 32 | #pprint.pprint(evs) 33 | 34 | # replay evs 35 | ev_pipe = open(EV_PIPE, "w") 36 | for ev in evs: 37 | #@TODO also simulate timing here 25.02 2013 (houqp) 38 | ev_pipe.write( 39 | struct.pack("llHHi", 40 | ev["time"]["sec"], ev["time"]["usec"], 41 | ev["type"], 42 | ev["code"], 43 | ev["value"]) 44 | ) 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ffi-cdecl/android-luajit-launcher_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "ffi-cdecl.h" 2 | 3 | cdecl_func(Java_org_koreader_launcher_Assets_extract) 4 | -------------------------------------------------------------------------------- /ffi-cdecl/blitbuffer_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "blitbuffer.h" 2 | #include "ffi-cdecl.h" 3 | 4 | /* cdecl_type(Color4L) */ 5 | /* cdecl_struct(Color4L) */ 6 | /* cdecl_type(Color4U) */ 7 | /* cdecl_struct(Color4U) */ 8 | cdecl_type(Color8) 9 | cdecl_struct(Color8) 10 | cdecl_type(Color8A) 11 | cdecl_struct(Color8A) 12 | cdecl_type(ColorRGB16) 13 | cdecl_struct(ColorRGB16) 14 | cdecl_type(ColorRGB24) 15 | cdecl_struct(ColorRGB24) 16 | cdecl_type(ColorRGB32) 17 | cdecl_struct(ColorRGB32) 18 | 19 | cdecl_type(BlitBuffer) 20 | cdecl_struct(BlitBuffer) 21 | /* cdecl_type(BlitBuffer4) */ 22 | /* cdecl_struct(BlitBuffer4) */ 23 | cdecl_type(BlitBuffer8) 24 | cdecl_struct(BlitBuffer8) 25 | cdecl_type(BlitBuffer8A) 26 | cdecl_struct(BlitBuffer8A) 27 | cdecl_type(BlitBufferRGB16) 28 | cdecl_struct(BlitBufferRGB16) 29 | cdecl_type(BlitBufferRGB24) 30 | cdecl_struct(BlitBufferRGB24) 31 | cdecl_type(BlitBufferRGB32) 32 | cdecl_struct(BlitBufferRGB32) 33 | 34 | cdecl_func(BB_add_blit_from) 35 | cdecl_func(BB_alpha_blit_from) 36 | cdecl_func(BB_blend_rect) 37 | cdecl_func(BB_blend_RGB32_over_rect) 38 | cdecl_func(BB_blend_RGB_multiply_rect) 39 | cdecl_func(BB_blend_RGB32_multiply_rect) 40 | cdecl_func(BB_blit_to) 41 | cdecl_func(BB_color_blit_from) 42 | cdecl_func(BB_color_blit_from_RGB32) 43 | cdecl_func(BB_dither_alpha_blit_from) 44 | cdecl_func(BB_dither_blit_to) 45 | cdecl_func(BB_dither_pmulalpha_blit_from) 46 | cdecl_func(BB_fill) 47 | cdecl_func(BB_fill_rect) 48 | cdecl_func(BB_fill_rect_RGB32) 49 | cdecl_func(BB_hatch_rect) 50 | cdecl_func(BB_invert_blit_from) 51 | cdecl_func(BB_invert_rect) 52 | cdecl_func(BB_paint_rounded_corner) 53 | cdecl_func(BB_pmulalpha_blit_from) 54 | -------------------------------------------------------------------------------- /ffi-cdecl/crypto_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_func(PKCS5_PBKDF2_HMAC_SHA1) 6 | cdecl_func(EVP_CIPHER_CTX_new); 7 | cdecl_func(EVP_CIPHER_CTX_free); 8 | cdecl_func(EVP_CIPHER_CTX_set_padding); 9 | cdecl_func(EVP_CIPHER_block_size); 10 | cdecl_func(EVP_DecryptInit_ex); 11 | cdecl_func(EVP_DecryptUpdate); 12 | cdecl_func(EVP_DecryptFinal_ex); 13 | cdecl_func(EVP_aes_128_ecb); 14 | cdecl_func(EVP_aes_192_ecb); 15 | cdecl_func(EVP_aes_256_ecb); 16 | -------------------------------------------------------------------------------- /ffi-cdecl/einkfb_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | // specialized eink framebuffer headers 6 | typedef unsigned int u_int; 7 | typedef unsigned long u_long; 8 | #include "include/einkfb.h" 9 | 10 | #include "ffi-cdecl.h" 11 | 12 | cdecl_enum(fx_type) 13 | cdecl_struct(update_area_t) 14 | cdecl_enum(orientation_t) 15 | 16 | cdecl_enum(einkfb_events_t) 17 | cdecl_struct(einkfb_event_t) 18 | 19 | cdecl_const(FBIO_EINK_UPDATE_DISPLAY) 20 | cdecl_const(FBIO_EINK_UPDATE_DISPLAY_AREA) 21 | cdecl_const(FBIO_EINK_SET_DISPLAY_ORIENTATION) 22 | cdecl_const(FBIO_EINK_GET_DISPLAY_ORIENTATION) 23 | 24 | -------------------------------------------------------------------------------- /ffi-cdecl/giflib_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_const(GIF_OK) 6 | cdecl_const(GIF_ERROR) 7 | 8 | cdecl_type(GifWord) 9 | cdecl_type(GifByteType) 10 | 11 | cdecl_type(GifColorType) 12 | cdecl_struct(GifColorType) 13 | 14 | cdecl_type(ColorMapObject) 15 | cdecl_struct(ColorMapObject) 16 | 17 | cdecl_type(GifImageDesc) 18 | cdecl_struct(GifImageDesc) 19 | 20 | cdecl_type(ExtensionBlock) 21 | cdecl_struct(ExtensionBlock) 22 | 23 | cdecl_type(GraphicsControlBlock) 24 | cdecl_struct(GraphicsControlBlock) 25 | 26 | cdecl_type(SavedImage) 27 | cdecl_struct(SavedImage) 28 | 29 | cdecl_type(GifFileType) 30 | cdecl_struct(GifFileType) 31 | 32 | cdecl_func(DGifOpenFileName) 33 | cdecl_func(DGifOpenFileHandle) 34 | cdecl_func(DGifCloseFile) 35 | 36 | cdecl_func(DGifSlurp) 37 | 38 | cdecl_func(GifErrorString) 39 | 40 | cdecl_func(DGifSavedExtensionToGCB) 41 | cdecl_const(DISPOSAL_UNSPECIFIED) 42 | cdecl_const(DISPOSE_DO_NOT) 43 | cdecl_const(DISPOSE_BACKGROUND) 44 | cdecl_const(DISPOSE_PREVIOUS) 45 | cdecl_const(NO_TRANSPARENT_COLOR) 46 | 47 | cdecl_type(InputFunc) 48 | cdecl_func(DGifOpen) 49 | -------------------------------------------------------------------------------- /ffi-cdecl/harfbuzz_cdecl.c: -------------------------------------------------------------------------------- 1 | // CPPFLAGS="-I/usr/include/freetype2" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "ffi-cdecl.h" 7 | 8 | // The few bits we actually rely on for ffi/harfbuzz.lua 9 | cdecl_c99_type(hb_codepoint_t, uint32_t) 10 | cdecl_union(_hb_var_int_t) 11 | cdecl_type(hb_var_int_t) 12 | 13 | cdecl_type(hb_face_t) 14 | cdecl_type(hb_language_t) 15 | cdecl_type(hb_ot_name_id_t) 16 | cdecl_struct(hb_ot_name_entry_t) 17 | cdecl_type(hb_ot_name_entry_t) 18 | cdecl_type(hb_set_t) 19 | 20 | cdecl_func(hb_ot_name_list_names) 21 | cdecl_func(hb_language_to_string) 22 | cdecl_func(hb_ot_name_get_utf8) 23 | cdecl_func(hb_set_create) 24 | cdecl_func(hb_face_collect_unicodes) 25 | cdecl_func(hb_set_set) 26 | cdecl_func(hb_set_intersect) 27 | cdecl_func(hb_set_get_population) 28 | cdecl_func(hb_set_destroy) 29 | cdecl_func(hb_face_destroy) 30 | cdecl_func(hb_set_add_range) 31 | 32 | // And in front (frontend/fontlist.lua) 33 | cdecl_type(hb_blob_t) 34 | cdecl_type(hb_memory_mode_t) 35 | cdecl_type(hb_destroy_func_t) 36 | 37 | cdecl_const(HB_OT_NAME_ID_FONT_FAMILY) 38 | cdecl_const(HB_OT_NAME_ID_FONT_SUBFAMILY) 39 | cdecl_const(HB_OT_NAME_ID_FULL_NAME) 40 | 41 | cdecl_type(FT_Face) 42 | 43 | cdecl_func(hb_blob_create) 44 | cdecl_func(hb_face_create) 45 | cdecl_func(hb_blob_destroy) 46 | cdecl_func(hb_face_get_glyph_count) 47 | cdecl_func(hb_ft_face_create_referenced) 48 | -------------------------------------------------------------------------------- /ffi-cdecl/include/README: -------------------------------------------------------------------------------- 1 | The include file "einkfb.h" is distributed with Amazons Linux kernel sources 2 | for the Kindle. It has no further copyright notice, so it's assumed to be 3 | released under the GPLv2 originally. Under the "any later version" clause, it 4 | should be OK to include it in this GPLv3 application. 5 | 6 | -------------------------------------------------------------------------------- /ffi-cdecl/inotify_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_const(IN_ACCESS) 6 | cdecl_const(IN_ATTRIB) 7 | cdecl_const(IN_CLOSE_WRITE) 8 | cdecl_const(IN_CLOSE_NOWRITE) 9 | cdecl_const(IN_CREATE) 10 | cdecl_const(IN_DELETE) 11 | cdecl_const(IN_DELETE_SELF) 12 | cdecl_const(IN_MODIFY) 13 | cdecl_const(IN_MOVE_SELF) 14 | cdecl_const(IN_MOVED_FROM) 15 | cdecl_const(IN_MOVED_TO) 16 | cdecl_const(IN_OPEN) 17 | 18 | /* convenience macros */ 19 | cdecl_const(IN_ALL_EVENTS) 20 | cdecl_const(IN_MOVE) 21 | cdecl_const(IN_CLOSE) 22 | 23 | /* bits for mask of inotify_add_watch() */ 24 | cdecl_const(IN_DONT_FOLLOW) /* from 2.6.15 */ 25 | cdecl_const(IN_EXCL_UNLINK) /* from 2.6.36 */ 26 | cdecl_const(IN_MASK_ADD) 27 | cdecl_const(IN_ONESHOT) 28 | cdecl_const(IN_ONLYDIR) /* from 2.6.15 */ 29 | 30 | /* may be set for events read() */ 31 | cdecl_const(IN_IGNORED) 32 | cdecl_const(IN_ISDIR) 33 | cdecl_const(IN_Q_OVERFLOW) 34 | cdecl_const(IN_UNMOUNT) 35 | 36 | /* flags for inotify_init1() */ 37 | cdecl_const(IN_NONBLOCK) 38 | cdecl_const(IN_CLOEXEC) 39 | 40 | cdecl_func(inotify_init) 41 | cdecl_func(inotify_init1) /* from 2.6.27 */ 42 | cdecl_func(inotify_add_watch) 43 | cdecl_func(inotify_rm_watch) 44 | 45 | cdecl_struct(inotify_event) 46 | -------------------------------------------------------------------------------- /ffi-cdecl/ion_kobo_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | // specialized ION headers 3 | #include "include/ion-kobo.h" 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_type(ion_user_handle_t) 8 | cdecl_struct(ion_allocation_data) 9 | cdecl_struct(ion_fd_data) 10 | cdecl_struct(ion_handle_data) 11 | 12 | cdecl_const(ION_IOC_ALLOC) 13 | cdecl_const(ION_IOC_FREE) 14 | cdecl_const(ION_IOC_MAP) 15 | 16 | cdecl_enum(ion_heap_mask) 17 | -------------------------------------------------------------------------------- /ffi-cdecl/koptcontext_cdecl.c: -------------------------------------------------------------------------------- 1 | #define K2PDFOPT_EXPORT 2 | #define WILLUS_EXPORT 3 | 4 | #include "koptcrop.h" 5 | #include "koptimize.h" 6 | #include "koptocr.h" 7 | #include "koptreflow.h" 8 | 9 | #include "ffi-cdecl.h" 10 | 11 | // FIXME: only declared in `koptocr.c`… 12 | PIX* bitmap2pix(WILLUSBITMAP *src, int x, int y, int w, int h); 13 | 14 | cdecl_type(BBox) 15 | cdecl_type(BOXA) 16 | cdecl_type(NUMA) 17 | cdecl_type(PIX) 18 | cdecl_type(POINT2D) 19 | cdecl_type(WRECTMAP) 20 | cdecl_type(WRECTMAPS) 21 | cdecl_type(WILLUSBITMAP) 22 | cdecl_type(HYPHENINFO) 23 | cdecl_type(TEXTROW) 24 | cdecl_type(TEXTROWS) 25 | cdecl_type(BMPREGION) 26 | cdecl_type(PAGEREGION) 27 | cdecl_type(PAGEREGIONS) 28 | cdecl_struct(KOPTContext) 29 | cdecl_type(KOPTContext) 30 | 31 | cdecl_func(bmp_init) 32 | cdecl_func(bmp_free) 33 | cdecl_func(bmp_alloc) 34 | cdecl_func(bmp_bytewidth) 35 | cdecl_func(bmp_copy) 36 | cdecl_func(wrectmaps_init) 37 | cdecl_func(wrectmaps_free) 38 | cdecl_func(wrectmap_inside) 39 | cdecl_func(k2pdfopt_get_reflowed_word_boxes) 40 | cdecl_func(k2pdfopt_get_native_word_boxes) 41 | cdecl_func(k2pdfopt_tocr_single_word) 42 | cdecl_func(k2pdfopt_reflow_bmp) 43 | cdecl_func(k2pdfopt_tocr_end) 44 | cdecl_func(k2pdfopt_crop_bmp) 45 | cdecl_func(k2pdfopt_optimize_bmp) 46 | cdecl_func(pixmap_to_bmp) 47 | cdecl_func(bitmap2pix) 48 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-cre_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "cre.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_cre) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-djvu_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "djvu.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_djvu) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-input_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "input/input.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_input) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-lfs_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_lfs) 2 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-nnsvg_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "nnsvg.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_nnsvg) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-xtext_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "xtext.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_xtext) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/leptonica_cdecl.c: -------------------------------------------------------------------------------- 1 | // CPPFLAGS="-I/var/tmp/niluje/leptonica/src" 2 | #include 3 | 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_type(l_int8) 7 | cdecl_type(l_uint8) 8 | cdecl_type(l_int16) 9 | cdecl_type(l_uint16) 10 | cdecl_type(l_int32) 11 | cdecl_type(l_uint32) 12 | cdecl_type(l_float32) 13 | cdecl_type(l_float64) 14 | 15 | cdecl_type(BOX) 16 | cdecl_type(BOXA) 17 | cdecl_type(NUMA) 18 | cdecl_type(PIX) 19 | cdecl_type(PIXA) 20 | 21 | cdecl_const(L_NOCOPY) 22 | cdecl_const(L_COPY) 23 | cdecl_const(L_CLONE) 24 | 25 | cdecl_func(boxAdjustSides) 26 | cdecl_func(boxCreate) 27 | cdecl_func(boxDestroy) 28 | cdecl_func(boxGetGeometry) 29 | cdecl_func(boxOverlapRegion) 30 | cdecl_func(boxaAddBox) 31 | cdecl_func(boxaClipToBox) 32 | cdecl_func(boxaCombineOverlaps) 33 | cdecl_func(boxaCreate) 34 | cdecl_func(boxaDestroy) 35 | cdecl_func(boxaGetBox) 36 | cdecl_func(boxaGetBoxGeometry) 37 | cdecl_func(boxaGetCount) 38 | cdecl_func(numaCreateFromFArray) 39 | cdecl_func(numaDestroy) 40 | cdecl_func(numaGetCount) 41 | cdecl_func(numaGetFArray) 42 | cdecl_func(numaGetIValue) 43 | cdecl_func(pixClipRectangle) 44 | cdecl_func(pixClone) 45 | cdecl_func(pixConnCompBB) 46 | cdecl_func(pixConvertRGBToGrayFast) 47 | cdecl_func(pixConvertTo32) 48 | cdecl_func(pixDestroy) 49 | cdecl_func(pixDrawBoxaRandom) 50 | cdecl_func(pixGetDepth) 51 | cdecl_func(pixGetHeight) 52 | cdecl_func(pixGetRegionsBinary) 53 | cdecl_func(pixGetWidth) 54 | cdecl_func(pixInvert) 55 | cdecl_func(pixMultiplyByColor) 56 | cdecl_func(pixSplitIntoBoxa) 57 | cdecl_func(pixThresholdToBinary) 58 | cdecl_func(pixWriteMemPng) 59 | cdecl_func(pixWritePng) 60 | -------------------------------------------------------------------------------- /ffi-cdecl/libwebp_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_const(WEBP_DEMUX_ABI_VERSION) 8 | cdecl_enum(WEBP_CSP_MODE) 9 | 10 | cdecl_struct(WebPData) 11 | cdecl_type(WebPData) 12 | 13 | cdecl_struct(WebPAnimInfo) 14 | cdecl_type(WebPAnimInfo) 15 | 16 | cdecl_struct(WebPAnimDecoderOptions) 17 | cdecl_type(WebPAnimDecoderOptions) 18 | // cdecl_func(WebPAnimDecoderOptionsInit) // inline in demux.h 19 | cdecl_func(WebPAnimDecoderOptionsInitInternal) // we need to use this one 20 | 21 | cdecl_struct(WebPAnimDecoder) 22 | cdecl_type(WebPAnimDecoder) 23 | // cdecl_func(WebPAnimDecoderNew) // inline in demux.h 24 | cdecl_func(WebPAnimDecoderNewInternal) // we need to use this one 25 | cdecl_func(WebPAnimDecoderGetInfo) 26 | cdecl_func(WebPAnimDecoderGetNext) 27 | cdecl_func(WebPAnimDecoderReset) 28 | cdecl_func(WebPAnimDecoderDelete) 29 | -------------------------------------------------------------------------------- /ffi-cdecl/linux_fb_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | 6 | #include "ffi-cdecl.h" 7 | 8 | cdecl_const(FBIOGET_FSCREENINFO) 9 | cdecl_const(FBIOGET_VSCREENINFO) 10 | cdecl_const(FBIOPUT_VSCREENINFO) 11 | 12 | cdecl_const(FB_TYPE_PACKED_PIXELS) 13 | 14 | cdecl_const(FB_ROTATE_UR) 15 | cdecl_const(FB_ROTATE_CW) 16 | cdecl_const(FB_ROTATE_UD) 17 | cdecl_const(FB_ROTATE_CCW) 18 | 19 | cdecl_struct(fb_bitfield) 20 | cdecl_struct(fb_fix_screeninfo) 21 | cdecl_struct(fb_var_screeninfo) 22 | -------------------------------------------------------------------------------- /ffi-cdecl/lodepng_decl.c: -------------------------------------------------------------------------------- 1 | #define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS 2 | #include 3 | 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_enum(LodePNGColorType) 7 | cdecl_type(LodePNGColorType) 8 | cdecl_type(LodePNGDecompressSettings) 9 | cdecl_struct(LodePNGDecompressSettings) 10 | cdecl_struct(LodePNGDecoderSettings) 11 | cdecl_type(LodePNGDecoderSettings) 12 | cdecl_enum(LodePNGFilterStrategy) 13 | cdecl_type(LodePNGFilterStrategy) 14 | cdecl_type(LodePNGCompressSettings) 15 | cdecl_struct(LodePNGCompressSettings) 16 | cdecl_struct(LodePNGEncoderSettings) 17 | cdecl_type(LodePNGEncoderSettings) 18 | cdecl_struct(LodePNGColorMode) 19 | cdecl_type(LodePNGColorMode) 20 | cdecl_struct(LodePNGInfo) 21 | cdecl_type(LodePNGInfo) 22 | cdecl_struct(LodePNGState) 23 | cdecl_type(LodePNGState) 24 | cdecl_func(lodepng_error_text) 25 | cdecl_func(lodepng_decode32_file) 26 | cdecl_func(lodepng_decode32) 27 | cdecl_func(lodepng_decode24_file) 28 | cdecl_func(lodepng_decode24) 29 | cdecl_func(lodepng_decode_memory) 30 | cdecl_func(lodepng_decode_file) 31 | cdecl_func(lodepng_encode32_file) 32 | cdecl_func(lodepng_encode_file) 33 | cdecl_func(lodepng_state_init) 34 | cdecl_func(lodepng_state_cleanup) 35 | cdecl_func(lodepng_state_copy) 36 | cdecl_func(lodepng_decode) 37 | cdecl_func(lodepng_inspect) 38 | cdecl_func(lodepng_encode) 39 | -------------------------------------------------------------------------------- /ffi-cdecl/lpeg_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_lpeg) 2 | -------------------------------------------------------------------------------- /ffi-cdecl/lua-rapidjson_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_rapidjson) 2 | -------------------------------------------------------------------------------- /ffi-cdecl/luasec_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_ssl_config) 2 | cdecl_func(luaopen_ssl_context) 3 | cdecl_func(luaopen_ssl_core) 4 | cdecl_func(luaopen_ssl_x509) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/luasocket_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_mime_mcore) 2 | cdecl_func(luaopen_socket_score) 3 | -------------------------------------------------------------------------------- /ffi-cdecl/mxcfb_cervantes_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "include/mxcfb-cervantes.h" 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_const(UPDATE_MODE_PARTIAL) 7 | cdecl_const(UPDATE_MODE_FULL) 8 | 9 | cdecl_const(TEMP_USE_AMBIENT) 10 | 11 | cdecl_const(WAVEFORM_MODE_AUTO) 12 | 13 | cdecl_const(WAVEFORM_MODE_INIT) 14 | cdecl_const(WAVEFORM_MODE_DU) 15 | cdecl_const(WAVEFORM_MODE_GC16) 16 | cdecl_const(WAVEFORM_MODE_A2) 17 | cdecl_const(WAVEFORM_MODE_GL16) 18 | cdecl_const(WAVEFORM_MODE_GLR16) 19 | cdecl_const(WAVEFORM_MODE_GLD16) 20 | 21 | cdecl_const(EPDC_FLAG_ENABLE_INVERSION) 22 | cdecl_const(EPDC_FLAG_FORCE_MONOCHROME) 23 | cdecl_const(EPDC_FLAG_USE_ALT_BUFFER) 24 | cdecl_const(EPDC_FLAG_USE_CMAP) 25 | cdecl_const(EPDC_FLAG_TEST_COLLISION) 26 | cdecl_const(EPDC_FLAG_GROUP_UPDATE) 27 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y1) 28 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y4) 29 | cdecl_const(EPDC_FLAG_USE_AAD) 30 | cdecl_const(EPDC_FLAG_USE_DITHERING_NTX_D8) 31 | 32 | cdecl_struct(mxcfb_rect) 33 | 34 | cdecl_struct(mxcfb_alt_buffer_data) 35 | cdecl_struct(mxcfb_update_data) 36 | 37 | cdecl_const(MXCFB_SEND_UPDATE) 38 | cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) 39 | -------------------------------------------------------------------------------- /ffi-cdecl/mxcfb_remarkable_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | // specialized eink framebuffer headers 6 | #include "include/mxcfb-remarkable.h" 7 | 8 | #include "ffi-cdecl.h" 9 | 10 | cdecl_const(UPDATE_MODE_PARTIAL) 11 | cdecl_const(UPDATE_MODE_FULL) 12 | 13 | cdecl_const(WAVEFORM_MODE_INIT) 14 | cdecl_const(WAVEFORM_MODE_DU) 15 | cdecl_const(WAVEFORM_MODE_GC16) 16 | cdecl_const(WAVEFORM_MODE_GL16) 17 | cdecl_const(WAVEFORM_MODE_A2) 18 | 19 | cdecl_const(WAVEFORM_MODE_AUTO) 20 | 21 | cdecl_const(TEMP_USE_AMBIENT) 22 | cdecl_const(TEMP_USE_REMARKABLE) 23 | 24 | cdecl_const(EPDC_FLAG_ENABLE_INVERSION) 25 | cdecl_const(EPDC_FLAG_FORCE_MONOCHROME) 26 | cdecl_const(EPDC_FLAG_USE_CMAP) 27 | cdecl_const(EPDC_FLAG_USE_ALT_BUFFER) 28 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y1) 29 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y4) 30 | cdecl_const(EPDC_FLAG_USE_REGAL) 31 | 32 | cdecl_enum(mxcfb_dithering_mode) 33 | 34 | cdecl_struct(mxcfb_rect) 35 | cdecl_struct(mxcfb_alt_buffer_data) 36 | cdecl_struct(mxcfb_update_data) 37 | cdecl_struct(mxcfb_update_marker_data) 38 | 39 | cdecl_const(MXCFB_SEND_UPDATE) 40 | 41 | cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) 42 | -------------------------------------------------------------------------------- /ffi-cdecl/mxcfb_sony_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | // specialized eink framebuffer headers 6 | #include "include/mxcfb-sony.h" 7 | 8 | #include "ffi-cdecl.h" 9 | 10 | cdecl_const(UPDATE_MODE_PARTIAL) 11 | cdecl_const(UPDATE_MODE_FULL) 12 | 13 | cdecl_const(WAVEFORM_MODE_AUTO) 14 | cdecl_const(TEMP_USE_AMBIENT) 15 | 16 | cdecl_const(EPDC_FLAG_ENABLE_INVERSION) 17 | cdecl_const(EPDC_FLAG_FORCE_MONOCHROME) 18 | cdecl_const(EPDC_FLAG_USE_ALT_BUFFER) 19 | cdecl_const(EPDC_FLAG_SP1_1) 20 | cdecl_const(EPDC_FLAG_SP1_2) 21 | 22 | cdecl_struct(mxcfb_rect) 23 | cdecl_struct(mxcfb_alt_buffer_data) 24 | cdecl_struct(mxcfb_update_data) 25 | 26 | cdecl_const(MXCFB_SEND_UPDATE) 27 | 28 | cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) 29 | -------------------------------------------------------------------------------- /ffi-cdecl/openlipclua_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_libopenlipclua) 2 | -------------------------------------------------------------------------------- /ffi-cdecl/rtc_cdecl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ffi-cdecl.h" 7 | 8 | cdecl_struct(rtc_time) 9 | cdecl_struct(rtc_wkalrm) 10 | 11 | cdecl_const(RTC_AIE_ON) 12 | cdecl_const(RTC_AIE_OFF) 13 | cdecl_const(RTC_WKALM_SET) 14 | cdecl_const(RTC_WKALM_RD) 15 | cdecl_const(RTC_RD_TIME) 16 | 17 | cdecl_type(time_t) 18 | cdecl_struct(tm) 19 | cdecl_func(time) 20 | cdecl_func(gmtime) 21 | cdecl_func(gmtime_r) 22 | cdecl_func(localtime) 23 | cdecl_func(localtime_r) 24 | cdecl_func(timegm) 25 | cdecl_func(mktime) 26 | cdecl_func(settimeofday) 27 | cdecl_func(tzset) 28 | -------------------------------------------------------------------------------- /ffi-cdecl/sqlite3_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "sqlite3.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_type(sqlite3) 5 | cdecl_type(sqlite3_context) 6 | cdecl_type(sqlite3_stmt) 7 | cdecl_type(sqlite3_value) 8 | 9 | cdecl_func(sqlite3_aggregate_context) 10 | cdecl_func(sqlite3_bind_blob) 11 | cdecl_func(sqlite3_bind_double) 12 | cdecl_func(sqlite3_bind_int64) 13 | cdecl_func(sqlite3_bind_null) 14 | cdecl_func(sqlite3_bind_parameter_index) 15 | cdecl_func(sqlite3_bind_text) 16 | cdecl_func(sqlite3_busy_timeout) 17 | cdecl_func(sqlite3_clear_bindings) 18 | cdecl_func(sqlite3_close_v2) 19 | cdecl_func(sqlite3_column_blob) 20 | cdecl_func(sqlite3_column_bytes) 21 | cdecl_func(sqlite3_column_count) 22 | cdecl_func(sqlite3_column_double) 23 | cdecl_func(sqlite3_column_int64) 24 | cdecl_func(sqlite3_column_name) 25 | cdecl_func(sqlite3_column_text) 26 | cdecl_func(sqlite3_column_type) 27 | cdecl_func(sqlite3_create_function) 28 | cdecl_func(sqlite3_errmsg) 29 | cdecl_func(sqlite3_exec) 30 | cdecl_func(sqlite3_finalize) 31 | cdecl_func(sqlite3_open_v2) 32 | cdecl_func(sqlite3_prepare_v2) 33 | cdecl_func(sqlite3_reset) 34 | cdecl_func(sqlite3_result_blob) 35 | cdecl_func(sqlite3_result_double) 36 | cdecl_func(sqlite3_result_error) 37 | cdecl_func(sqlite3_result_int64) 38 | cdecl_func(sqlite3_result_text) 39 | cdecl_func(sqlite3_step) 40 | cdecl_func(sqlite3_value_blob) 41 | cdecl_func(sqlite3_value_bytes) 42 | cdecl_func(sqlite3_value_double) 43 | cdecl_func(sqlite3_value_int64) 44 | cdecl_func(sqlite3_value_text) 45 | cdecl_func(sqlite3_value_type) 46 | -------------------------------------------------------------------------------- /ffi-cdecl/sunxi_kobo_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | // specialized sunxi disp/eink headers 3 | #include "include/sunxi-kobo.h" 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_struct(area_info) 8 | cdecl_enum(eink_update_mode) 9 | cdecl_struct(disp_rectsz) 10 | cdecl_enum(disp_pixel_format) 11 | cdecl_enum(disp_color_space) 12 | cdecl_struct(disp_rect64) 13 | cdecl_enum(disp_buffer_flags) 14 | cdecl_enum(disp_scan_flags) 15 | cdecl_enum(disp_layer_mode) 16 | cdecl_struct(disp_rect) 17 | cdecl_enum(disp_3d_out_mode) 18 | cdecl_enum(disp_eotf) 19 | cdecl_enum(disp_atw_mode) 20 | cdecl_struct(disp_atw_info) 21 | cdecl_struct(disp_fb_info2) 22 | cdecl_struct(disp_layer_info2) 23 | cdecl_struct(disp_layer_config2) 24 | 25 | cdecl_const(DISP_EINK_UPDATE2) 26 | cdecl_const(DISP_EINK_WAIT_BEFORE_LCD_INT_COMPLETE) 27 | cdecl_const(DISP_EINK_SET_UPDATE_CONTROL) 28 | cdecl_const(DISP_EINK_WAIT_FRAME_SYNC_COMPLETE) 29 | cdecl_const(DISP_EINK_SET_NTX_HANDWRITE_ONOFF) 30 | cdecl_const(DISP_EINK_SET_WAIT_MODE_ONOFF) 31 | 32 | cdecl_type(sunxi_disp_raw_ioctl) 33 | cdecl_type(sunxi_disp_eink_update2) 34 | cdecl_type(sunxi_disp_eink_set_update_control) 35 | cdecl_type(sunxi_disp_eink_wait_frame_sync_complete) 36 | cdecl_type(sunxi_disp_eink_set_ntx_handwrite_onoff) 37 | cdecl_type(sunxi_disp_eink_set_wait_mode_onoff) 38 | 39 | cdecl_struct(disp_fb_info) 40 | cdecl_struct(disp_layer_info) 41 | cdecl_struct(disp_layer_config) 42 | cdecl_type(sunxi_disp_eink_update) 43 | cdecl_type(sunxi_disp_eink_set_temp) 44 | cdecl_type(sunxi_disp_eink_overlap_skip) 45 | cdecl_type(sunxi_disp_eink_set_gc_count) 46 | cdecl_struct(cfa_enable) 47 | cdecl_type(sunxi_disp_eink_set_bg_onoff) 48 | cdecl_type(sunxi_disp_layer_get_config2) 49 | cdecl_type(sunxi_disp_layer_get_config) 50 | cdecl_type(sunxi_disp_layer_generic_get) 51 | 52 | cdecl_type(sunxi_disp_eink_ioctl) 53 | -------------------------------------------------------------------------------- /ffi-cdecl/tffi_wrap_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "http-parser/http_parser.h" 2 | #include "turbo_ffi_wrap.h" 3 | 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_func(http_body_is_final) 7 | cdecl_func(http_errno_description) 8 | cdecl_func(http_errno_name) 9 | cdecl_func(http_method_str) 10 | cdecl_func(http_parser_execute) 11 | cdecl_func(http_parser_init) 12 | cdecl_func(http_parser_parse_url) 13 | cdecl_func(http_parser_pause) 14 | cdecl_func(http_parser_settings_init) 15 | cdecl_func(http_parser_url_init) 16 | cdecl_func(http_parser_version) 17 | cdecl_func(http_should_keep_alive) 18 | cdecl_func(turbo_bswap_u64) 19 | cdecl_func(turbo_parser_check) 20 | cdecl_func(turbo_parser_wrapper_exit) 21 | cdecl_func(turbo_parser_wrapper_init) 22 | cdecl_func(turbo_websocket_mask) 23 | cdecl_func(url_field) 24 | cdecl_func(url_field_is_set) 25 | cdecl_func(validate_hostname) 26 | -------------------------------------------------------------------------------- /ffi-cdecl/turbojpeg_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_enum(TJINIT) 6 | cdecl_enum(TJSAMP) 7 | cdecl_enum(TJPF) 8 | cdecl_enum(TJPARAM) 9 | 10 | cdecl_type(tjhandle) 11 | 12 | cdecl_func(tj3Init) 13 | cdecl_func(tj3Set) 14 | cdecl_func(tj3Get) 15 | cdecl_func(tj3Compress8) 16 | cdecl_func(tj3DecompressHeader) 17 | cdecl_func(tj3Decompress8) 18 | cdecl_func(tj3Destroy) 19 | cdecl_func(tj3SaveImage8) 20 | cdecl_func(tj3Free) 21 | -------------------------------------------------------------------------------- /ffi-cdecl/zeromq_cdecl.c: -------------------------------------------------------------------------------- 1 | // CPPFLAGS="-I/var/tmp/niluje/libzmq/include -I/var/tmp/niluje/czmq/include" 2 | #include 3 | #include 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_type(zmsg_t) 8 | cdecl_type(zhash_t) 9 | cdecl_type(zsock_t) 10 | cdecl_type(zframe_t) 11 | cdecl_type(zpoller_t) 12 | 13 | cdecl_const(ZFRAME_MORE) 14 | cdecl_const(ZFRAME_REUSE) 15 | cdecl_const(ZMQ_IDENTITY) 16 | cdecl_const(ZMQ_STREAM) 17 | 18 | cdecl_func(zmq_getsockopt) 19 | cdecl_func(zmq_send) 20 | 21 | cdecl_func(zsock_bind) 22 | cdecl_func(zsock_connect) 23 | cdecl_func(zsock_destroy) 24 | cdecl_func(zsock_new) 25 | cdecl_func(zsock_resolve) 26 | 27 | cdecl_func(zframe_data) 28 | cdecl_func(zframe_destroy) 29 | cdecl_func(zframe_recv) 30 | cdecl_func(zframe_send) 31 | cdecl_func(zframe_size) 32 | 33 | cdecl_func(zmsg_addmem) 34 | cdecl_func(zmsg_destroy) 35 | cdecl_func(zmsg_new) 36 | cdecl_func(zmsg_pop) 37 | cdecl_func(zmsg_popstr) 38 | cdecl_func(zmsg_send) 39 | cdecl_func(zmsg_size) 40 | 41 | cdecl_func(zstr_free) 42 | cdecl_func(zstr_send) 43 | 44 | cdecl_func(zhash_cursor) 45 | cdecl_func(zhash_destroy) 46 | cdecl_func(zhash_unpack) 47 | 48 | cdecl_func(zpoller_destroy) 49 | cdecl_func(zpoller_new) 50 | cdecl_func(zpoller_wait) 51 | -------------------------------------------------------------------------------- /ffi-cdecl/zlib_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_func(compressBound) 6 | cdecl_func(compress2) 7 | cdecl_func(crc32) 8 | cdecl_func(uncompress) 9 | 10 | -------------------------------------------------------------------------------- /ffi-cdecl/zstd_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_const(ZSTD_CLEVEL_DEFAULT) 6 | 7 | cdecl_func(ZSTD_compress) 8 | cdecl_func(ZSTD_decompress) 9 | cdecl_func(ZSTD_getFrameContentSize) 10 | cdecl_func(ZSTD_compressBound) 11 | cdecl_func(ZSTD_isError) 12 | cdecl_func(ZSTD_getErrorName) 13 | 14 | cdecl_type(ZSTD_DCtx) 15 | cdecl_type(ZSTD_ResetDirective) 16 | cdecl_func(ZSTD_createDCtx) 17 | cdecl_func(ZSTD_freeDCtx) 18 | cdecl_func(ZSTD_decompressDCtx) 19 | cdecl_func(ZSTD_DCtx_reset) 20 | -------------------------------------------------------------------------------- /ffi/MD5.lua: -------------------------------------------------------------------------------- 1 | --[[-- 2 | MD5 hash library. 3 | 4 | 5 | Deprecated except for sumFile. Use sha2 instead. 6 | 7 | @module ffi.md5 8 | ]] 9 | 10 | local sha2 = require "ffi/sha2" 11 | 12 | local md5 = {} 13 | 14 | --- Calculate md5 sum for a file. 15 | ---- @string filename 16 | ---- @treturn string md5 sum in Lua string 17 | function md5.sumFile(filename) 18 | local update = sha2.md5() 19 | local fd, err = io.open(filename, "rb") 20 | if err ~= nil then 21 | return nil, err 22 | end 23 | while true do 24 | local bytes = fd:read(8192) 25 | if not bytes then 26 | fd:close() 27 | break 28 | end 29 | update(bytes) 30 | end 31 | return update() 32 | end 33 | 34 | return md5 35 | -------------------------------------------------------------------------------- /ffi/__gc.lua: -------------------------------------------------------------------------------- 1 | -- This is https://github.com/katlogic/__gc/raw/master/__gc.lua 2 | local rg = assert(rawget) 3 | local proxy_key = "__gc_proxy" 4 | local rs = assert(rawset) 5 | local gmt = assert(debug.getmetatable) 6 | local smt = assert(setmetatable) 7 | local np = assert(newproxy) 8 | 9 | return function(t, mt) 10 | if mt ~= nil and rg(mt, "__gc") and not rg(t, "__gc_proxy") then 11 | local p = np(true) 12 | rs(t, proxy_key, p) 13 | gmt(p).__gc = function() 14 | rs(t, proxy_key, nil) 15 | local nmt = gmt(t) 16 | if not nmt then return end 17 | local fin = rg(nmt, "__gc") 18 | if fin then return fin(t) end 19 | end 20 | end 21 | return smt(t, mt) 22 | end 23 | -------------------------------------------------------------------------------- /ffi/crypto_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | int PKCS5_PBKDF2_HMAC_SHA1(const char *, int, const unsigned char *, int, int, int, unsigned char *); 7 | struct evp_cipher_ctx_st *EVP_CIPHER_CTX_new(void); 8 | void EVP_CIPHER_CTX_free(struct evp_cipher_ctx_st *); 9 | int EVP_CIPHER_CTX_set_padding(struct evp_cipher_ctx_st *, int); 10 | int EVP_CIPHER_block_size(const struct evp_cipher_st *); 11 | int EVP_DecryptInit_ex(struct evp_cipher_ctx_st *, const struct evp_cipher_st *, struct engine_st *, const unsigned char *, const unsigned char *); 12 | int EVP_DecryptUpdate(struct evp_cipher_ctx_st *, unsigned char *, int *, const unsigned char *, int); 13 | int EVP_DecryptFinal_ex(struct evp_cipher_ctx_st *, unsigned char *, int *); 14 | const struct evp_cipher_st *EVP_aes_128_ecb(void); 15 | const struct evp_cipher_st *EVP_aes_192_ecb(void); 16 | const struct evp_cipher_st *EVP_aes_256_ecb(void); 17 | ]] 18 | -------------------------------------------------------------------------------- /ffi/drawcontext.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Drawcontext structure 3 | 4 | FFI frontend 5 | ]] 6 | 7 | local ffi = require "ffi" 8 | 9 | ffi.cdef[[ 10 | typedef struct DrawContext { 11 | int rotate; 12 | double zoom; 13 | double gamma; 14 | int offset_x; 15 | int offset_y; 16 | } DrawContext; 17 | ]] 18 | 19 | local DC = {} 20 | local DC_mt = {__index={}} 21 | 22 | function DC_mt.__index:setRotate(rotate) self.rotate = rotate end 23 | function DC_mt.__index:getRotate() return self.rotate end 24 | function DC_mt.__index:setZoom(zoom) self.zoom = zoom end 25 | function DC_mt.__index:getZoom() return self.zoom end 26 | function DC_mt.__index:setOffset(x, y) 27 | self.offset_x = x or 0 28 | self.offset_y = y or 0 29 | end 30 | function DC_mt.__index:getOffset() return self.offset_x, self.offset_y end 31 | function DC_mt.__index:setGamma(gamma) self.gamma = gamma end 32 | function DC_mt.__index:getGamma() return self.gamma end 33 | 34 | local dctype = ffi.metatype("DrawContext", DC_mt) 35 | 36 | function DC.new(rotate, zoom, x, y, gamma) 37 | return dctype(rotate or 0, zoom or 1.0, gamma or -1.0, x or 0, y or 0) 38 | end 39 | 40 | return DC 41 | -------------------------------------------------------------------------------- /ffi/einkfb_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | enum fx_type { 7 | fx_mask = 11, 8 | fx_buf_is_mask = 14, 9 | fx_none = -1, 10 | fx_flash = 20, 11 | fx_invert = 21, 12 | fx_update_partial = 0, 13 | fx_update_full = 1, 14 | fx_update_fast = 2, 15 | fx_update_slow = 3, 16 | fx_buffer_load = 99, 17 | fx_buffer_display_partial = 100, 18 | fx_buffer_display_full = 101, 19 | }; 20 | struct update_area_t { 21 | int x1; 22 | int y1; 23 | int x2; 24 | int y2; 25 | enum fx_type which_fx; 26 | uint8_t *buffer; 27 | }; 28 | enum orientation_t { 29 | orientation_portrait = 0, 30 | orientation_portrait_upside_down = 1, 31 | orientation_landscape = 2, 32 | orientation_landscape_upside_down = 3, 33 | }; 34 | enum einkfb_events_t { 35 | einkfb_event_update_display = 0, 36 | einkfb_event_update_display_area = 1, 37 | einkfb_event_blank_display = 2, 38 | einkfb_event_rotate_display = 3, 39 | einkfb_event_null = -1, 40 | }; 41 | struct einkfb_event_t { 42 | enum einkfb_events_t event; 43 | enum fx_type update_mode; 44 | int x1; 45 | int y1; 46 | int x2; 47 | int y2; 48 | enum orientation_t orientation; 49 | }; 50 | static const int FBIO_EINK_UPDATE_DISPLAY = 18139; 51 | static const int FBIO_EINK_UPDATE_DISPLAY_AREA = 18141; 52 | static const int FBIO_EINK_SET_DISPLAY_ORIENTATION = 18160; 53 | static const int FBIO_EINK_GET_DISPLAY_ORIENTATION = 18161; 54 | ]] 55 | -------------------------------------------------------------------------------- /ffi/fbink_input_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | typedef enum { 7 | INPUT_UNKNOWN = 0, 8 | INPUT_POINTINGSTICK = 1, 9 | INPUT_MOUSE = 2, 10 | INPUT_TOUCHPAD = 4, 11 | INPUT_TOUCHSCREEN = 8, 12 | INPUT_JOYSTICK = 16, 13 | INPUT_TABLET = 32, 14 | INPUT_KEY = 64, 15 | INPUT_KEYBOARD = 128, 16 | INPUT_ACCELEROMETER = 256, 17 | INPUT_POWER_BUTTON = 65536, 18 | INPUT_SLEEP_COVER = 131072, 19 | INPUT_PAGINATION_BUTTONS = 262144, 20 | INPUT_HOME_BUTTON = 524288, 21 | INPUT_LIGHT_BUTTON = 1048576, 22 | INPUT_MENU_BUTTON = 2097152, 23 | INPUT_DPAD = 4194304, 24 | INPUT_ROTATION_EVENT = 8388608, 25 | INPUT_SCALED_TABLET = 16777216, 26 | INPUT_VOLUME_BUTTONS = 33554432, 27 | } __attribute__((packed)) INPUT_DEVICE_TYPE_E; 28 | typedef uint32_t INPUT_DEVICE_TYPE_T; 29 | typedef enum { 30 | SCAN_ONLY = 1, 31 | OPEN_BLOCKING = 2, 32 | MATCH_ALL = 4, 33 | EXCLUDE_ALL = 8, 34 | NO_RECAP = 16, 35 | } __attribute__((packed)) INPUT_SETTINGS_TYPE_E; 36 | typedef uint32_t INPUT_SETTINGS_TYPE_T; 37 | typedef struct { 38 | INPUT_DEVICE_TYPE_T type; 39 | int fd; 40 | bool matched; 41 | char name[256]; 42 | char path[4096]; 43 | } FBInkInputDevice; 44 | FBInkInputDevice *fbink_input_scan(INPUT_DEVICE_TYPE_T, INPUT_DEVICE_TYPE_T, INPUT_SETTINGS_TYPE_T, size_t *); 45 | FBInkInputDevice *fbink_input_check(const char *, INPUT_DEVICE_TYPE_T, INPUT_DEVICE_TYPE_T, INPUT_SETTINGS_TYPE_T); 46 | ]] 47 | -------------------------------------------------------------------------------- /ffi/framebuffer_dummy.lua: -------------------------------------------------------------------------------- 1 | local BB = require("ffi/blitbuffer") 2 | 3 | local framebuffer = {} 4 | 5 | function framebuffer:init() 6 | self.bb = BB.new(600, 800) 7 | self.bb:fill(BB.COLOR_WHITE) 8 | 9 | framebuffer.parent.init(self) 10 | end 11 | 12 | function framebuffer:resize(w, h) 13 | end 14 | 15 | function framebuffer:_newBB(w, h) 16 | local rotation 17 | local inverse 18 | 19 | if self.bb then 20 | rotation = self.bb:getRotation() 21 | inverse = self.bb:getInverse() == 1 22 | self.bb:free() 23 | end 24 | if self.invert_bb then self.invert_bb:free() end 25 | 26 | -- we present this buffer to the outside 27 | local bb = BB.new(w, h, BB.TYPE_BBRGB32) 28 | local flash = os.getenv("EMULATE_READER_FLASH") 29 | if flash then 30 | -- in refresh emulation mode, we use a shadow blitbuffer 31 | -- and blit refresh areas from it. 32 | self.bb = BB.new(w, h, BB.TYPE_BBRGB32) 33 | else 34 | self.bb = bb 35 | end 36 | self.invert_bb = BB.new(w, h, BB.TYPE_BBRGB32) 37 | 38 | if rotation then 39 | self.bb:setRotation(rotation) 40 | end 41 | 42 | -- reinit inverse mode on resize 43 | if inverse then 44 | self.bb:invert() 45 | end 46 | end 47 | 48 | function framebuffer:_render(bb, x, y, w, h) 49 | end 50 | 51 | function framebuffer:refreshFullImp(x, y, w, h) 52 | end 53 | 54 | function framebuffer:setWindowTitle(new_title) 55 | end 56 | 57 | function framebuffer:setWindowIcon(icon) 58 | end 59 | 60 | function framebuffer:close() 61 | end 62 | 63 | return require("ffi/framebuffer"):extend(framebuffer) 64 | -------------------------------------------------------------------------------- /ffi/framebuffer_einkfb.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | require("ffi/posix_h") 3 | require("ffi/einkfb_h") 4 | local C = ffi.C 5 | 6 | local framebuffer = {} 7 | 8 | local function einkfb_update(fb, refreshtype, x, y, w, h) 9 | x, y, w, h = fb.bb:getBoundedRect(x, y, w, h) 10 | x, y, w, h = fb.bb:getPhysicalRect(x, y, w, h) 11 | 12 | local refarea = ffi.new("struct update_area_t[1]") 13 | 14 | refarea[0].x1 = x or 0 15 | refarea[0].y1 = y or 0 16 | refarea[0].x2 = x + w 17 | refarea[0].y2 = y + h 18 | refarea[0].buffer = nil 19 | refarea[0].which_fx = refreshtype 20 | 21 | C.ioctl(fb.fd, C.FBIO_EINK_UPDATE_DISPLAY_AREA, refarea); 22 | end 23 | 24 | function framebuffer:refreshPartialImp(x, y, w, h) 25 | einkfb_update(self, C.fx_update_partial, x, y, w, h) 26 | end 27 | 28 | function framebuffer:refreshFullImp(x, y, w, h) 29 | einkfb_update(self, C.fx_update_full, x, y, w, h) 30 | end 31 | 32 | return require("ffi/framebuffer_linux"):extend(framebuffer) 33 | -------------------------------------------------------------------------------- /ffi/inotify_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int IN_ACCESS = 1; 7 | static const int IN_ATTRIB = 4; 8 | static const int IN_CLOSE_WRITE = 8; 9 | static const int IN_CLOSE_NOWRITE = 16; 10 | static const int IN_CREATE = 256; 11 | static const int IN_DELETE = 512; 12 | static const int IN_DELETE_SELF = 1024; 13 | static const int IN_MODIFY = 2; 14 | static const int IN_MOVE_SELF = 2048; 15 | static const int IN_MOVED_FROM = 64; 16 | static const int IN_MOVED_TO = 128; 17 | static const int IN_OPEN = 32; 18 | static const int IN_ALL_EVENTS = 4095; 19 | static const int IN_MOVE = 192; 20 | static const int IN_CLOSE = 24; 21 | static const int IN_DONT_FOLLOW = 33554432; 22 | static const int IN_EXCL_UNLINK = 67108864; 23 | static const int IN_MASK_ADD = 536870912; 24 | static const int IN_ONESHOT = 2147483648; 25 | static const int IN_ONLYDIR = 16777216; 26 | static const int IN_IGNORED = 32768; 27 | static const int IN_ISDIR = 1073741824; 28 | static const int IN_Q_OVERFLOW = 16384; 29 | static const int IN_UNMOUNT = 8192; 30 | static const int IN_NONBLOCK = 2048; 31 | static const int IN_CLOEXEC = 524288; 32 | int inotify_init(void) __attribute__((nothrow, leaf)); 33 | int inotify_init1(int) __attribute__((nothrow, leaf)); 34 | int inotify_add_watch(int, const char *, uint32_t) __attribute__((nothrow, leaf)); 35 | int inotify_rm_watch(int, int) __attribute__((nothrow, leaf)); 36 | struct inotify_event { 37 | int wd; 38 | uint32_t mask; 39 | uint32_t cookie; 40 | uint32_t len; 41 | char name[]; 42 | }; 43 | ]] 44 | -------------------------------------------------------------------------------- /ffi/input_SDL2_0.lua: -------------------------------------------------------------------------------- 1 | -- load common SDL input/video library 2 | local SDL = require("ffi/SDL2_0") 3 | 4 | return { 5 | open = SDL.open, 6 | waitForEvent = SDL.waitForEvent, 7 | -- NOPs: 8 | fakeTapInput = function() end, 9 | close = function() end, 10 | -- Input & Output are handled as one, and we call SDL_Quit in fb:close already 11 | closeAll = function() end, 12 | -- Tell front that we're a custom imp with no concept of paths/fd 13 | is_ffi = true, 14 | hasClipboardText = SDL.hasClipboardText, 15 | getClipboardText = SDL.getClipboardText, 16 | setClipboardText = SDL.setClipboardText, 17 | gameControllerRumble = SDL.gameControllerRumble, 18 | } 19 | -------------------------------------------------------------------------------- /ffi/ion_kobo_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | typedef int ion_user_handle_t; 7 | struct ion_allocation_data { 8 | size_t len; 9 | size_t align; 10 | unsigned int heap_id_mask; 11 | unsigned int flags; 12 | ion_user_handle_t handle; 13 | }; 14 | struct ion_fd_data { 15 | ion_user_handle_t handle; 16 | int fd; 17 | }; 18 | struct ion_handle_data { 19 | ion_user_handle_t handle; 20 | }; 21 | static const int ION_IOC_ALLOC = 3222554880; 22 | static const int ION_IOC_FREE = 3221506305; 23 | static const int ION_IOC_MAP = 3221768450; 24 | enum ion_heap_mask { 25 | ION_HEAP_MASK_SYSTEM = 1, 26 | ION_HEAP_MASK_SYSTEM_CONTIG = 2, 27 | ION_HEAP_MASK_CARVEOUT = 4, 28 | ION_HEAP_MASK_CHUNK = 8, 29 | ION_HEAP_MASK_DMA = 16, 30 | ION_HEAP_MASK_CUSTOM = 32, 31 | ION_HEAP_MASK_SECURE = 64, 32 | }; 33 | ]] 34 | -------------------------------------------------------------------------------- /ffi/kobolight.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | local bor = bit.bor 3 | local C = ffi.C 4 | 5 | -- for closing on garbage collection, we need a pointer or aggregate 6 | -- cdata object (not a plain "int"). So we encapsulate in a struct. 7 | ffi.cdef[[ 8 | typedef struct light_fd { int ld; } light_fd; 9 | ]] 10 | 11 | -- for ioctl header definition: 12 | require("ffi/posix_h") 13 | 14 | local kobolight = {} 15 | local kobolight_mt = {__index={}} 16 | 17 | function kobolight_mt.__index:close() 18 | -- this is redundant to garbage collection of the 19 | -- whole object and not strictly needed. 20 | -- it allows to force-close immediately, though. 21 | if self.light_fd and self.light_fd.ld ~= -1 then 22 | C.close(self.light_fd.ld) 23 | self.light_fd.ld = -1 24 | end 25 | end 26 | 27 | function kobolight_mt.__index:setBrightness(brightness) 28 | assert(brightness >= 0 and brightness <= 100, 29 | "Wrong brightness value given!") 30 | 31 | assert(C.ioctl(self.light_fd.ld, 241, ffi.cast("int", brightness)) == 0, 32 | "cannot change brightess value") 33 | end 34 | 35 | function kobolight.open(device) 36 | local light = { 37 | light_fd = nil, 38 | } 39 | 40 | local ld = C.open(device or "/dev/ntx_io", bor(C.O_RDONLY, C.O_NONBLOCK, C.O_CLOEXEC)) 41 | assert(ld ~= -1, "cannot open ntx_io character device") 42 | light.light_fd = ffi.gc( 43 | ffi.new("light_fd", ld), 44 | function (light_fd) C.close(light_fd.ld) end 45 | ) 46 | 47 | setmetatable(light, kobolight_mt) 48 | return light 49 | end 50 | 51 | return kobolight 52 | -------------------------------------------------------------------------------- /ffi/libwebp_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int WEBP_DEMUX_ABI_VERSION = 263; 7 | enum WEBP_CSP_MODE { 8 | MODE_RGB = 0, 9 | MODE_RGBA = 1, 10 | MODE_BGR = 2, 11 | MODE_BGRA = 3, 12 | MODE_ARGB = 4, 13 | MODE_RGBA_4444 = 5, 14 | MODE_RGB_565 = 6, 15 | MODE_rgbA = 7, 16 | MODE_bgrA = 8, 17 | MODE_Argb = 9, 18 | MODE_rgbA_4444 = 10, 19 | MODE_YUV = 11, 20 | MODE_YUVA = 12, 21 | MODE_LAST = 13, 22 | }; 23 | struct WebPData { 24 | const uint8_t *bytes; 25 | size_t size; 26 | }; 27 | typedef struct WebPData WebPData; 28 | struct WebPAnimInfo { 29 | uint32_t canvas_width; 30 | uint32_t canvas_height; 31 | uint32_t loop_count; 32 | uint32_t bgcolor; 33 | uint32_t frame_count; 34 | uint32_t pad[4]; 35 | }; 36 | typedef struct WebPAnimInfo WebPAnimInfo; 37 | struct WebPAnimDecoderOptions { 38 | enum WEBP_CSP_MODE color_mode; 39 | int use_threads; 40 | uint32_t padding[7]; 41 | }; 42 | typedef struct WebPAnimDecoderOptions WebPAnimDecoderOptions; 43 | int WebPAnimDecoderOptionsInitInternal(WebPAnimDecoderOptions *, int); 44 | struct WebPAnimDecoder; 45 | typedef struct WebPAnimDecoder WebPAnimDecoder; 46 | WebPAnimDecoder *WebPAnimDecoderNewInternal(const WebPData *, const WebPAnimDecoderOptions *, int); 47 | int WebPAnimDecoderGetInfo(const WebPAnimDecoder *, WebPAnimInfo *); 48 | int WebPAnimDecoderGetNext(WebPAnimDecoder *, uint8_t **, int *); 49 | void WebPAnimDecoderReset(WebPAnimDecoder *); 50 | void WebPAnimDecoderDelete(WebPAnimDecoder *); 51 | ]] 52 | -------------------------------------------------------------------------------- /ffi/linux_fb_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int FBIOGET_FSCREENINFO = 17922; 7 | static const int FBIOGET_VSCREENINFO = 17920; 8 | static const int FBIOPUT_VSCREENINFO = 17921; 9 | static const int FB_TYPE_PACKED_PIXELS = 0; 10 | static const int FB_ROTATE_UR = 0; 11 | static const int FB_ROTATE_CW = 1; 12 | static const int FB_ROTATE_UD = 2; 13 | static const int FB_ROTATE_CCW = 3; 14 | struct fb_bitfield { 15 | unsigned int offset; 16 | unsigned int length; 17 | unsigned int msb_right; 18 | }; 19 | struct fb_fix_screeninfo { 20 | char id[16]; 21 | long unsigned int smem_start; 22 | unsigned int smem_len; 23 | unsigned int type; 24 | unsigned int type_aux; 25 | unsigned int visual; 26 | short unsigned int xpanstep; 27 | short unsigned int ypanstep; 28 | short unsigned int ywrapstep; 29 | unsigned int line_length; 30 | long unsigned int mmio_start; 31 | unsigned int mmio_len; 32 | unsigned int accel; 33 | short unsigned int capabilities; 34 | short unsigned int reserved[2]; 35 | }; 36 | struct fb_var_screeninfo { 37 | unsigned int xres; 38 | unsigned int yres; 39 | unsigned int xres_virtual; 40 | unsigned int yres_virtual; 41 | unsigned int xoffset; 42 | unsigned int yoffset; 43 | unsigned int bits_per_pixel; 44 | unsigned int grayscale; 45 | struct fb_bitfield red; 46 | struct fb_bitfield green; 47 | struct fb_bitfield blue; 48 | struct fb_bitfield transp; 49 | unsigned int nonstd; 50 | unsigned int activate; 51 | unsigned int height; 52 | unsigned int width; 53 | unsigned int accel_flags; 54 | unsigned int pixclock; 55 | unsigned int left_margin; 56 | unsigned int right_margin; 57 | unsigned int upper_margin; 58 | unsigned int lower_margin; 59 | unsigned int hsync_len; 60 | unsigned int vsync_len; 61 | unsigned int sync; 62 | unsigned int vmode; 63 | unsigned int rotate; 64 | unsigned int colorspace; 65 | unsigned int reserved[4]; 66 | }; 67 | ]] 68 | -------------------------------------------------------------------------------- /ffi/mxcfb_cervantes_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int UPDATE_MODE_PARTIAL = 0; 7 | static const int UPDATE_MODE_FULL = 1; 8 | static const int TEMP_USE_AMBIENT = 4096; 9 | static const int WAVEFORM_MODE_AUTO = 257; 10 | static const int WAVEFORM_MODE_INIT = 0; 11 | static const int WAVEFORM_MODE_DU = 1; 12 | static const int WAVEFORM_MODE_GC16 = 2; 13 | static const int WAVEFORM_MODE_A2 = 4; 14 | static const int WAVEFORM_MODE_GL16 = 5; 15 | static const int WAVEFORM_MODE_GLR16 = 6; 16 | static const int WAVEFORM_MODE_GLD16 = 7; 17 | static const int EPDC_FLAG_ENABLE_INVERSION = 1; 18 | static const int EPDC_FLAG_FORCE_MONOCHROME = 2; 19 | static const int EPDC_FLAG_USE_ALT_BUFFER = 256; 20 | static const int EPDC_FLAG_USE_CMAP = 4; 21 | static const int EPDC_FLAG_TEST_COLLISION = 512; 22 | static const int EPDC_FLAG_GROUP_UPDATE = 1024; 23 | static const int EPDC_FLAG_USE_DITHERING_Y1 = 8192; 24 | static const int EPDC_FLAG_USE_DITHERING_Y4 = 16384; 25 | static const int EPDC_FLAG_USE_AAD = 4096; 26 | static const int EPDC_FLAG_USE_DITHERING_NTX_D8 = 1048576; 27 | struct mxcfb_rect { 28 | unsigned int top; 29 | unsigned int left; 30 | unsigned int width; 31 | unsigned int height; 32 | }; 33 | struct mxcfb_alt_buffer_data { 34 | void *virt_addr; 35 | unsigned int phys_addr; 36 | unsigned int width; 37 | unsigned int height; 38 | struct mxcfb_rect alt_update_region; 39 | }; 40 | struct mxcfb_update_data { 41 | struct mxcfb_rect update_region; 42 | unsigned int waveform_mode; 43 | unsigned int update_mode; 44 | unsigned int update_marker; 45 | int temp; 46 | unsigned int flags; 47 | struct mxcfb_alt_buffer_data alt_buffer_data; 48 | }; 49 | static const int MXCFB_SEND_UPDATE = 1078216238; 50 | static const int MXCFB_WAIT_FOR_UPDATE_COMPLETE = 1074021935; 51 | ]] 52 | -------------------------------------------------------------------------------- /ffi/mxcfb_sony_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | struct mxcfb_rect { 5 | unsigned int top; 6 | unsigned int left; 7 | unsigned int width; 8 | unsigned int height; 9 | }; 10 | 11 | struct mxcfb_alt_buffer_data { 12 | void* virt_addr; 13 | unsigned int phys_addr; 14 | unsigned int width; 15 | unsigned int height; 16 | struct mxcfb_rect alt_update_region; 17 | }; 18 | 19 | struct mxcfb_update_data { 20 | struct mxcfb_rect update_region; 21 | unsigned int waveform_mode; 22 | unsigned int update_mode; 23 | unsigned int update_marker; 24 | int temp; 25 | unsigned int flags; 26 | struct mxcfb_alt_buffer_data alt_buffer_data; 27 | }; 28 | 29 | static const int UPDATE_MODE_PARTIAL = 0; 30 | static const int UPDATE_MODE_FULL = 1; 31 | 32 | static const int WAVEFORM_MODE_INIT = 0; 33 | static const int WAVEFORM_MODE_DU = 1; 34 | static const int WAVEFORM_MODE_GC16 = 2; 35 | static const int WAVEFORM_MODE_GC4 = 3; 36 | static const int WAVEFORM_MODE_A2 = 4; 37 | static const int WAVEFORM_MODE_AUTO = 257; 38 | static const int TEMP_USE_AMBIENT = 4096; 39 | static const int TEMP_USE_AUTO = 4097; // this does not exist, simply use a value different than above 40 | static const int EPDC_FLAG_ENABLE_INVERSION = 1; 41 | static const int EPDC_FLAG_FORCE_MONOCHROME = 2; 42 | static const int EPDC_FLAG_USE_ALT_BUFFER = 256; 43 | 44 | static const int MXCFB_SEND_UPDATE = 1078216238; 45 | static const int MXCFB_WAIT_FOR_UPDATE_COMPLETE = 1074021935; 46 | ]] 47 | -------------------------------------------------------------------------------- /ffi/posix_types_64b_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | long unsigned int f_flag; 26 | long unsigned int f_namemax; 27 | int __f_spare[6]; 28 | }; 29 | ]] 30 | -------------------------------------------------------------------------------- /ffi/posix_types_def_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | int __f_unused; 26 | long unsigned int f_flag; 27 | long unsigned int f_namemax; 28 | int __f_spare[6]; 29 | }; 30 | ]] 31 | -------------------------------------------------------------------------------- /ffi/posix_types_x64_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | long unsigned int f_flag; 26 | long unsigned int f_namemax; 27 | int __f_spare[6]; 28 | }; 29 | ]] 30 | -------------------------------------------------------------------------------- /ffi/posix_types_x86_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | int __f_unused; 26 | long unsigned int f_flag; 27 | long unsigned int f_namemax; 28 | int __f_spare[6]; 29 | }; 30 | ]] 31 | -------------------------------------------------------------------------------- /ffi/rtc_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | struct rtc_time { 7 | int tm_sec; 8 | int tm_min; 9 | int tm_hour; 10 | int tm_mday; 11 | int tm_mon; 12 | int tm_year; 13 | int tm_wday; 14 | int tm_yday; 15 | int tm_isdst; 16 | }; 17 | struct rtc_wkalrm { 18 | unsigned char enabled; 19 | unsigned char pending; 20 | struct rtc_time time; 21 | }; 22 | static const int RTC_AIE_ON = 28673; 23 | static const int RTC_AIE_OFF = 28674; 24 | static const int RTC_WKALM_SET = 1076391951; 25 | static const int RTC_WKALM_RD = 2150133776; 26 | static const int RTC_RD_TIME = 2149871625; 27 | typedef long int time_t; 28 | struct tm { 29 | int tm_sec; 30 | int tm_min; 31 | int tm_hour; 32 | int tm_mday; 33 | int tm_mon; 34 | int tm_year; 35 | int tm_wday; 36 | int tm_yday; 37 | int tm_isdst; 38 | long int tm_gmtoff; 39 | const char *tm_zone; 40 | }; 41 | time_t time(time_t *) __attribute__((nothrow, leaf)); 42 | struct tm *gmtime(const time_t *) __attribute__((nothrow, leaf)); 43 | struct tm *gmtime_r(const time_t *restrict, struct tm *restrict) __attribute__((nothrow, leaf)); 44 | struct tm *localtime(const time_t *) __attribute__((nothrow, leaf)); 45 | struct tm *localtime_r(const time_t *restrict, struct tm *restrict) __attribute__((nothrow, leaf)); 46 | time_t timegm(struct tm *) __attribute__((nothrow, leaf)); 47 | time_t mktime(struct tm *) __attribute__((nothrow, leaf)); 48 | int settimeofday(const struct timeval *, const struct timezone *) __attribute__((nothrow, leaf)); 49 | void tzset(void) __attribute__((nothrow, leaf)); 50 | ]] 51 | -------------------------------------------------------------------------------- /ffi/turbojpeg_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | enum TJINIT { 7 | TJINIT_COMPRESS = 0, 8 | TJINIT_DECOMPRESS = 1, 9 | TJINIT_TRANSFORM = 2, 10 | }; 11 | enum TJSAMP { 12 | TJSAMP_444 = 0, 13 | TJSAMP_422 = 1, 14 | TJSAMP_420 = 2, 15 | TJSAMP_GRAY = 3, 16 | TJSAMP_440 = 4, 17 | TJSAMP_411 = 5, 18 | TJSAMP_441 = 6, 19 | TJSAMP_UNKNOWN = -1, 20 | }; 21 | enum TJPF { 22 | TJPF_RGB = 0, 23 | TJPF_BGR = 1, 24 | TJPF_RGBX = 2, 25 | TJPF_BGRX = 3, 26 | TJPF_XBGR = 4, 27 | TJPF_XRGB = 5, 28 | TJPF_GRAY = 6, 29 | TJPF_RGBA = 7, 30 | TJPF_BGRA = 8, 31 | TJPF_ABGR = 9, 32 | TJPF_ARGB = 10, 33 | TJPF_CMYK = 11, 34 | TJPF_UNKNOWN = -1, 35 | }; 36 | enum TJPARAM { 37 | TJPARAM_STOPONWARNING = 0, 38 | TJPARAM_BOTTOMUP = 1, 39 | TJPARAM_NOREALLOC = 2, 40 | TJPARAM_QUALITY = 3, 41 | TJPARAM_SUBSAMP = 4, 42 | TJPARAM_JPEGWIDTH = 5, 43 | TJPARAM_JPEGHEIGHT = 6, 44 | TJPARAM_PRECISION = 7, 45 | TJPARAM_COLORSPACE = 8, 46 | TJPARAM_FASTUPSAMPLE = 9, 47 | TJPARAM_FASTDCT = 10, 48 | TJPARAM_OPTIMIZE = 11, 49 | TJPARAM_PROGRESSIVE = 12, 50 | TJPARAM_SCANLIMIT = 13, 51 | TJPARAM_ARITHMETIC = 14, 52 | TJPARAM_LOSSLESS = 15, 53 | TJPARAM_LOSSLESSPSV = 16, 54 | TJPARAM_LOSSLESSPT = 17, 55 | TJPARAM_RESTARTBLOCKS = 18, 56 | TJPARAM_RESTARTROWS = 19, 57 | TJPARAM_XDENSITY = 20, 58 | TJPARAM_YDENSITY = 21, 59 | TJPARAM_DENSITYUNITS = 22, 60 | TJPARAM_MAXMEMORY = 23, 61 | TJPARAM_MAXPIXELS = 24, 62 | }; 63 | typedef void *tjhandle; 64 | tjhandle tj3Init(int); 65 | int tj3Set(tjhandle, int, int); 66 | int tj3Get(tjhandle, int); 67 | int tj3Compress8(tjhandle, const unsigned char *, int, int, int, int, unsigned char **, size_t *); 68 | int tj3DecompressHeader(tjhandle, const unsigned char *, size_t); 69 | int tj3Decompress8(tjhandle, const unsigned char *, size_t, unsigned char *, int, int); 70 | void tj3Destroy(tjhandle); 71 | int tj3SaveImage8(tjhandle, const char *, const unsigned char *, int, int, int, int); 72 | void tj3Free(void *); 73 | ]] 74 | -------------------------------------------------------------------------------- /ffi/zeromq_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | typedef struct _zmsg_t zmsg_t; 7 | typedef struct _zhash_t zhash_t; 8 | typedef struct _zsock_t zsock_t; 9 | typedef struct _zframe_t zframe_t; 10 | typedef struct _zpoller_t zpoller_t; 11 | static const int ZFRAME_MORE = 1; 12 | static const int ZFRAME_REUSE = 2; 13 | static const int ZMQ_IDENTITY = 5; 14 | static const int ZMQ_STREAM = 11; 15 | int zmq_getsockopt(void *, int, void *, size_t *); 16 | int zmq_send(void *, const void *, size_t, int); 17 | int zsock_bind(zsock_t *, const char *, ...); 18 | int zsock_connect(zsock_t *, const char *, ...); 19 | void zsock_destroy(zsock_t **); 20 | zsock_t *zsock_new(int); 21 | void *zsock_resolve(void *); 22 | unsigned char *zframe_data(zframe_t *); 23 | void zframe_destroy(zframe_t **); 24 | zframe_t *zframe_recv(void *); 25 | int zframe_send(zframe_t **, void *, int); 26 | size_t zframe_size(zframe_t *); 27 | int zmsg_addmem(zmsg_t *, const void *, size_t); 28 | void zmsg_destroy(zmsg_t **); 29 | zmsg_t *zmsg_new(void); 30 | zframe_t *zmsg_pop(zmsg_t *); 31 | char *zmsg_popstr(zmsg_t *); 32 | int zmsg_send(zmsg_t **, void *); 33 | size_t zmsg_size(zmsg_t *); 34 | void zstr_free(char **); 35 | int zstr_send(void *, const char *); 36 | const char *zhash_cursor(zhash_t *); 37 | void zhash_destroy(zhash_t **); 38 | zhash_t *zhash_unpack(zframe_t *); 39 | void zpoller_destroy(zpoller_t **); 40 | zpoller_t *zpoller_new(void *, ...); 41 | void *zpoller_wait(zpoller_t *, int); 42 | ]] 43 | -------------------------------------------------------------------------------- /ffi/zlib.lua: -------------------------------------------------------------------------------- 1 | --[[-- 2 | LuaJIT FFI wrapper for zlib. 3 | 4 | @module ffi.zlib 5 | ]] 6 | 7 | local ffi = require("ffi") 8 | require("ffi/zlib_h") 9 | 10 | local libz = ffi.loadlib("z", 1) 11 | 12 | local zlib = {} 13 | 14 | -- Data compression/decompression of strings via zlib 15 | -- from http://luajit.org/ext_ffi_tutorial.html 16 | function zlib.zlib_compress(data) 17 | local n = libz.compressBound(#data) 18 | local buf = ffi.new("uint8_t[?]", n) 19 | local buflen = ffi.new("unsigned long[1]", n) 20 | local res = libz.compress2(buf, buflen, data, #data, 9) 21 | assert(res == 0) 22 | return ffi.string(buf, buflen[0]) 23 | end 24 | 25 | function zlib.zlib_uncompress(zdata, datalen) 26 | local buf = ffi.new("uint8_t[?]", datalen) 27 | local buflen = ffi.new("unsigned long[1]", datalen) 28 | local res = libz.uncompress(buf, buflen, zdata, #zdata) 29 | assert(res == 0) 30 | return ffi.string(buf, buflen[0]) 31 | end 32 | 33 | return zlib 34 | -------------------------------------------------------------------------------- /ffi/zlib_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | long unsigned int compressBound(long unsigned int); 7 | int compress2(unsigned char *, long unsigned int *, const unsigned char *, long unsigned int, int); 8 | long unsigned int crc32(long unsigned int, const unsigned char *, unsigned int); 9 | int uncompress(unsigned char *, long unsigned int *, const unsigned char *, long unsigned int); 10 | ]] 11 | -------------------------------------------------------------------------------- /ffi/zstd_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int ZSTD_CLEVEL_DEFAULT = 3; 7 | size_t ZSTD_compress(void *, size_t, const void *, size_t, int); 8 | size_t ZSTD_decompress(void *, size_t, const void *, size_t); 9 | long long unsigned int ZSTD_getFrameContentSize(const void *, size_t); 10 | size_t ZSTD_compressBound(size_t); 11 | unsigned int ZSTD_isError(size_t); 12 | const char *ZSTD_getErrorName(size_t); 13 | typedef struct ZSTD_DCtx_s ZSTD_DCtx; 14 | typedef enum { 15 | ZSTD_reset_session_only = 1, 16 | ZSTD_reset_parameters = 2, 17 | ZSTD_reset_session_and_parameters = 3, 18 | } ZSTD_ResetDirective; 19 | ZSTD_DCtx *ZSTD_createDCtx(void); 20 | size_t ZSTD_freeDCtx(ZSTD_DCtx *); 21 | size_t ZSTD_decompressDCtx(ZSTD_DCtx *, void *, size_t, const void *, size_t); 22 | size_t ZSTD_DCtx_reset(ZSTD_DCtx *, ZSTD_ResetDirective); 23 | ]] 24 | -------------------------------------------------------------------------------- /input/inkview-compat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "inkview.h" 4 | 5 | #define COMPAT __attribute__((weak)) 6 | #define TICK_MS 20 7 | 8 | static int abc[3]; 9 | static pthread_t ivm_thread; 10 | static sem_t sem_notify, sem_poll; 11 | static iv_handler handler; 12 | static iv_mtinfo *gtcache; 13 | static int exiting; 14 | 15 | static void poll_timer() { 16 | SetWeakTimer("compat-poll", poll_timer, TICK_MS); // re-arm 17 | abc[0] = -1; // signals expiry 18 | sem_post(&sem_notify); 19 | sem_wait(&sem_poll); 20 | } 21 | 22 | static int ivm_proc(int a, int b, int c) { 23 | if (a == EVT_INIT) { 24 | SetWeakTimer("compat-poll", poll_timer, TICK_MS); 25 | sem_wait(&sem_poll); 26 | } 27 | abc[0] = a; 28 | abc[1] = b; 29 | abc[2] = c; 30 | if (a == EVT_EXIT) { 31 | exiting = 1; 32 | } else if (exiting) return 2; 33 | sem_post(&sem_notify); 34 | sem_wait(&sem_poll); 35 | return 0; 36 | } 37 | 38 | COMPAT void PrepareForLoop(iv_handler h) { 39 | handler = h; 40 | sem_init(&sem_notify, 0, 0);; 41 | sem_init(&sem_poll, 0, 0);; 42 | pthread_create(&ivm_thread, NULL, (void *)&InkViewMain, ivm_proc); 43 | } 44 | 45 | COMPAT void ProcessEventLoop() { 46 | sem_post(&sem_poll); 47 | sem_wait(&sem_notify); 48 | if (abc[0] != -1) 49 | handler(abc[0], abc[1], abc[2]); 50 | } 51 | 52 | COMPAT void ClearOnExit() { 53 | ClearTimer(poll_timer); 54 | if (!exiting) { 55 | LeaveInkViewMain(); 56 | exiting = 1; 57 | } 58 | sem_post(&sem_poll); 59 | sem_post(&sem_poll); 60 | pthread_join(ivm_thread, NULL); // until it escapes IVM 61 | sem_destroy(&sem_notify); 62 | sem_destroy(&sem_poll); 63 | } 64 | 65 | COMPAT iv_mtinfo *GetTouchInfoI(unsigned int i) { 66 | if (!i) gtcache = GetTouchInfo(); 67 | return gtcache + i; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /input/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: input abstraction for Lua 3 | Copyright (C) 2011 Hans-Werner Hilse 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _KO_INPUT_H 19 | #define _KO_INPUT_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | // Symbol visibility 26 | #define DLL_PUBLIC __attribute__((visibility("default"))) 27 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 28 | 29 | DLL_PUBLIC int luaopen_input(lua_State *L); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /koptcontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: a KOPTContext abstraction 3 | Copyright (C) 2012 Huang Xin 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _KOPTCONTEXT_H 19 | #define _KOPTCONTEXT_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include "context.h" 25 | #include "koptocr.h" 26 | 27 | int luaopen_koptcontext(lua_State *L); 28 | #endif 29 | -------------------------------------------------------------------------------- /libxss-dummy.c: -------------------------------------------------------------------------------- 1 | // Dummy symbol resolver for AppImage 2 | // See https://github.com/koreader/koreader/issues/4627 3 | // Thanks to https://github.com/AppImage/pkg2appimage/issues/127#issuecomment-278397037 4 | #include 5 | typedef unsigned long ulong; 6 | typedef unsigned int uint; 7 | typedef struct { Window window; int state; int kind; ulong til_or_since; ulong idle; ulong eventMask; } XScreenSaverInfo; 8 | Bool XScreenSaverQueryExtension(Display *dpy, int *event_base_return, int *error_base_return){} 9 | Status XScreenSaverQueryVersion(Display *dpy, int *major_version_return, int *minor_version_return){} 10 | XScreenSaverInfo *XScreenSaverAllocInfo(void){} 11 | Status XScreenSaverQueryInfo(Display *dpy, Drawable drawable, XScreenSaverInfo *saver_info){} 12 | void XScreenSaverSelectInput(register Display *dpy, Drawable drawable, ulong mask){} 13 | void XScreenSaverSetAttributes(Display *dpy, Drawable drawable, int x, int y, uint width, uint height, 14 | uint border_width, int depth, uint class, Visual *visual, ulong valuemask, XSetWindowAttributes *attributes){} 15 | void XScreenSaverUnsetAttributes(register Display *dpy, Drawable drawable){} 16 | Status XScreenSaverRegister(Display *dpy, int screen, XID xid, Atom type){} 17 | Status XScreenSaverUnregister(Display *dpy, int screen){} 18 | Status XScreenSaverGetRegistered(Display *dpy, int screen, XID *xid, Atom *type){} 19 | void XScreenSaverSuspend(Display *dpy, Bool suspend){} 20 | -------------------------------------------------------------------------------- /monolibtic.cpp: -------------------------------------------------------------------------------- 1 | // Nothing to see here… 2 | -------------------------------------------------------------------------------- /nnsvg.h: -------------------------------------------------------------------------------- 1 | // nnsvg.cpp 2 | // Lua interface to wrap nanosvg. 3 | 4 | #ifndef _NNSVG_H 5 | #define _NNSVG_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | // Symbol visibility 12 | #define DLL_PUBLIC __attribute__((visibility("default"))) 13 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 14 | 15 | DLL_PUBLIC int luaopen_nnsvg(lua_State *L); 16 | #endif 17 | -------------------------------------------------------------------------------- /origin.ldflags: -------------------------------------------------------------------------------- 1 | --disable-new-dtags -rpath $ORIGIN -rpath $ORIGIN/libs 2 | -------------------------------------------------------------------------------- /patches/lfs-visibility.patch: -------------------------------------------------------------------------------- 1 | --- a/src/lfs.h 2 | +++ b/src/lfs.h 3 | @@ -24,7 +24,7 @@ 4 | #define fileno(f) (_fileno(f)) 5 | #endif 6 | #else 7 | -#define LFS_EXPORT 8 | +#define LFS_EXPORT __attribute__((visibility("default"))) 9 | #endif 10 | 11 | #ifdef __cplusplus 12 | -------------------------------------------------------------------------------- /spec/unit/data/2col.jbig2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/2col.jbig2.pdf -------------------------------------------------------------------------------- /spec/unit/data/Alice.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/Alice.pdf -------------------------------------------------------------------------------- /spec/unit/data/Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/Paper.pdf -------------------------------------------------------------------------------- /spec/unit/data/encrypted-aes.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/encrypted-aes.zip -------------------------------------------------------------------------------- /spec/unit/data/encrypted-none.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/encrypted-none.zip -------------------------------------------------------------------------------- /spec/unit/data/encrypted-plain.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/encrypted-plain.zip -------------------------------------------------------------------------------- /spec/unit/data/sample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/sample.jpg -------------------------------------------------------------------------------- /spec/unit/data/simple-out-annotated.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/simple-out-annotated.pdf -------------------------------------------------------------------------------- /spec/unit/data/simple-out-annotation-deleted.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/simple-out-annotation-deleted.pdf -------------------------------------------------------------------------------- /spec/unit/data/simple-out.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/simple-out.pdf -------------------------------------------------------------------------------- /spec/unit/data/simple.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/simple.pdf -------------------------------------------------------------------------------- /spec/unit/data/simple.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 16 | 18 | 19 | 21 | image/svg+xml 22 | 24 | 25 | 26 | 27 | 28 | 30 | Simple test document 39 | 40 | 41 | -------------------------------------------------------------------------------- /spec/unit/data/testdocument.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/testdocument.odt -------------------------------------------------------------------------------- /spec/unit/data/testdocument.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/testdocument.pdf -------------------------------------------------------------------------------- /spec/unit/data/testfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/testfont.ttf -------------------------------------------------------------------------------- /spec/unit/data/transparency_various_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/1e10ca07ab962ec819de41be18057209d0144313/spec/unit/data/transparency_various_bg.png -------------------------------------------------------------------------------- /spec/unit/ffi_wrapper.lua: -------------------------------------------------------------------------------- 1 | -- Check if we're running a busted version recent enough that we don't need to deal with the LuaJIT hacks... 2 | -- That currently means > 2.0.0 (i.e., scm-2, which isn't on LuaRocks...). 3 | local busted_ok = false 4 | for name, _ in pairs(package.loaded) do 5 | if name == "busted.luajit" then 6 | busted_ok = true 7 | break 8 | end 9 | end 10 | 11 | -- Whee! 12 | if busted_ok then 13 | return 14 | end 15 | 16 | -- Don't try to overwrite metatables so we can use --auto-insulate-tests 17 | -- Shamelessly copied from https://github.com/Olivine-Labs/busted/commit/2dfff99bda01fd3da56fd23415aba5a2a4cc0ffd 18 | local ffi = require "ffi" 19 | 20 | local original_metatype = ffi.metatype 21 | local original_store = {} 22 | ffi.metatype = function (primary, ...) 23 | if original_store[primary] then 24 | return original_store[primary] 25 | end 26 | local success, result, err = pcall(original_metatype, primary, ...) 27 | if not success then 28 | -- hard error was thrown 29 | error(result, 2) 30 | end 31 | if not result then 32 | -- soft error was returned 33 | return result, err 34 | end 35 | -- it worked, store and return 36 | original_store[primary] = result 37 | return result 38 | end 39 | -------------------------------------------------------------------------------- /spec/unit/font_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | local ffi = require("ffi") 3 | 4 | describe("Low level font interfaces", function() 5 | it("FreeType and HarfBuzz FFI should work", function() 6 | assert.has_no.errors(function() 7 | -- HL wrappers are omitted deliberately - faster bisect in case those fail, but we don't. 8 | local ft = ffi.loadlib("freetype", "6") 9 | require("ffi/freetype_h") 10 | local hb = require("ffi/harfbuzz") 11 | 12 | -- This font is deliberately "odd" - raw ttf data - to test that both can see it the same 13 | local font = "spec/base/unit/data/testfont.ttf" 14 | local nglyphs = 15 15 | 16 | -- First try with HB 17 | local fontdata = io.open(font, "rb"):read("*a") 18 | local blob = hb.hb_blob_create(fontdata, #fontdata, hb.HB_MEMORY_MODE_READONLY, nil, nil) 19 | local face = hb.hb_face_create(blob, 0) 20 | hb.hb_blob_destroy(blob) 21 | assert.are.equals(hb.hb_face_get_glyph_count(face), nglyphs) 22 | hb.hb_face_destroy(face) 23 | 24 | -- Then with FT 25 | local ftlibp = ffi.new("FT_Library[1]") 26 | local facep = ffi.new("FT_Face[1]") 27 | ft.FT_Init_FreeType(ftlibp) 28 | ft.FT_New_Face(ftlibp[0], font, 0, facep) 29 | assert.are.equals(facep[0].num_glyphs, nglyphs) 30 | 31 | -- Try to turn the FT face into HB face 32 | face = hb.hb_ft_face_create_referenced(facep[0]) 33 | ft.FT_Done_Face(facep[0]) 34 | 35 | -- Check if it works 36 | assert.are.equals(hb.hb_face_get_glyph_count(face), nglyphs) 37 | hb.hb_face_destroy(face) 38 | --ft.FT_Done_FreeType(ftlibp[0]) 39 | end) 40 | end) 41 | end) 42 | 43 | -------------------------------------------------------------------------------- /spec/unit/framebuffer_spec.lua: -------------------------------------------------------------------------------- 1 | describe("Framebuffer unit tests", function() 2 | local fb 3 | 4 | setup(function() 5 | fb = require("ffi/framebuffer_dummy"):new{ 6 | dummy = true, 7 | device = { 8 | device_dpi = 167, 9 | } 10 | } 11 | end) 12 | 13 | it("should set & update DPI", function() 14 | assert.are.equals(160, fb:getDPI()) 15 | 16 | fb:setDPI(120) 17 | assert.are.equals(120, fb:getDPI()) 18 | 19 | fb:setDPI(60) 20 | assert.are.equals(60, fb:getDPI()) 21 | end) 22 | 23 | it("should scale by DPI", function() 24 | fb:setDPI(167) 25 | assert.are.equals(31, fb:scaleBySize(30)) 26 | 27 | fb:setDPI(167 * 3) 28 | assert.are.equals(62, fb:scaleBySize(30)) 29 | end) 30 | end) 31 | -------------------------------------------------------------------------------- /spec/unit/freetype_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | local Freetype = require("ffi/freetype") 3 | 4 | describe("Freetype module", function() 5 | it("should create new face size without error", function() 6 | assert.has_no.errors(function() 7 | local ftsize = Freetype.newFaceSize('./fonts/droid/DroidSansMono.ttf', 18) 8 | assert.are_not.equals(ftsize, nil) 9 | end) 10 | end) 11 | end) 12 | -------------------------------------------------------------------------------- /spec/unit/md5_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | 3 | describe("MD5 module", function() 4 | local md5, sha2 5 | 6 | setup(function() 7 | md5 = require("ffi/MD5") 8 | sha2 = require("ffi/sha2") 9 | end) 10 | 11 | it("should calculate correct MD5 hashes", function() 12 | assert.is_equal("d41d8cd98f00b204e9800998ecf8427e", sha2.md5("")) 13 | assert.is_equal("93b885adfe0da089cdf634904fd59f71", sha2.md5("\0")) 14 | assert.is_equal("1b05aba914a8b12315c7ee52b42f3d35", sha2.md5("0123456789abcdefX")) 15 | end) 16 | 17 | it("should calculate MD5 sum by updating", function() 18 | local update = sha2.md5() 19 | update("0123456789") 20 | update("abcdefghij") 21 | assert.is_equal(sha2.md5("0123456789abcdefghij"), update()) 22 | end) 23 | 24 | it("should calculate MD5 sum of a file", function() 25 | assert.is_equal( 26 | "ee53c8f032c3d047cb3d1999c8ff5e09", 27 | md5.sumFile("spec/base/unit/data/2col.jbig2.pdf")) 28 | end) 29 | 30 | it("should error out on non-exist file", function() 31 | local ok, err = md5.sumFile("foo/bar/abc/123/baz.pdf") 32 | assert.is.falsy(ok) 33 | assert.is_not_nil(err) 34 | end) 35 | end) 36 | 37 | -------------------------------------------------------------------------------- /spec/unit/nnsvg_spec.lua: -------------------------------------------------------------------------------- 1 | describe("nnsvg library", function() 2 | it("should load libkoreader-nnsvg library", function() 3 | local NnSVG = require("libs/libkoreader-nnsvg") 4 | assert.are_not.equal(NnSVG, nil) 5 | assert.are_not.equal(NnSVG.new, nil) 6 | end) 7 | 8 | describe("NnSVG.new", function() 9 | it("should parse SVG image", function() 10 | local svg_file = "spec/base/unit/data/simple.svg" 11 | local NnSVG = require("libs/libkoreader-nnsvg") 12 | local svg_image = NnSVG.new(svg_file) 13 | local native_w, native_h = svg_image:getSize() 14 | assert.are.equal(native_w, 744) 15 | assert.are.equal(native_h, 1052) 16 | end) 17 | 18 | end) 19 | end) 20 | -------------------------------------------------------------------------------- /spec/unit/png_spec.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | require("ffi_wrapper") 3 | local BB = require("ffi/blitbuffer") 4 | local Png = require("ffi/png") 5 | 6 | describe("Png module", function() 7 | it("should write bitmap to png file", function() 8 | local re, ok 9 | local fn = os.tmpname() 10 | local w, h = 40, 60 11 | local bb = BB.new(w, h, BB.TYPE_BBRGB32) 12 | bb:setPixel(0, 0, BB.ColorRGB32(128, 128, 128, 0)) 13 | bb:setPixel(20, 30, BB.ColorRGB32(10, 128, 205, 50)) 14 | bb:setPixel(40, 10, BB.ColorRGB32(120, 28, 25, 255)) 15 | 16 | local cdata = ffi.C.malloc(w * h * 4) 17 | local mem = ffi.cast("unsigned char*", cdata) 18 | for x = 0, w-1 do 19 | for y = 0, h-1 do 20 | local c = bb:getPixel(x, y):getColorRGB32() 21 | local offset = 4 * w * y + 4 * x 22 | mem[offset] = c.r 23 | mem[offset + 1] = c.g 24 | mem[offset + 2] = c.b 25 | mem[offset + 3] = c.alpha 26 | end 27 | end 28 | 29 | ok = Png.encodeToFile(fn, mem, w, h, 4) 30 | ffi.C.free(cdata) 31 | assert.are.same(ok, true) 32 | 33 | ok, re = Png.decodeFromFile(fn, 4) 34 | assert.are.same(ok, true) 35 | local bb2 = BB.new(re.width, re.height, BB.TYPE_BBRGB32, re.data) 36 | bb2:setAllocated(1) 37 | local c = bb2:getPixel(0, 0) 38 | assert.are.same({0x80, 0x80, 0x80, 0}, {c.r, c.g, c.b, c.alpha}) 39 | c = bb2:getPixel(20, 20) 40 | assert.are.same({0, 0, 0, 0}, {c.r, c.g, c.b, c.alpha}) 41 | c = bb2:getPixel(20, 30) 42 | assert.are.same({10, 128, 205, 50}, {c.r, c.g, c.b, c.alpha}) 43 | c = bb2:getPixel(40, 10) 44 | assert.are.same({120, 28, 25, 255}, {c.r, c.g, c.b, c.alpha}) 45 | os.remove(fn) 46 | end) 47 | end) 48 | -------------------------------------------------------------------------------- /spec/unit/qrencode_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | local qrencode = require("ffi/qrencode") 3 | 4 | describe("QRencode module", function() 5 | it("should match the defined result", function() 6 | local result = '2;2;2;2;2;2;2;-2;-2;-1;1;1;1;-2;2;2;2;2;2;2;2;2;-2;-2;-2;-2;-2;2;-2;-2;-1;-1;1;1;-2;2;-2;-2;' 7 | ..'-2;-2;-2;2;2;-2;2;2;2;-2;2;-2;-2;-1;1;-1;-1;-2;2;-2;2;2;2;-2;2;2;-2;2;2;2;-2;2;-2;2;1;1;1;-1;-2;2;-2;2;' 8 | ..'2;2;-2;2;2;-2;2;2;2;-2;2;-2;-2;1;-1;-1;-1;-2;2;-2;2;2;2;-2;2;2;-2;-2;-2;-2;-2;2;-2;-2;-1;-1;-1;1;-2;2;' 9 | ..'-2;-2;-2;-2;-2;2;2;2;2;2;2;2;2;-2;2;-2;2;-2;2;-2;2;2;2;2;2;2;2;-2;-2;-2;-2;-2;-2;-2;-2;-2;1;1;-1;-1;-2;' 10 | ..'-2;-2;-2;-2;-2;-2;-2;2;2;-2;2;2;2;2;-2;-2;1;1;-1;1;2;-2;-2;-2;2;-2;-2;-2;1;1;-1;-1;-1;1;-2;1;1;-1;-1;1;' 11 | ..'1;-1;1;1;-1;1;-1;1;-1;1;-1;1;-1;-1;-1;2;1;-1;-1;1;-1;1;-1;1;1;-1;-1;-1;-1;1;-1;-1;1;1;1;-1;-2;-1;1;-1;' 12 | ..'-1;-1;-1;1;1;-1;1;1;-1;1;1;1;-1;-1;1;-1;-1;2;1;-1;1;1;1;-1;1;-1;1;-1;-1;1;-1;-1;-2;-2;-2;-2;-2;-2;-2;-2;' 13 | ..'-2;-1;-1;-1;-1;1;-1;-1;1;-1;1;-1;1;2;2;2;2;2;2;2;-2;-2;1;1;1;-1;-1;1;1;1;-1;-1;1;-1;2;-2;-2;-2;-2;-2;2;' 14 | ..'-2;2;1;1;1;1;-1;-1;-1;-1;1;1;1;1;2;-2;2;2;2;-2;2;-2;2;-1;1;1;-1;1;1;-1;-1;-1;-1;-1;-1;2;-2;2;2;2;-2;2;' 15 | ..'-2;2;-1;1;1;1;1;-1;-1;1;1;-1;1;1;2;-2;2;2;2;-2;2;-2;-2;-1;1;-1;-1;-1;-1;-1;-1;-1;1;-1;1;2;-2;-2;-2;-2;' 16 | ..'-2;2;-2;2;1;-1;1;1;1;1;1;-1;1;-1;-1;1;2;2;2;2;2;2;2;-2;2;1;1;1;1;1;-1;-1;1;1;1;-1;-1;' 17 | local ok, tab = qrencode.qrcode('test') 18 | assert.are.same(ok, true) 19 | local ret = {} 20 | for _, col in ipairs(tab) do 21 | for _, lgn in ipairs(col) do 22 | table.insert(ret, lgn) 23 | table.insert(ret, ';') 24 | end 25 | end 26 | assert.are.same(table.concat(ret, ''), result) 27 | end) 28 | end) -------------------------------------------------------------------------------- /test-runner/busted_config.lua: -------------------------------------------------------------------------------- 1 | local lfs = require("lfs") 2 | 3 | local testsuites = {} 4 | local roots = {} 5 | local lpaths = {} 6 | for entry in lfs.dir("spec") do 7 | local attr = lfs.attributes("spec/" .. entry .. "/unit") 8 | if attr and attr.mode == "directory" then 9 | local testroot = "spec/" .. entry .. "/unit" 10 | local testpath = testroot .. "/?.lua" 11 | testsuites[entry] = {} 12 | testsuites[entry].ROOT = {testroot} 13 | testsuites[entry].lpath = testpath 14 | table.insert(roots, testroot) 15 | table.insert(lpaths, testpath) 16 | end 17 | end 18 | 19 | testsuites.all = { 20 | ROOT = roots, 21 | lpath = table.concat(lpaths, ";"), 22 | } 23 | 24 | return testsuites 25 | -------------------------------------------------------------------------------- /test-runner/busted_helper.lua: -------------------------------------------------------------------------------- 1 | -- Create `$KO_HOME` directory. 2 | local lfs = require("lfs") 3 | lfs.mkdir(os.getenv("KO_HOME")) 4 | -- Preload necessary busted modules and their dependencies (which 5 | -- are normally dynamically loaded during the testsuite execution). 6 | require("pl.dir") 7 | require("pl.List") 8 | require("busted.execute") 9 | require("busted.modules.files.lua") 10 | require("busted.modules.test_file_loader") 11 | -- Patch `package.path / package.cpath`: filter-out paths 12 | -- specific to the test framework (e.g. `spec/rocks/…`). 13 | local function filter_rocks(path) 14 | local filtered = {} 15 | for spec in string.gmatch(path, "([^;]+)") do 16 | if not spec:match("spec/rocks/") then 17 | table.insert(filtered, spec) 18 | end 19 | end 20 | return table.concat(filtered, ';') 21 | end 22 | package.path = filter_rocks(package.path) 23 | package.cpath = filter_rocks(package.cpath) 24 | -- Setup `ffi.loadlib` support. 25 | require("ffi/loadlib") 26 | -------------------------------------------------------------------------------- /thirdparty/android-luajit-launcher/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD 7z) 12 | endif() 13 | append_shared_lib_install_commands(INSTALL_CMD ioctl) 14 | append_shared_lib_install_commands(INSTALL_CMD luajit-launcher) 15 | 16 | external_project( 17 | CMAKE_ARGS ${CMAKE_ARGS} 18 | SOURCE_SUBDIR jni 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /thirdparty/cpu_features/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | # Project options. 4 | -DANDROID=${ANDROID} 5 | -DBUILD_EXECUTABLE=FALSE 6 | -DBUILD_TESTING=FALSE 7 | ) 8 | 9 | list(APPEND BUILD_CMD COMMAND ninja) 10 | 11 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 12 | 13 | external_project( 14 | DOWNLOAD URL 383ee74871f1e85e625a32c7e72e7777 15 | https://github.com/google/cpu_features/archive/refs/tags/v0.9.0.tar.gz 16 | CMAKE_ARGS ${CMAKE_ARGS} 17 | BUILD_COMMAND ${BUILD_CMD} 18 | INSTALL_COMMAND ${INSTALL_CMD} 19 | ) 20 | -------------------------------------------------------------------------------- /thirdparty/curl/clock_gettime_needs_rt.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -1369,6 +1369,10 @@ 4 | 5 | if(NOT WIN32) 6 | # Check clock_gettime(CLOCK_MONOTONIC, x) support 7 | + set(CMAKE_REQUIRED_LIBRARIES -lrt) 8 | curl_internal_test(HAVE_CLOCK_GETTIME_MONOTONIC) 9 | + if(HAVE_CLOCK_GETTIME_MONOTONIC) 10 | + list(APPEND CURL_LIBS "rt") 11 | + endif() 12 | endif() 13 | 14 | -------------------------------------------------------------------------------- /thirdparty/curl/fetch-ca-bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | output="$1" 4 | outdir="$(dirname "${output}")" 5 | 6 | mkdir -p "${outdir}" && curl \ 7 | --etag-compare "${output}.etag" \ 8 | --etag-save "${output}.etag" \ 9 | --output "${output}" \ 10 | --retry 3 \ 11 | https://curl.se/ca/cacert.pem 12 | code=$? 13 | 14 | if [ ${code} -ne 0 ]; then 15 | if [ -r "${output}" ]; then 16 | code=0 17 | severity=WARNING 18 | else 19 | severity=ERROR 20 | fi 21 | printf '\033[31;1m%s:\033[0m failed to fetch “%s”\n' "${severity}" "${output}" 1>&2 22 | fi 23 | 24 | exit ${code} 25 | 26 | # vim: sw=4 27 | -------------------------------------------------------------------------------- /thirdparty/curl/use_-pthread.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -378,6 +378,7 @@ 4 | if(WIN32) 5 | set(USE_THREADS_WIN32 ON) 6 | else() 7 | + set(THREADS_PREFER_PTHREAD_FLAG TRUE) 8 | find_package(Threads REQUIRED) 9 | set(USE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT}) 10 | set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT}) 11 | -------------------------------------------------------------------------------- /thirdparty/czmq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | if(ANDROID) 3 | list(APPEND PATCH_FILES android.patch) 4 | endif() 5 | 6 | # Pre-emptively remove `src/platform.h`: this is normaly done by 7 | # `CMakeLists.txt` at configure time, and wreaks havoc with `build.d` 8 | # generation. Since the later is done before configuring, a missing 9 | # `src/platform.h` would endlessly trigger a new czmq build. 10 | list(APPEND PATCH_CMD COMMAND rm src/platform.h) 11 | 12 | list(APPEND CMAKE_ARGS 13 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 14 | # Project options. 15 | -DCZMQ_BUILD_SHARED=$> 16 | -DCZMQ_BUILD_STATIC=$ 17 | -DENABLE_DRAFTS=FALSE 18 | # Disable some dependencies (which will automatically 19 | # disable the corresponding project optional features). 20 | -DCMAKE_DISABLE_FIND_PACKAGE_libcurl=TRUE 21 | -DCMAKE_DISABLE_FIND_PACKAGE_libmicrohttpd=TRUE 22 | -DCMAKE_DISABLE_FIND_PACKAGE_lz4=TRUE 23 | -DCMAKE_DISABLE_FIND_PACKAGE_nss=TRUE 24 | -DCMAKE_DISABLE_FIND_PACKAGE_systemd=TRUE 25 | -DCMAKE_DISABLE_FIND_PACKAGE_uuid=TRUE 26 | ) 27 | 28 | list(APPEND BUILD_CMD COMMAND ninja) 29 | 30 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 31 | 32 | if(NOT MONOLIBTIC) 33 | append_shared_lib_install_commands(INSTALL_CMD czmq VERSION 4) 34 | endif() 35 | 36 | external_project( 37 | DOWNLOAD URL 471e9ec120fc66a2fe2aae14359e3cfa 38 | https://github.com/zeromq/czmq/releases/download/v4.2.1/czmq-4.2.1.tar.gz 39 | PATCH_FILES ${PATCH_FILES} 40 | PATCH_COMMAND ${PATCH_CMD} 41 | CMAKE_ARGS ${CMAKE_ARGS} 42 | BUILD_COMMAND ${BUILD_CMD} 43 | INSTALL_COMMAND ${INSTALL_CMD} 44 | ) 45 | -------------------------------------------------------------------------------- /thirdparty/czmq/android.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -89,6 +89,7 @@ 4 | if(HAVE_CLOCK_GETTIME) 5 | list(APPEND MORE_LIBRARIES -lrt) 6 | endif() 7 | +list(APPEND MORE_LIBRARIES -llog) 8 | 9 | ######################################################################## 10 | # ZMQ dependency 11 | -------------------------------------------------------------------------------- /thirdparty/czmq/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -6,7 +6,7 @@ 4 | ######################################################################## 5 | # Project setup 6 | ######################################################################## 7 | -cmake_minimum_required(VERSION 2.8.12) 8 | +cmake_minimum_required(VERSION 3.17.5) 9 | project(czmq) 10 | enable_language(C) 11 | enable_testing() 12 | @@ -123,6 +123,13 @@ 13 | set(MORE_LIBRARIES) 14 | endif() 15 | 16 | +set(CMAKE_REQUIRED_LIBRARIES -lrt) 17 | +check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) 18 | +set(CMAKE_REQUIRED_LIBRARIES) 19 | +if(HAVE_CLOCK_GETTIME) 20 | + list(APPEND MORE_LIBRARIES -lrt) 21 | +endif() 22 | + 23 | list(APPEND CMAKE_MODULE_PATH "${SOURCE_DIR}") 24 | set(OPTIONAL_LIBRARIES) 25 | set(OPTIONAL_LIBRARIES_STATIC) 26 | @@ -544,6 +549,7 @@ 27 | ######################################################################## 28 | # executables 29 | ######################################################################## 30 | +if(FALSE) 31 | add_executable( 32 | zmakecert 33 | "${SOURCE_DIR}/src/zmakecert.c" 34 | @@ -631,6 +637,7 @@ 35 | ${OPTIONAL_LIBRARIES_STATIC} 36 | ) 37 | endif() 38 | +endif() 39 | 40 | ######################################################################## 41 | # tests 42 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Never *ever* call setlocale, for any reason. 2 | # Most of our target platforms have custom/broken/incomplete locales, don't screw with it. 3 | # And this runs in our main thread, so this is Very Bad(TM). 4 | list(APPEND PATCH_FILES djvulibre-no-locale-mangling.patch) 5 | # Remove references to (build specific) install directory in binary. 6 | list(APPEND PATCH_FILES no_references_to_install_dir.patch) 7 | 8 | if(ANDROID) 9 | list(APPEND PATCH_FILES android.patch) 10 | endif() 11 | 12 | list(APPEND PATCH_CMD COMMAND env NOCONFIGURE=1 ./autogen.sh) 13 | 14 | # fix build error due to -Werror under Fedora 26 (and potentially other systems) 15 | string(APPEND CFLAGS " -Wno-error") 16 | # Fix build error when compiling with -std=gnu++17: ISO 17 | # C++17 does not allow 'register' storage class specifier. 18 | string(APPEND CXXFLAGS " -Wno-register -Wno-error=register") 19 | # Fix symbols visibility. 20 | string(APPEND CFLAGS " -fvisibility=hidden") 21 | string(APPEND CXXFLAGS " -fvisibility=hidden -fvisibility-inlines-hidden") 22 | 23 | list(APPEND CFG_CMD COMMAND env) 24 | append_autotools_vars(CFG_CMD) 25 | list(APPEND CFG_CMD 26 | ${SOURCE_DIR}/configure --host=${CHOST} --prefix=/ 27 | --disable-shared --enable-static 28 | --disable-desktopfiles 29 | --disable-largefile 30 | --disable-xmltools 31 | --with-jpeg=${STAGING_DIR} 32 | --without-tiff 33 | ) 34 | 35 | list(APPEND BUILD_CMD COMMAND make -C libdjvu) 36 | 37 | list(APPEND INSTALL_CMD COMMAND make -C libdjvu DESTDIR=${STAGING_DIR} install) 38 | 39 | external_project( 40 | DOWNLOAD GIT 6a1e5ba1c9ef81c205a4b270c3f121a1e106f4fc 41 | https://gitlab.com/koreader/djvulibre.git 42 | PATCH_FILES ${PATCH_FILES} 43 | PATCH_COMMAND ${PATCH_CMD} 44 | CONFIGURE_COMMAND ${CFG_CMD} 45 | BUILD_COMMAND ${BUILD_CMD} 46 | INSTALL_COMMAND ${INSTALL_CMD} 47 | ) 48 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/android.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libdjvu/DjVuToPS.cpp b/libdjvu/DjVuToPS.cpp 2 | index f72a4c9..51b2ce3 100644 3 | --- a/libdjvu/DjVuToPS.cpp 4 | +++ b/libdjvu/DjVuToPS.cpp 5 | @@ -59,6 +59,9 @@ 6 | #if NEED_GNUG_PRAGMAS 7 | # pragma implementation 8 | #endif 9 | +#ifdef __ANDROID__ 10 | +# undef UNIX 11 | +#endif 12 | 13 | #include "DjVuToPS.h" 14 | #include "IFFByteStream.h" 15 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/djvulibre-no-locale-mangling.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libdjvu/GString.cpp b/libdjvu/GString.cpp 2 | index b17ed2a..5f844bd 100644 3 | --- a/libdjvu/GString.cpp 4 | +++ b/libdjvu/GString.cpp 5 | @@ -88,14 +88,7 @@ 6 | #endif 7 | #include 8 | 9 | -#ifndef LC_NUMERIC //MingW 10 | -# undef DO_CHANGELOCALE 11 | -# define LC_NUMERIC 0 12 | -#endif 13 | -#ifndef DO_CHANGELOCALE 14 | -# define DO_CHANGELOCALE 0 15 | -#endif 16 | - 17 | +#undef DO_CHANGELOCALE 18 | 19 | #ifdef HAVE_NAMESPACES 20 | namespace DJVU { 21 | @@ -241,11 +234,6 @@ GStringRep::UTF8::create(const char fmt[],va_list& args) 22 | 23 | #define NATIVE_CREATE(x) UTF8::create( x ); 24 | 25 | -#ifdef LC_ALL 26 | -#undef LC_ALL 27 | -#endif 28 | -#define LC_ALL 0 29 | - 30 | class GStringRep::ChangeLocale 31 | { 32 | public: 33 | diff --git a/libdjvu/ddjvuapi.cpp b/libdjvu/ddjvuapi.cpp 34 | index c6cecfe..c0fef7d 100644 35 | --- a/libdjvu/ddjvuapi.cpp 36 | +++ b/libdjvu/ddjvuapi.cpp 37 | @@ -358,12 +358,6 @@ ddjvu_context_create(const char *programname) 38 | ddjvu_context_t *ctx = 0; 39 | G_TRY 40 | { 41 | -#ifdef LC_ALL 42 | - setlocale(LC_ALL,""); 43 | -# ifdef LC_NUMERIC 44 | - setlocale(LC_NUMERIC, "C"); 45 | -# endif 46 | -#endif 47 | if (programname) 48 | djvu_programname(programname); 49 | DjVuMessage::use_language(); 50 | diff --git a/tools/common.h b/tools/common.h 51 | index e28fb58..873fbb7 100644 52 | --- a/tools/common.h 53 | +++ b/tools/common.h 54 | @@ -76,8 +76,6 @@ 55 | djvu_programname(argv[0]); } while (0) 56 | #else 57 | # define DJVU_LOCALE do { \ 58 | - setlocale(LC_ALL,""); \ 59 | - setlocale(LC_NUMERIC,"C"); \ 60 | djvu_programname(argv[0]); } while (0) 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/no_references_to_install_dir.patch: -------------------------------------------------------------------------------- 1 | --- a/libdjvu/DjVuMessage.cpp 2 | +++ b/libdjvu/DjVuMessage.cpp 3 | @@ -117,7 +117,7 @@ static const char localestring[]="locale"; 4 | 5 | 6 | // directory names for searching messages 7 | -#ifdef AUTOCONF 8 | +#if 0//def AUTOCONF 9 | static const char DjVuDataDir[] = DIR_DATADIR "/djvu/osi"; 10 | #endif /* AUTOCONF */ 11 | static const char ModuleDjVuDir[] ="share/djvu/osi"; 12 | @@ -291,7 +291,7 @@ DjVuMessage::GetProfilePaths(void) 13 | appendPath(GURL::UTF8(ProfilesDjVuDir,mpath),pathsmap,paths); 14 | } 15 | #endif 16 | -#if defined(AUTOCONF) 17 | +#if 0//defined(AUTOCONF) 18 | GURL dpath = GURL::Filename::UTF8(DjVuDataDir); 19 | appendPath(dpath,pathsmap,paths); 20 | #endif 21 | -------------------------------------------------------------------------------- /thirdparty/dkjson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD dkjson.lua DESTINATION common) 5 | 6 | external_project( 7 | DOWNLOAD URL d7754634dcbe6e95f3b6b55fd4ca5ceb 8 | http://dkolf.de/dkjson-lua/dkjson-2.8.tar.gz 9 | INSTALL_COMMAND ${INSTALL_CMD} 10 | ) 11 | -------------------------------------------------------------------------------- /thirdparty/dropbear/dbscp-path.patch: -------------------------------------------------------------------------------- 1 | --- i/src/svr-chansession.c 2 | +++ w/src/svr-chansession.c 3 | @@ -678,6 +678,17 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess, 4 | TRACE(("leave sessioncommand, command too long %d", cmdlen)) 5 | return DROPBEAR_FAILURE; 6 | } 7 | + 8 | +#ifdef DBSCP_PATH 9 | + // HACK. This is terrible. Truly, truly awful. 10 | + if (strncmp(chansess->cmd, "scp", 3) == 0) { 11 | + char* mangled_cmd = m_malloc(cmdlen + sizeof(DBSCP_PATH)); 12 | + snprintf(mangled_cmd, cmdlen + sizeof(DBSCP_PATH) + 1, "%s/%s", DBSCP_PATH, chansess->cmd); 13 | + m_free(chansess->cmd); 14 | + chansess->cmd = m_strdup(mangled_cmd); 15 | + m_free(mangled_cmd); 16 | + } 17 | +#endif 18 | } 19 | if (issubsys) { 20 | #if DROPBEAR_SFTPSERVER 21 | -------------------------------------------------------------------------------- /thirdparty/dropbear/localoptions.h.cmake: -------------------------------------------------------------------------------- 1 | #cmakedefine DEBUG_TRACE @DEBUG_TRACE@ 2 | #cmakedefine DROPBEAR_DEFPORT "@DROPBEAR_DEFPORT@" 3 | #cmakedefine01 DROPBEAR_SMALL_CODE 4 | #cmakedefine01 DROPBEAR_X11FWD 5 | #cmakedefine01 INETD_MODE 6 | #cmakedefine01 LOG_COMMANDS 7 | // Paths. 8 | #cmakedefine DBSCP_PATH "@DBSCP_PATH@" 9 | #cmakedefine DEFAULT_PATH "@DEFAULT_PATH@" 10 | #cmakedefine DROPBEAR_PATH_SSH_PROGRAM "@DROPBEAR_PATH_SSH_PROGRAM@" 11 | #cmakedefine DROPBEAR_PIDFILE "@DROPBEAR_PIDFILE@" 12 | #cmakedefine SFTPSERVER_PATH "@SFTPSERVER_PATH@" 13 | // Keys. 14 | #cmakedefine DSS_PRIV_FILENAME "@DSS_PRIV_FILENAME@" 15 | #cmakedefine RSA_PRIV_FILENAME "@RSA_PRIV_FILENAME@" 16 | #cmakedefine ECDSA_PRIV_FILENAME "@ECDSA_PRIV_FILENAME@" 17 | #cmakedefine ED25519_PRIV_FILENAME "@ED25519_PRIV_FILENAME@" 18 | // Extra part of the SSH server identification string. 19 | #define IDENT_VERSION_PART "_" DROPBEAR_VERSION " (KOReader)" 20 | // Disable mlkem769 (post-quantum key exchange): sntrup761 is 21 | // already available and much lighter in terms of code size. 22 | #define DROPBEAR_MLKEM768 0 23 | -------------------------------------------------------------------------------- /thirdparty/dropbear/nochdir-hack.patch: -------------------------------------------------------------------------------- 1 | --- i/src/svr-main.c 2 | +++ w/src/svr-main.c 3 | @@ -185,7 +185,7 @@ static void main_noinetd(int argc, char ** argv, const char* multipath) { 4 | closefds = 1; 5 | } 6 | #endif 7 | - if (daemon(0, closefds) < 0) { 8 | + if (daemon(1, closefds) < 0) { 9 | dropbear_exit("Failed to daemonize: %s", strerror(errno)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /thirdparty/dropbear/nopasswd-hack.patch: -------------------------------------------------------------------------------- 1 | --- i/src/runopts.h 2 | +++ w/src/runopts.h 3 | @@ -121,6 +121,7 @@ typedef struct svr_runopts { 4 | 5 | buffer * banner; 6 | char * pidfile; 7 | + int nopasschk; 8 | 9 | char * authorized_keys_dir; 10 | 11 | --- i/src/svr-authpasswd.c 12 | +++ w/src/svr-authpasswd.c 13 | @@ -80,6 +80,15 @@ void svr_auth_password(int valid_user) { 14 | return; 15 | } 16 | 17 | + /* 18 | + * Hack. Always auth successfully if we were launched with the -n flag. 19 | + */ 20 | + if (svr_opts.nopasschk) { 21 | + dropbear_log(LOG_WARNING, "Password-less mode enabled, you're in!"); 22 | + send_msg_userauth_success(); 23 | + return; 24 | + } 25 | + 26 | if (passwordlen > DROPBEAR_MAX_PASSWORD_LEN) { 27 | dropbear_log(LOG_WARNING, 28 | "Too-long password attempt for '%s' from %s", 29 | --- i/src/svr-runopts.c 30 | +++ w/src/svr-runopts.c 31 | @@ -106,6 +106,7 @@ static void printhelp(const char * progname) { 32 | "-l \n" 33 | " interface to bind on\n" 34 | #endif 35 | + "-n Disable password checking (/!\\ Hack, don't use this!)\n" 36 | #if INETD_MODE 37 | "-i Start for inetd\n" 38 | #endif 39 | @@ -177,6 +178,7 @@ void svr_getopts(int argc, char ** argv) { 40 | svr_opts.delay_hostkey = 0; 41 | svr_opts.pidfile = expand_homedir_path(DROPBEAR_PIDFILE); 42 | svr_opts.authorized_keys_dir = "~/.ssh"; 43 | + svr_opts.nopasschk = 0; 44 | #if DROPBEAR_SVR_LOCALANYFWD 45 | svr_opts.nolocaltcp = 0; 46 | #endif 47 | @@ -279,6 +281,9 @@ void svr_getopts(int argc, char ** argv) { 48 | case 'P': 49 | next = &svr_opts.pidfile; 50 | break; 51 | + case 'n': 52 | + svr_opts.nopasschk = 1; 53 | + break; 54 | #ifdef SO_BINDTODEVICE 55 | case 'l': 56 | next = &svr_opts.interface; 57 | -------------------------------------------------------------------------------- /thirdparty/dropbear/reduce_build_verbosity.patch: -------------------------------------------------------------------------------- 1 | --- i/Makefile.in 2 | +++ w/Makefile.in 3 | @@ -168,7 +168,7 @@ $(OBJ_DIR): 4 | mkdir -p $@ 5 | 6 | $(OBJ_DIR)/%.o: $(srcdir)/%.c $(HEADERS) | $(OBJ_DIR) 7 | - $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ -c 8 | + $(if $V,,@echo " * ${CC} $@"; )$(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ -c 9 | 10 | fuzz/%.o: $(srcdir)/../fuzz/%.c $(HEADERS) 11 | $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ -c 12 | --- i/libtomcrypt/Makefile.in 13 | +++ w/libtomcrypt/Makefile.in 14 | @@ -243,7 +243,7 @@ $(TOBJECTS): $(HEADERS) tests/tomcrypt_test.h 15 | #This is necessary for compatibility with BSD make (namely on OpenBSD) 16 | .SUFFIXES: .o .c 17 | .c.o: 18 | - $(CC) $(LTC_CFLAGS) -c $< -o $@ 19 | + $(if $V,,@echo " * ${CC} $@"; )$(CC) $(LTC_CFLAGS) -c $< -o $@ 20 | 21 | #Create libtomcrypt.a 22 | $(LIBMAIN_S): $(OBJECTS) 23 | --- i/libtommath/Makefile.in 24 | +++ w/libtommath/Makefile.in 25 | @@ -10,8 +10,6 @@ CFLAGS += -I$(srcdir) -I../libtomcrypt/src/headers/ -I$(srcdir)/../libtomcrypt/s 26 | CFLAGS += -Wno-deprecated 27 | CFLAGS += $(CPPFLAGS) 28 | 29 | -V = 1 30 | - 31 | ifeq ($V,1) 32 | silent= 33 | else 34 | -------------------------------------------------------------------------------- /thirdparty/ffi-cdecl/ffi-cdecl.patch: -------------------------------------------------------------------------------- 1 | --- a/ffi-cdecl.lua 2 | +++ b/ffi-cdecl.lua 3 | @@ -1,5 +1,5 @@ 4 | local script_dir = arg["script"]:gsub("[^/]+$","") 5 | -package.path = script_dir .. "gcc-lua-cdecl/?.lua;" .. package.path 6 | +package.path = script_dir .. "/?.lua;" .. package.path 7 | 8 | local gcc = require("gcc") 9 | local cdecl = require("gcc.cdecl") 10 | @@ -73,7 +73,7 @@ 11 | ::continue:: 12 | end 13 | 14 | - local f = assert(io.open(arg.output, "w")) 15 | + local f = arg.output == '-' and io.stdout or assert(io.open(arg.output, "w")) 16 | if arg.output:match(".*%.(.*)") == "py" then 17 | f:write([=[ 18 | """ 19 | -------------------------------------------------------------------------------- /thirdparty/freetype2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | fix_meson_bzip2_option.patch 3 | # Work around GCC 12 ARM NEON bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117811). 4 | ftcalc_gcc12_arm_neon_fix.patch 5 | ) 6 | 7 | list(APPEND CFG_CMD COMMAND 8 | ${MESON_SETUP} --default-library=$,static,shared> 9 | -Dmmap=enabled 10 | -Dzlib=disabled 11 | ${SOURCE_DIR} 12 | ) 13 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 14 | list(APPEND CMAKE_ARGS -DFT_ENABLE_ERROR_STRINGS=TRUE) 15 | endif() 16 | 17 | list(APPEND BUILD_CMD COMMAND ninja) 18 | 19 | list(APPEND INSTALL_CMD COMMAND ${MESON_INSTALL}) 20 | 21 | if(NOT MONOLIBTIC) 22 | set(LIB_SPEC freetype VERSION 6) 23 | if(APPLE) 24 | append_shared_lib_fix_commands(INSTALL_CMD ${LIB_SPEC} ID) 25 | endif() 26 | append_shared_lib_install_commands(INSTALL_CMD ${LIB_SPEC}) 27 | endif() 28 | 29 | external_project( 30 | DOWNLOAD URL 4425315beb50f913ae12d643e4e121e1 31 | https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-3.tar.gz 32 | PATCH_FILES ${PATCH_FILES} 33 | CONFIGURE_COMMAND ${CFG_CMD} 34 | BUILD_COMMAND ${BUILD_CMD} 35 | INSTALL_COMMAND ${INSTALL_CMD} 36 | ) 37 | -------------------------------------------------------------------------------- /thirdparty/freetype2/fix_meson_bzip2_option.patch: -------------------------------------------------------------------------------- 1 | --- a/meson.build 2 | +++ b/meson.build 3 | @@ -320,11 +320,16 @@ else 4 | endif 5 | 6 | # BZip2 support. 7 | -bzip2_dep = dependency('bzip2', required: false) 8 | +bzip2_dep = dependency( 9 | + 'bzip2', 10 | + required: get_option('bzip2').disabled() ? get_option('bzip2') : false, 11 | +) 12 | if not bzip2_dep.found() 13 | - bzip2_dep = cc.find_library('bz2', 14 | + bzip2_dep = cc.find_library( 15 | + 'bz2', 16 | has_headers: ['bzlib.h'], 17 | - required: get_option('bzip2')) 18 | + required: get_option('bzip2'), 19 | + ) 20 | endif 21 | 22 | if bzip2_dep.found() 23 | -------------------------------------------------------------------------------- /thirdparty/freetype2/ftcalc_gcc12_arm_neon_fix.patch: -------------------------------------------------------------------------------- 1 | --- i/src/base/ftcalc.c 2 | +++ w/src/base/ftcalc.c 3 | @@ -750,7 +750,8 @@ 4 | 5 | shift = FT_MSB( val ) - 12; 6 | 7 | - if ( shift > 0 ) 8 | + if ( shift < 0 ) 9 | + shift = 0; 10 | { 11 | xx >>= shift; 12 | xy >>= shift; 13 | -------------------------------------------------------------------------------- /thirdparty/fribidi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CFG_CMD COMMAND 2 | ${MESON_SETUP} --default-library=$,static,shared> 3 | -Dbin=false 4 | -Ddocs=false 5 | -Dtests=false 6 | ${SOURCE_DIR} 7 | ) 8 | 9 | list(APPEND BUILD_CMD COMMAND ninja) 10 | 11 | list(APPEND INSTALL_CMD COMMAND ${MESON_INSTALL}) 12 | 13 | if(NOT MONOLIBTIC) 14 | set(LIB_SPEC fribidi VERSION 0) 15 | if(APPLE) 16 | append_shared_lib_fix_commands(INSTALL_CMD ${LIB_SPEC} ID) 17 | endif() 18 | append_shared_lib_install_commands(INSTALL_CMD ${LIB_SPEC}) 19 | endif() 20 | 21 | external_project( 22 | DOWNLOAD URL 333ad150991097a627755b752b87f9ff 23 | https://github.com/fribidi/fribidi/releases/download/v1.0.16/fribidi-1.0.16.tar.xz 24 | CONFIGURE_COMMAND ${CFG_CMD} 25 | BUILD_COMMAND ${BUILD_CMD} 26 | INSTALL_COMMAND ${INSTALL_CMD} 27 | ) 28 | -------------------------------------------------------------------------------- /thirdparty/giflib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(ANDROID) 2 | # Use `limits.h` instead of `stdint.h`. 3 | list(APPEND PATCH_CMD COMMAND ${ISED} "s|stdint.h|limits.h|g" openbsd-reallocarray.c) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | -DBUILD_SHARED_LIBS=$> 9 | ) 10 | 11 | list(APPEND BUILD_CMD COMMAND ninja) 12 | 13 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 14 | 15 | if(NOT MONOLIBTIC) 16 | append_shared_lib_install_commands(INSTALL_CMD gif VERSION 7) 17 | endif() 18 | 19 | external_project( 20 | DOWNLOAD URL 913dd251492134e235ee3c9a91987a4d 21 | https://sourceforge.net/projects/giflib/files/giflib-5.2.2.tar.gz 22 | PATCH_OVERLAY overlay 23 | PATCH_COMMAND ${PATCH_CMD} 24 | CMAKE_ARGS ${CMAKE_ARGS} 25 | BUILD_COMMAND ${BUILD_CMD} 26 | INSTALL_COMMAND ${INSTALL_CMD} 27 | ) 28 | -------------------------------------------------------------------------------- /thirdparty/giflib/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(giflib LANGUAGES C) 3 | 4 | add_library(gif) 5 | set_target_properties(gif PROPERTIES SOVERSION 7) 6 | if(DEFINED ANDROID_STL) 7 | target_compile_definitions(gif PRIVATE -DS_IREAD=S_IRUSR -DS_IWRITE=S_IWUSR) 8 | endif() 9 | target_sources(gif PRIVATE 10 | dgif_lib.c egif_lib.c 11 | gifalloc.c gif_err.c gif_font.c gif_hash.c 12 | openbsd-reallocarray.c quantize.c 13 | ) 14 | 15 | install(TARGETS gif) 16 | install(FILES gif_lib.h TYPE INCLUDE) 17 | -------------------------------------------------------------------------------- /thirdparty/glib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | # We only care about `libglib-2.0.a`. 3 | libglib-only.patch 4 | # We don't need regex support, and removing it gets rid of the pcre2 dependency. 5 | no_regex_support.patch 6 | ) 7 | if(LEGACY OR POCKETBOOK) 8 | # Avoid pulling-in `__sched_cpucount@GLIBC_2.6`, `eventfd@GLIBC_2.7`, 9 | # `pipe2@GLIBC_2.9` or `mkostemp@GLIBC_2.7`. 10 | list(APPEND PATCH_FILES no_glibc_2.6_or_above_symbols.patch) 11 | endif() 12 | 13 | if(ANDROID OR APPLE) 14 | set(ICONV gnu) 15 | else() 16 | set(ICONV libc) 17 | endif() 18 | 19 | list(APPEND CFG_CMD COMMAND 20 | ${MESON_SETUP} --default-library=static 21 | -Dglib_assert=false 22 | -Dglib_debug=disabled 23 | -Dtests=false 24 | -Dxattr=false 25 | ${SOURCE_DIR} 26 | ) 27 | 28 | list(APPEND BUILD_CMD COMMAND ninja glib/libglib-2.0.a) 29 | 30 | list(APPEND INSTALL_CMD COMMAND ${MESON_INSTALL} --tags devel) 31 | # Don't install the pkg-config entry: 32 | # - sdcv is the only user, and needs to be manually coaxed into using our GLib anyway. 33 | # - when building SDL2 for the AppImage, IBus headers include some GObject headers, 34 | # which our patched version does not include. 35 | list(APPEND INSTALL_CMD COMMAND rm -f ${STAGING_DIR}/lib/pkgconfig/glib-2.0.pc) 36 | 37 | external_project( 38 | DOWNLOAD URL d101f1acab6805d4d6d3104e9634b8e3 39 | https://download.gnome.org/sources/glib/2.82/glib-2.82.1.tar.xz 40 | PATCH_FILES ${PATCH_FILES} 41 | CONFIGURE_COMMAND ${CFG_CMD} 42 | BUILD_COMMAND ${BUILD_CMD} 43 | INSTALL_COMMAND ${INSTALL_CMD} 44 | ) 45 | -------------------------------------------------------------------------------- /thirdparty/glib/no_glibc_2.6_or_above_symbols.patch: -------------------------------------------------------------------------------- 1 | --- i/meson.build 2 | +++ w/meson.build 3 | @@ -709,7 +709,6 @@ functions = [ 4 | 'memalign', 5 | 'mmap', 6 | 'newlocale', 7 | - 'pipe2', 8 | 'poll', 9 | 'prlimit', 10 | 'readlink', 11 | @@ -945,14 +944,6 @@ else 12 | endif 13 | message('Checking whether to use statfs or statvfs .. ' + stat_func_to_use) 14 | 15 | -if host_system == 'linux' 16 | - if cc.has_function('mkostemp', 17 | - prefix: '''#define _GNU_SOURCE 18 | - #include ''') 19 | - glib_conf.set('HAVE_MKOSTEMP', 1) 20 | - endif 21 | -endif 22 | - 23 | osx_ldflags = [] 24 | glib_have_os_x_9_or_later = false 25 | glib_have_carbon = false 26 | @@ -1014,16 +1005,6 @@ if cc.compiles('''#include 27 | glib_conf.set('HAVE_FUTEX_TIME64', 1) 28 | endif 29 | 30 | -# Check for eventfd(2) 31 | -if cc.links('''#include 32 | - #include 33 | - int main (int argc, char ** argv) { 34 | - eventfd (0, EFD_CLOEXEC); 35 | - return 0; 36 | - }''', name : 'eventfd(2) system call') 37 | - glib_conf.set('HAVE_EVENTFD', 1) 38 | -endif 39 | - 40 | # Check for ppoll(2) 41 | if cc.links('''#define _GNU_SOURCE 42 | #include 43 | @@ -2113,9 +2094,6 @@ else 44 | if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix) 45 | glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1) 46 | endif 47 | - if cc.has_header_symbol('pthread.h', 'pthread_getaffinity_np', prefix : pthread_prefix) 48 | - glib_conf.set('HAVE_PTHREAD_GETAFFINITY_NP', 1) 49 | - endif 50 | 51 | # Assume that pthread_setname_np is available in some form; same as configure 52 | if cc.links(pthread_prefix + ''' 53 | -------------------------------------------------------------------------------- /thirdparty/harfbuzz/android.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/hb.hh b/src/hb.hh 2 | index fe466fe1..d728bb99 100644 3 | --- a/src/hb.hh 4 | +++ b/src/hb.hh 5 | @@ -500,6 +500,10 @@ static int HB_UNUSED _hb_errno = 0; 6 | #define HB_NO_SETLOCALE 1 7 | #endif 8 | 9 | +#if !defined(HB_NO_SETLOCALE) && defined(__ANDROID__) && __ANDROID_API__ < 21 10 | +#define HB_NO_SETLOCALE 1 11 | +#endif 12 | + 13 | #ifndef HB_NO_SETLOCALE 14 | 15 | #include 16 | --- a/src/hb-buffer-verify.cc 17 | +++ b/src/hb-buffer-verify.cc 18 | @@ -46,11 +46,13 @@ 19 | { 20 | va_list ap; 21 | va_start (ap, fmt); 22 | +#ifndef HB_NO_BUFFER_MESSAGE 23 | if (buffer->messaging ()) 24 | { 25 | buffer->message_impl (font, fmt, ap); 26 | } 27 | else 28 | +#endif 29 | { 30 | fprintf (stderr, "harfbuzz "); 31 | vfprintf (stderr, fmt, ap); 32 | -------------------------------------------------------------------------------- /thirdparty/harfbuzz/no-subset.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/meson.build b/src/meson.build 2 | index b9daabf0..b5a04745 100644 3 | --- a/src/meson.build 4 | +++ b/src/meson.build 5 | @@ -620,7 +620,7 @@ defs_list += [harfbuzz_subset_def] 6 | 7 | libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, 8 | include_directories: incconfig, 9 | - dependencies: [m_dep], 10 | + dependencies: [m_dep, disabler()], 11 | link_with: [libharfbuzz], 12 | cpp_args: cpp_args + extra_hb_cpp_args, 13 | soversion: hb_so_version, 14 | @@ -631,7 +631,7 @@ libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, 15 | ) 16 | 17 | custom_target('harfbuzz-subset.cc', 18 | - build_by_default: true, 19 | + build_by_default: false, 20 | output: 'harfbuzz-subset.cc', 21 | input: hb_base_sources + hb_subset_sources, 22 | command: [find_program('gen-harfbuzzcc.py'), 23 | -------------------------------------------------------------------------------- /thirdparty/kobo-usbms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | list(APPEND BUILD_CMD COMMAND make CROSS_TC=${CHOST}) 5 | append_autotools_vars(BUILD_CMD) 6 | # Make sure the binaries in the `KoboUSBMS.tar.gz` archive are stripped. 7 | list(APPEND BUILD_CMD "STRIP=${STRIP} --strip-unneeded") 8 | list(APPEND BUILD_CMD kobo) 9 | 10 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 11 | set(BUILD_DIR Debug) 12 | else() 13 | set(BUILD_DIR Release) 14 | endif() 15 | 16 | append_install_commands(INSTALL_CMD ${CMAKE_BUILD_TYPE}/KoboUSBMS.tar.gz DESTINATION data) 17 | 18 | external_project( 19 | DOWNLOAD GIT a35a8f639699deaae2e2ee446b5f6c2d2096c1bb 20 | https://github.com/koreader/KoboUSBMS.git 21 | BUILD_COMMAND ${BUILD_CMD} 22 | INSTALL_COMMAND ${INSTALL_CMD} 23 | ) 24 | -------------------------------------------------------------------------------- /thirdparty/leptonica/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -8,8 +8,7 @@ 4 | # 5 | # ############################################################################## 6 | 7 | -cmake_minimum_required(VERSION 3.5) 8 | -cmake_policy(SET CMP0054 NEW) 9 | +cmake_minimum_required(VERSION 3.17.5) 10 | 11 | # In-source builds are disabled. 12 | if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") 13 | -------------------------------------------------------------------------------- /thirdparty/leptonica/fmemopen-arm-compat-symbol.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/utils2.c b/src/utils2.c 2 | index bac9621..4f7c696 100644 3 | --- a/src/utils2.c 4 | +++ b/src/utils2.c 5 | @@ -1632,6 +1632,7 @@ FILE *fp; 6 | return (FILE *)ERROR_PTR("data not defined", procName, NULL); 7 | 8 | #if HAVE_FMEMOPEN 9 | + __asm__(".symver fmemopen,fmemopen@GLIBC_2.4"); 10 | if ((fp = fmemopen((void *)data, size, "rb")) == NULL) 11 | return (FILE *)ERROR_PTR("stream not opened", procName, NULL); 12 | #else /* write to tmp file */ 13 | -------------------------------------------------------------------------------- /thirdparty/libarchive/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(ANDROID) 2 | list(APPEND PATCH_FILES android.patch) 3 | list(APPEND PATCH_CMD COMMAND mv contrib/android/include/android_lf.h libarchive/) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | -DBUILD_SHARED_LIBS=$> 9 | # Project options. 10 | -DENABLE_ACL=FALSE 11 | -DENABLE_BZip2=FALSE 12 | -DENABLE_CAT=FALSE 13 | -DENABLE_CNG=FALSE 14 | -DENABLE_CPIO=FALSE 15 | -DENABLE_EXPAT=FALSE 16 | -DENABLE_ICONV=FALSE 17 | -DENABLE_LIBB2=FALSE 18 | -DENABLE_LIBXML2=FALSE 19 | -DENABLE_LZ4=FALSE 20 | -DENABLE_LZMA=$ 21 | -DENABLE_OPENSSL=FALSE 22 | -DENABLE_PCRE2POSIX=FALSE 23 | -DENABLE_PCREPOSIX=FALSE 24 | -DENABLE_TAR=FALSE 25 | -DENABLE_TEST=FALSE 26 | -DENABLE_UNZIP=FALSE 27 | -DENABLE_WERROR=FALSE 28 | -DENABLE_XATTR=FALSE 29 | # Prevent md library fallback because OpenSSL is not used. 30 | -DLIBMD_FOUND=FALSE 31 | ) 32 | # Avoid pulling > GLIBC_2.4 symbols on crappy platforms. 33 | if(LEGACY OR POCKETBOOK) 34 | list(APPEND CMAKE_ARGS 35 | -DHAVE_FUTIMENS=FALSE 36 | -DHAVE_UTIMENSAT=FALSE 37 | ) 38 | endif() 39 | 40 | list(APPEND BUILD_CMD COMMAND ninja) 41 | 42 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 43 | 44 | if(NOT MONOLIBTIC) 45 | append_shared_lib_install_commands(INSTALL_CMD archive VERSION 13) 46 | endif() 47 | 48 | external_project( 49 | DOWNLOAD URL e378aeb163d8c81745665dddd81116ef 50 | https://github.com/libarchive/libarchive/releases/download/v3.7.9/libarchive-3.7.9.tar.xz 51 | CMAKE_ARGS ${CMAKE_ARGS} 52 | PATCH_FILES ${PATCH_FILES} 53 | PATCH_COMMAND ${PATCH_CMD} 54 | BUILD_COMMAND ${BUILD_CMD} 55 | INSTALL_COMMAND ${INSTALL_CMD} 56 | ) 57 | -------------------------------------------------------------------------------- /thirdparty/libarchive/android.patch: -------------------------------------------------------------------------------- 1 | --- i/libarchive/archive_read_disk_posix.c 2 | +++ w/libarchive/archive_read_disk_posix.c 3 | @@ -1825,7 +1825,7 @@ 4 | /* pathconf(_PC_REX_*) operations are not supported. */ 5 | #if defined(HAVE_STATVFS) 6 | set_statvfs_transfer_size(t->current_filesystem, &svfs); 7 | -#else 8 | +#elif defined(HAVE_STRUCT_STATFS) 9 | set_statfs_transfer_size(t->current_filesystem, &sfs); 10 | #endif 11 | } 12 | -------------------------------------------------------------------------------- /thirdparty/libiconv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CFG_CMD COMMAND env) 2 | append_autotools_vars(CFG_CMD) 3 | list(APPEND CFG_CMD 4 | ${SOURCE_DIR}/configure --host=${CHOST} --prefix=/ 5 | --enable-shared=false --enable-static=true 6 | --disable-nls 7 | --with-threads=none 8 | ) 9 | 10 | list(APPEND BUILD_CMD COMMAND make) 11 | 12 | list(APPEND INSTALL_CMD COMMAND make DESTDIR=${STAGING_DIR} install) 13 | # Get rid of libtool crap… 14 | list(APPEND INSTALL_CMD COMMAND rm -f ${STAGING_DIR}/lib/libiconv.la ${STAGING_DIR}/lib/libcharset.la) 15 | 16 | external_project( 17 | DOWNLOAD URL ace8b5f2db42f7b3b3057585e80d9808 18 | http://ftpmirror.gnu.org/libiconv/libiconv-1.15.tar.gz 19 | https://ftp.wayne.edu/gnu/libiconv/libiconv-1.15.tar.gz 20 | http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz 21 | CONFIGURE_COMMAND ${CFG_CMD} 22 | BUILD_COMMAND ${BUILD_CMD} 23 | INSTALL_COMMAND ${INSTALL_CMD} 24 | ) 25 | -------------------------------------------------------------------------------- /thirdparty/libjpeg-turbo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES no_cmake_rpath_shenanigans.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | # Project options. 6 | -DENABLE_SHARED=$> 7 | -DENABLE_STATIC=$ 8 | -DWITH_JAVA=OFF 9 | -DWITH_JPEG8=ON 10 | # Make sure we disable ASM if we don't support SIMD. 11 | -DREQUIRE_SIMD=$ 12 | -DWITH_SIMD=$ 13 | # Reproducible builds: use release date. 14 | -DBUILD=20240508 15 | ) 16 | 17 | list(APPEND BUILD_CMD COMMAND ninja) 18 | 19 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 20 | 21 | if(NOT MONOLIBTIC) 22 | append_shared_lib_install_commands(INSTALL_CMD jpeg VERSION 8) 23 | append_shared_lib_install_commands(INSTALL_CMD turbojpeg VERSION 0.3.0) 24 | endif() 25 | 26 | external_project( 27 | DOWNLOAD GIT 3.0.4 28 | https://github.com/libjpeg-turbo/libjpeg-turbo.git 29 | PATCH_FILES ${PATCH_FILES} 30 | CMAKE_ARGS ${CMAKE_ARGS} 31 | BUILD_COMMAND ${BUILD_CMD} 32 | INSTALL_COMMAND ${INSTALL_CMD} 33 | ) 34 | -------------------------------------------------------------------------------- /thirdparty/libjpeg-turbo/no_cmake_rpath_shenanigans.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -269,10 +269,6 @@ endif() 4 | report_option(ENABLE_SHARED "Shared libraries") 5 | report_option(ENABLE_STATIC "Static libraries") 6 | 7 | -if(ENABLE_SHARED) 8 | - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) 9 | -endif() 10 | - 11 | if(WITH_JPEG8 OR WITH_JPEG7) 12 | set(WITH_ARITH_ENC 1) 13 | set(WITH_ARITH_DEC 1) 14 | -------------------------------------------------------------------------------- /thirdparty/libk2pdfopt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT MONOLIBTIC) 2 | set(CMAKE_PATCH_FILE ${CMAKE_BINARY_DIR}/k2pdfopt_exports.cmake) 3 | target_exports(k2pdfopt FILELIST_VAR CDECLS_FILES WRITE_TO_FILE ${CMAKE_PATCH_FILE} CDECLS koptcontext_cdecl) 4 | list(APPEND PATCH_CMD COMMAND ${ISED} "\$p" -e "\$s|.*|include(${CMAKE_PATCH_FILE})|" lib/CMakeLists.txt) 5 | endif() 6 | 7 | list(APPEND CMAKE_ARGS 8 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 9 | -DBUILD_SHARED_LIBS=$> 10 | # Project options. 11 | -DANDROID=${ANDROID} 12 | ) 13 | 14 | list(APPEND BUILD_CMD COMMAND ninja) 15 | 16 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 17 | 18 | if(NOT MONOLIBTIC) 19 | append_shared_lib_install_commands(INSTALL_CMD k2pdfopt VERSION 2) 20 | endif() 21 | 22 | external_project( 23 | DOWNLOAD GIT 59ced371378312d8f332d9a35f5b4a3c33b18954 24 | https://github.com/koreader/libk2pdfopt.git 25 | PATCH_COMMAND ${PATCH_CMD} 26 | CMAKE_ARGS ${CMAKE_ARGS} 27 | SOURCE_SUBDIR lib 28 | BUILD_COMMAND ${BUILD_CMD} 29 | BUILD_DEPENDS ${CDECLS_FILES} 30 | INSTALL_COMMAND ${INSTALL_CMD} 31 | ) 32 | -------------------------------------------------------------------------------- /thirdparty/libpng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES math_library.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | # Project options. 6 | -DPNG_DEBUG_POSTFIX= 7 | -DPNG_FRAMEWORK=FALSE 8 | -DPNG_HARDWARE_OPTIMIZATIONS=$ 9 | -DPNG_SHARED=$> 10 | -DPNG_STATIC=$ 11 | -DPNG_TESTS=FALSE 12 | -DPNG_TOOLS=FALSE 13 | ) 14 | # Rely on `-mfpu=neon` ifdefs for enabling NEON on 32bits ARM. 15 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") 16 | list(APPEND CMAKE_ARGS -DPNG_ARM_NEON=on) 17 | endif() 18 | 19 | list(APPEND BUILD_CMD COMMAND ninja) 20 | 21 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 22 | 23 | if(NOT MONOLIBTIC) 24 | append_shared_lib_install_commands(INSTALL_CMD png16 VERSION 16) 25 | endif() 26 | 27 | external_project( 28 | DOWNLOAD URL be6cc9e411c26115db3b9eab1159a1d9 29 | https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.48.tar.gz 30 | PATCH_FILES ${PATCH_FILES} 31 | CMAKE_ARGS ${CMAKE_ARGS} 32 | BUILD_COMMAND ${BUILD_CMD} 33 | INSTALL_COMMAND ${INSTALL_CMD} 34 | ) 35 | -------------------------------------------------------------------------------- /thirdparty/libpng/math_library.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -116,17 +116,12 @@ 4 | 5 | find_package(ZLIB REQUIRED) 6 | 7 | -if(UNIX 8 | - AND NOT (APPLE OR BEOS OR HAIKU) 9 | - AND NOT EMSCRIPTEN) 10 | - find_library(M_LIBRARY m) 11 | - if(M_LIBRARY) 12 | +include(CheckLibraryExists) 13 | +check_library_exists(m floor "" M_LIBRARY) 14 | +if(M_LIBRARY) 15 | set(M_LIBRARY m) 16 | - else() 17 | - set(M_LIBRARY "") 18 | - endif() 19 | else() 20 | - # libm is not available or not needed. 21 | + set(M_LIBRARY "") 22 | endif() 23 | 24 | if(PNG_HARDWARE_OPTIMIZATIONS) 25 | -------------------------------------------------------------------------------- /thirdparty/libressl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | if(ANDROID) 3 | list(APPEND PATCH_FILES android.patch) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | -DBUILD_SHARED_LIBS=$> 9 | # Project options. 10 | -DLIBRESSL_APPS=OFF 11 | -DLIBRESSL_TESTS=OFF 12 | -DENABLE_ASM=${WANT_SIMD} 13 | ) 14 | 15 | list(APPEND BUILD_CMD COMMAND ninja) 16 | 17 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 18 | 19 | if(NOT MONOLIBTIC) 20 | append_shared_lib_install_commands(INSTALL_CMD crypto VERSION 56) 21 | append_shared_lib_install_commands(INSTALL_CMD ssl VERSION 59) 22 | endif() 23 | 24 | external_project( 25 | DOWNLOAD URL 18079dcf72a398d8c188e67e30c1dc13 26 | https://github.com/libressl/portable/releases/download/v4.1.0/libressl-4.1.0.tar.gz 27 | https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-4.1.0.tar.gz 28 | PATCH_FILES ${PATCH_FILES} 29 | CMAKE_ARGS ${CMAKE_ARGS} 30 | BUILD_COMMAND ${BUILD_CMD} 31 | INSTALL_COMMAND ${INSTALL_CMD} 32 | ) 33 | -------------------------------------------------------------------------------- /thirdparty/libressl/android.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -82,7 +82,6 @@ 4 | add_definitions(-D_BSD_SOURCE) 5 | add_definitions(-D_POSIX_SOURCE) 6 | add_definitions(-D_GNU_SOURCE) 7 | - set(PLATFORM_LIBS ${PLATFORM_LIBS} pthread) 8 | endif() 9 | 10 | if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 11 | -------------------------------------------------------------------------------- /thirdparty/libressl/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -1,4 +1,4 @@ 4 | -cmake_minimum_required (VERSION 3.16.4) 5 | +cmake_minimum_required (VERSION 3.17.5) 6 | if(MSVC) 7 | cmake_policy(SET CMP0091 NEW) 8 | endif() 9 | @@ -516,8 +516,8 @@ 10 | # Create pkgconfig files. 11 | set(prefix ${CMAKE_INSTALL_PREFIX}) 12 | set(exec_prefix \${prefix}) 13 | - set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR}) 14 | - set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) 15 | + set(libdir \${exec_prefix}/lib) 16 | + set(includedir \${prefix}/include) 17 | if(PLATFORM_LIBS) 18 | string(REGEX REPLACE ";" " -l" PLATFORM_LDADD ";${PLATFORM_LIBS}") 19 | endif() 20 | -------------------------------------------------------------------------------- /thirdparty/libunibreak/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CFG_CMD COMMAND env) 2 | append_autotools_vars(CFG_CMD) 3 | list(APPEND CFG_CMD 4 | ${SOURCE_DIR}/configure --host=${CHOST} --prefix=${STAGING_DIR} 5 | --disable-$,shared,static> 6 | --enable-$,static,shared> 7 | --enable-silent-rules 8 | ) 9 | 10 | list(APPEND BUILD_CMD COMMAND make) 11 | 12 | list(APPEND INSTALL_CMD COMMAND make install) 13 | 14 | if(NOT MONOLIBTIC) 15 | set(LIB_SPEC unibreak VERSION 6) 16 | if(APPLE) 17 | append_shared_lib_fix_commands(INSTALL_CMD ${LIB_SPEC} ID) 18 | endif() 19 | append_shared_lib_install_commands(INSTALL_CMD ${LIB_SPEC}) 20 | endif() 21 | 22 | external_project( 23 | DOWNLOAD URL 8df410d010e03de1a339a400a920335e 24 | https://github.com/adah1972/libunibreak/releases/download/libunibreak_6_1/libunibreak-6.1.tar.gz 25 | CONFIGURE_COMMAND ${CFG_CMD} 26 | BUILD_COMMAND ${BUILD_CMD} 27 | INSTALL_COMMAND ${INSTALL_CMD} 28 | ) 29 | -------------------------------------------------------------------------------- /thirdparty/libwebp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | # Project options. 7 | # Note: we could build libwebpdecoder.so only, which would be smaller and fine 8 | # decoding single frame webp images. But it fails on animated webp images, not 9 | # even rendering the first frame. We need the regular libraries (`libwebp.so` 10 | # and `libwebpdemux.so`) to handle them (but we can left out the encoder, 11 | # `libwebpmux.so`). 12 | -DWEBP_BUILD_ANIM_UTILS=FALSE 13 | -DWEBP_BUILD_CWEBP=FALSE 14 | -DWEBP_BUILD_DWEBP=FALSE 15 | -DWEBP_BUILD_EXTRAS=FALSE 16 | -DWEBP_BUILD_GIF2WEBP=FALSE 17 | -DWEBP_BUILD_IMG2WEBP=FALSE 18 | -DWEBP_BUILD_LIBWEBPMUX=FALSE 19 | -DWEBP_BUILD_VWEBP=FALSE 20 | -DWEBP_BUILD_WEBPINFO=FALSE 21 | -DWEBP_BUILD_WEBPMUX=FALSE 22 | -DWEBP_ENABLE_SIMD=$ 23 | ) 24 | 25 | list(APPEND BUILD_CMD COMMAND ninja) 26 | 27 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 28 | 29 | if(NOT MONOLIBTIC) 30 | append_shared_lib_install_commands(INSTALL_CMD sharpyuv VERSION 0) 31 | append_shared_lib_install_commands(INSTALL_CMD webpdemux VERSION 2) 32 | append_shared_lib_install_commands(INSTALL_CMD webp VERSION 7) 33 | endif() 34 | 35 | external_project( 36 | DOWNLOAD URL 8f659e426eaa2aeec4b36bc9ea43b3f3 37 | https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.5.0.tar.gz 38 | PATCH_FILES ${PATCH_FILES} 39 | CMAKE_ARGS ${CMAKE_ARGS} 40 | BUILD_COMMAND ${BUILD_CMD} 41 | INSTALL_COMMAND ${INSTALL_CMD} 42 | ) 43 | -------------------------------------------------------------------------------- /thirdparty/libwebp/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/cmake/deps.cmake 2 | +++ w/cmake/deps.cmake 3 | @@ -52,20 +52,8 @@ endif() 4 | set(LT_OBJDIR ".libs/") 5 | 6 | # Only useful for vwebp, so useless for now. 7 | -find_package(OpenGL) 8 | -set(WEBP_HAVE_GL ${OPENGL_FOUND}) 9 | - 10 | -# Check if we need to link to the C math library. We do not look for it as it is 11 | -# not found when cross-compiling, while it is here. 12 | -check_c_source_compiles( 13 | - " 14 | - #include 15 | - int main(int argc, char** argv) { 16 | - return (int)pow(argc, 2.5); 17 | - } 18 | - " 19 | - HAVE_MATH_LIBRARY) 20 | -if(NOT HAVE_MATH_LIBRARY) 21 | +check_library_exists(m floor "" HAVE_MATH_LIBRARY) 22 | +if(HAVE_MATH_LIBRARY) 23 | message(STATUS "Adding -lm flag.") 24 | list(APPEND SHARPYUV_DEP_LIBRARIES m) 25 | list(APPEND WEBP_DEP_LIBRARIES m) 26 | @@ -128,9 +116,6 @@ endif() 27 | 28 | # Check for specific headers. 29 | include(CheckIncludeFiles) 30 | -check_include_files(GLUT/glut.h HAVE_GLUT_GLUT_H) 31 | -check_include_files(GL/glut.h HAVE_GL_GLUT_H) 32 | -check_include_files(OpenGL/glut.h HAVE_OPENGL_GLUT_H) 33 | check_include_files(shlwapi.h HAVE_SHLWAPI_H) 34 | check_include_files(unistd.h HAVE_UNISTD_H) 35 | check_include_files(wincodec.h HAVE_WINCODEC_H) 36 | -------------------------------------------------------------------------------- /thirdparty/libzmq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | if(LEGACY OR POCKETBOOK) 3 | list(APPEND PATCH_FILES disable_eventfd.patch) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | # Project options. 9 | -DBUILD_SHARED=$> 10 | -DBUILD_STATIC=$ 11 | -DENABLE_DRAFTS=FALSE 12 | -DWITH_DOC=FALSE 13 | -DWITH_LIBBSD=FALSE 14 | -DZMQ_BUILD_FRAMEWORK=FALSE 15 | -DZMQ_BUILD_TESTS=FALSE 16 | # Disable some dependencies (which will automatically 17 | # disable the corresponding project optional features). 18 | -DCMAKE_DISABLE_FIND_PACKAGE_AsciiDoc=TRUE 19 | ) 20 | if(LEGACY OR POCKETBOOK) 21 | list(APPEND CMAKE_ARGS -DPOLLER=epoll) 22 | endif() 23 | 24 | list(APPEND BUILD_CMD COMMAND ninja) 25 | 26 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 27 | 28 | if(NOT MONOLIBTIC) 29 | append_shared_lib_install_commands(INSTALL_CMD zmq VERSION 5) 30 | endif() 31 | 32 | external_project( 33 | DOWNLOAD URL ae933b1e98411fd7cb8309f9502d2737 34 | https://github.com/zeromq/libzmq/releases/download/v4.3.5/zeromq-4.3.5.tar.gz 35 | PATCH_FILES ${PATCH_FILES} 36 | CMAKE_ARGS ${CMAKE_ARGS} 37 | BUILD_COMMAND ${BUILD_CMD} 38 | INSTALL_COMMAND ${INSTALL_CMD} 39 | ) 40 | -------------------------------------------------------------------------------- /thirdparty/libzmq/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -2,9 +2,9 @@ 4 | project(ZeroMQ) 5 | 6 | if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) 7 | - cmake_minimum_required(VERSION 3.0.2) 8 | + cmake_minimum_required(VERSION 3.17.5) 9 | else() 10 | - cmake_minimum_required(VERSION 2.8.12) 11 | + cmake_minimum_required(VERSION 3.17.5) 12 | endif() 13 | 14 | include(CheckIncludeFiles) 15 | @@ -1469,6 +1469,10 @@ 16 | if(BUILD_SHARED) 17 | target_link_libraries(libzmq ${CMAKE_THREAD_LIBS_INIT}) 18 | 19 | + if(HAVE_CLOCK_GETTIME) 20 | + target_link_libraries(libzmq -lrt) 21 | + endif() 22 | + 23 | if(QNX) 24 | target_link_libraries(libzmq -lsocket) 25 | endif() 26 | -------------------------------------------------------------------------------- /thirdparty/libzmq/disable_eventfd.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -541,10 +541,6 @@ 4 | if(NOT MSVC) 5 | check_include_files(ifaddrs.h ZMQ_HAVE_IFADDRS) 6 | check_include_files(sys/uio.h ZMQ_HAVE_UIO) 7 | - check_include_files(sys/eventfd.h ZMQ_HAVE_EVENTFD) 8 | - if(ZMQ_HAVE_EVENTFD AND NOT CMAKE_CROSSCOMPILING) 9 | - zmq_check_efd_cloexec() 10 | - endif() 11 | endif() 12 | 13 | if(ZMQ_HAVE_WINDOWS) 14 | -------------------------------------------------------------------------------- /thirdparty/lj-wpaclient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD 5 | consts_h.lua poll_h.lua select_h.lua 6 | socket_h.lua socket.lua time_h.lua 7 | wpaclient.lua wpa_ctrl.lua 8 | DESTINATION ${OUTPUT_DIR}/common/lj-wpaclient 9 | ) 10 | 11 | external_project( 12 | DOWNLOAD GIT 0d5c8ee336b699dbb35850a7336d24e89e1aac24 13 | https://github.com/koreader/lj-wpaclient.git 14 | INSTALL_COMMAND ${INSTALL_CMD} 15 | ) 16 | -------------------------------------------------------------------------------- /thirdparty/lodepng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD lodepng) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD GIT 0b1d9ccfc2093e5d6620cd9a11d03ee6ff6705f5 16 | https://github.com/lvandeve/lodepng.git 17 | PATCH_OVERLAY overlay 18 | CMAKE_ARGS ${CMAKE_ARGS} 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /thirdparty/lodepng/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(lodepng LANGUAGES C) 3 | 4 | file(WRITE lodepng.c "#include \"lodepng.cpp\"\n") 5 | add_library(lodepng) 6 | target_sources(lodepng PRIVATE lodepng.c) 7 | target_compile_definitions(lodepng PRIVATE LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS) 8 | 9 | install(TARGETS lodepng) 10 | install(FILES lodepng.h TYPE INCLUDE) 11 | -------------------------------------------------------------------------------- /thirdparty/lpeg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES luajit.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | if(MONOLIBTIC) 11 | append_install_commands(INSTALL_CMD lpeg.a DESTINATION ${STAGING_DIR}/lib) 12 | else() 13 | append_binary_install_command(INSTALL_CMD lpeg.so DESTINATION common) 14 | endif() 15 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/re.lua DESTINATION common) 16 | 17 | external_project( 18 | DOWNLOAD URL 842a538b403b5639510c9b6fffd2c75b 19 | http://distcache.FreeBSD.org/ports-distfiles/lpeg-1.1.0.tar.gz 20 | PATCH_OVERLAY overlay 21 | PATCH_FILES ${PATCH_FILES} 22 | CMAKE_ARGS ${CMAKE_ARGS} 23 | BUILD_COMMAND ${BUILD_CMD} 24 | INSTALL_COMMAND ${INSTALL_CMD} 25 | ) 26 | -------------------------------------------------------------------------------- /thirdparty/lpeg/luajit.patch: -------------------------------------------------------------------------------- 1 | diff -Nuarp lpeg-1.1.0-orig/lptree.c lpeg-1.1.0/lptree.c 2 | --- lpeg-1.1.0-orig/lptree.c 2023-06-26 18:30:55.000000000 +0200 3 | +++ lpeg-1.1.0/lptree.c 2024-06-18 21:45:18.373041624 +0200 4 | @@ -1382,8 +1382,8 @@ static struct luaL_Reg metareg[] = { 5 | }; 6 | 7 | 8 | -int luaopen_lpeg (lua_State *L); 9 | -int luaopen_lpeg (lua_State *L) { 10 | +LUALIB_API int luaopen_lpeg (lua_State *L); 11 | +LUALIB_API int luaopen_lpeg (lua_State *L) { 12 | luaL_newmetatable(L, PATTERN_T); 13 | lua_pushnumber(L, MAXBACK); /* initialize maximum backtracking */ 14 | lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX); 15 | diff -Nuarp lpeg-1.1.0-orig/lptypes.h lpeg-1.1.0/lptypes.h 16 | --- lpeg-1.1.0-orig/lptypes.h 2023-06-26 18:30:55.000000000 +0200 17 | +++ lpeg-1.1.0/lptypes.h 2024-06-18 21:51:11.192651835 +0200 18 | @@ -34,8 +34,14 @@ 19 | 20 | #define lua_rawlen lua_objlen 21 | 22 | +#ifdef luaL_setfuncs 23 | +#undef luaL_setfuncs 24 | #define luaL_setfuncs(L,f,n) luaL_register(L,NULL,f) 25 | +#endif 26 | +#ifdef luaL_newlib 27 | +#undef luaL_newlib 28 | #define luaL_newlib(L,f) luaL_register(L,"lpeg",f) 29 | +#endif 30 | 31 | typedef size_t lua_Unsigned; 32 | 33 | -------------------------------------------------------------------------------- /thirdparty/lpeg/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(lpeg LANGUAGES C) 3 | 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(LuaJIT luajit REQUIRED IMPORTED_TARGET) 6 | 7 | if(BUILD_SHARED_LIBS) 8 | add_library(lpeg MODULE) 9 | else() 10 | add_library(lpeg STATIC) 11 | endif() 12 | set_target_properties(lpeg PROPERTIES 13 | C_STANDARD 99 14 | PREFIX "" 15 | ) 16 | target_link_libraries(lpeg PRIVATE PkgConfig::LuaJIT) 17 | target_sources(lpeg PRIVATE 18 | lpcap.c 19 | lpcode.c 20 | lpcset.c 21 | lpprint.c 22 | lptree.c 23 | lpvm.c 24 | ) 25 | -------------------------------------------------------------------------------- /thirdparty/lua-Spore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | list(APPEND PATCH_FILES content-type-detection.patch) 5 | 6 | append_install_commands(INSTALL_CMD src/Spore.lua DESTINATION common) 7 | append_tree_install_commands(INSTALL_CMD src/Spore common/Spore) 8 | 9 | external_project( 10 | DOWNLOAD GIT 0.4.0 11 | https://framagit.org/fperrad/lua-Spore 12 | PATCH_FILES ${PATCH_FILES} 13 | INSTALL_COMMAND ${INSTALL_CMD} 14 | ) 15 | -------------------------------------------------------------------------------- /thirdparty/lua-htmlparser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD src/htmlparser.lua DESTINATION common) 5 | append_tree_install_commands(INSTALL_CMD src/htmlparser common/htmlparser) 6 | 7 | external_project( 8 | DOWNLOAD GIT 5ce9a775a345cf458c0388d7288e246bb1b82bff 9 | https://github.com/msva/lua-htmlparser 10 | INSTALL_COMMAND ${INSTALL_CMD} 11 | ) 12 | -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LJSQLITE3_MOD ${OUTPUT_DIR}/common/lua-ljsqlite3/init.lua) 2 | 3 | add_custom_command( 4 | OUTPUT ${LJSQLITE3_MOD} 5 | MAIN_DEPENDENCY init.lua 6 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/init.lua ${LJSQLITE3_MOD} 7 | ) 8 | 9 | add_custom_target(lua-ljsqlite3 ALL DEPENDS ${LJSQLITE3_MOD}) 10 | -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/LICENSE: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | 3 | LJSQLite3: SQlite3 Interface. 4 | 5 | Copyright (C) 2014-2016 Stefano Peluchetti. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | [ MIT license: http://opensource.org/licenses/MIT ] 26 | 27 | =============================================================================== -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/__meta.lua: -------------------------------------------------------------------------------- 1 | return { 2 | name = "ljsqlite3", 3 | version = "1.0.2", 4 | require = { 5 | luajit = "2.0", 6 | clib_sqlite3 = "3", 7 | xsys = "1.0", 8 | }, 9 | license = "MIT ", 10 | homepage = "http://scilua.org/ljsqlite3.html", 11 | description = "SQlite3 interface", 12 | } 13 | -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/notes.txt: -------------------------------------------------------------------------------- 1 | lua-ljsqlite3 is copied from upstream commit: d742002 2 | A few patches from forks have been merged: 3 | * https://github.com/Codezerker/lua-ljsqlite3/commit/4efb927a6514039ec657ce977154b6ea3596f2ce 4 | * https://github.com/mnemnion/lua-ljsqlite3/commit/c81b2ed8efec34af24876a5b1489650a3f891e53 5 | 6 | -------------------------------------------------------------------------------- /thirdparty/lua-rapidjson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | # Project options. 7 | -DLUA_INCLUDE_DIR=${LUAJIT_INC} 8 | -DLUA_LIBRARIES=${LUAJIT_LIB} 9 | ) 10 | 11 | list(APPEND BUILD_CMD COMMAND ninja) 12 | 13 | if(MONOLIBTIC) 14 | append_install_commands(INSTALL_CMD rapidjson.a DESTINATION ${STAGING_DIR}/lib) 15 | else() 16 | append_binary_install_command(INSTALL_CMD rapidjson.so DESTINATION common) 17 | endif() 18 | 19 | external_project( 20 | DOWNLOAD GIT e84973356255bde06a70ce6263a3a0ef5c8f4ad4 21 | https://github.com/NiLuJe/lua-rapidjson 22 | PATCH_FILES ${PATCH_FILES} 23 | CMAKE_ARGS ${CMAKE_ARGS} 24 | BUILD_COMMAND ${BUILD_CMD} 25 | INSTALL_COMMAND ${INSTALL_CMD} 26 | ) 27 | -------------------------------------------------------------------------------- /thirdparty/lua-rapidjson/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -1,4 +1,4 @@ 4 | -cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) 5 | +cmake_minimum_required(VERSION 3.17.5 FATAL_ERROR) 6 | 7 | project(lua-rapidjson) 8 | 9 | @@ -24,19 +24,6 @@ if (LUA_RAPIDJSON_VERSION) 10 | endif() 11 | 12 | if(UNIX) 13 | - if(APPLE) 14 | - set(PLAT "macosx") 15 | - set(LINK_FLAGS "-bundle -undefined dynamic_lookup -all_load") 16 | - else(APPLE) 17 | - set(PLAT "linux") 18 | - set(LINK_FLAGS "-shared") 19 | - endif(APPLE) 20 | - add_compile_options(-g -Wall -fPIC) 21 | - include(CheckCXXCompilerFlag) 22 | - CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_ARCH_NATIVE) 23 | - if (COMPILER_SUPPORTS_ARCH_NATIVE) 24 | - add_compile_options(-march=native) 25 | - endif() 26 | else(UNIX) 27 | if(WIN32) 28 | set(PLAT "win32") 29 | @@ -69,7 +56,11 @@ 30 | src/calibre.hpp 31 | ) 32 | 33 | -add_library(lua-rapidjson MODULE ${SOURCES}) 34 | +if(BUILD_SHARED_LIBS) 35 | + add_library(lua-rapidjson MODULE ${SOURCES}) 36 | +else() 37 | + add_library(lua-rapidjson STATIC ${SOURCES}) 38 | +endif() 39 | if(${CMAKE_VERSION} VERSION_LESS "3.1.0") 40 | if(CMAKE_COMPILER_IS_GNUCXX) 41 | execute_process(COMMAND "${CMAKE_CXX_COMPILER} -dumpversion" OUTPUT_VARIABLE GCC_VERSION) 42 | @@ -84,9 +71,7 @@ endif() 43 | 44 | source_group(src FILES ${SOURCES}) 45 | 46 | -if (WIN32) 47 | - target_link_libraries(lua-rapidjson ${LUA_LIBRARIES}) 48 | -endif() 49 | +target_link_libraries(lua-rapidjson m ${LUA_LIBRARIES}) 50 | 51 | if (LINK_FLAGS) 52 | set_target_properties(lua-rapidjson PROPERTIES 53 | -------------------------------------------------------------------------------- /thirdparty/luajit/koreader-luajit-enable-table_pack.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/lib_table.c b/src/lib_table.c 2 | index d159360b..a3f146ce 100644 3 | --- a/src/lib_table.c 4 | +++ b/src/lib_table.c 5 | @@ -267,7 +267,6 @@ LJLIB_CF(table_sort) 6 | return 0; 7 | } 8 | 9 | -#if LJ_52 10 | LJLIB_PUSH("n") 11 | LJLIB_CF(table_pack) 12 | { 13 | @@ -283,7 +282,6 @@ LJLIB_CF(table_pack) 14 | lj_gc_check(L); 15 | return 1; 16 | } 17 | -#endif 18 | 19 | LJLIB_NOREG LJLIB_CF(table_new) LJLIB_REC(.) 20 | { 21 | @@ -316,10 +314,8 @@ static int luaopen_table_clear(lua_State *L) 22 | LUALIB_API int luaopen_table(lua_State *L) 23 | { 24 | LJ_LIB_REG(L, LUA_TABLIBNAME, table); 25 | -#if LJ_52 26 | lua_getglobal(L, "unpack"); 27 | lua_setfield(L, -2, "unpack"); 28 | -#endif 29 | lj_lib_prereg(L, LUA_TABLIBNAME ".new", luaopen_table_new, tabV(L->top-1)); 30 | lj_lib_prereg(L, LUA_TABLIBNAME ".clear", luaopen_table_clear, tabV(L->top-1)); 31 | return 1; 32 | -------------------------------------------------------------------------------- /thirdparty/luajit/koreader-luajit-verbose-build.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/Makefile b/src/Makefile 2 | index 9bc109d8..1a38d2fe 100644 3 | --- a/src/Makefile 4 | +++ b/src/Makefile 5 | @@ -597,10 +597,10 @@ endif 6 | endif 7 | endif 8 | 9 | -Q= @ 10 | -E= @echo 11 | -#Q= 12 | -#E= @: 13 | +#Q= @ 14 | +#E= @echo 15 | +Q= 16 | +E= @: 17 | 18 | ############################################################################## 19 | # Make targets. 20 | -------------------------------------------------------------------------------- /thirdparty/luajson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD lua/json.lua DESTINATION common) 5 | append_tree_install_commands(INSTALL_CMD lua/json common/json) 6 | 7 | external_project( 8 | DOWNLOAD GIT 6ecaf9bea8b121a9ffca5a470a2080298557b55d 9 | https://github.com/harningt/luajson.git 10 | INSTALL_COMMAND ${INSTALL_CMD} 11 | ) 12 | -------------------------------------------------------------------------------- /thirdparty/luarocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | list(APPEND CFG_CMD COMMAND 5 | ./configure 6 | --prefix=${STAGING_DIR} 7 | --with-lua=${STAGING_DIR} 8 | ) 9 | 10 | list(APPEND BUILD_CMD COMMAND make) 11 | 12 | list(APPEND INSTALL_CMD COMMAND make install) 13 | 14 | # Try to use our compilation flags. 15 | set(LD ${CC}) 16 | set(LIBFLAGS ${DYNLIB_LDFLAGS}) 17 | foreach(VAR CC CFLAGS LD LIBFLAGS) 18 | list(APPEND INSTALL_CMD COMMAND ${STAGING_DIR}/bin/luarocks config -- ${VAR} "${${VAR}}") 19 | endforeach() 20 | # Luarocks needs to be told where librt is when building 21 | # luasystem with clang in our Ubuntu based docker image. 22 | if(EMULATE_READER AND NOT APPLE) 23 | # NOTE: `librt.so.1` may not exists (e.g. on Alpine Linux), in which 24 | # case `find_compiler_lib_path` will return a false value ("NOTFOUND"). 25 | find_compiler_lib_path(RT_LIB librt.so.1) 26 | if(RT_LIB) 27 | get_filename_component(RT_LIBDIR ${RT_LIB} DIRECTORY) 28 | list(APPEND INSTALL_CMD COMMAND ${STAGING_DIR}/bin/luarocks config -- RT_LIBDIR "${RT_LIBDIR}") 29 | endif() 30 | endif() 31 | 32 | external_project( 33 | DOWNLOAD URL ab95865ced3c123908bd2f1fe6843606 34 | https://github.com/luarocks/luarocks/archive/refs/tags/v3.11.1.tar.gz 35 | CONFIGURE_COMMAND ${CFG_CMD} 36 | BUILD_COMMAND ${BUILD_CMD} 37 | INSTALL_COMMAND ${INSTALL_CMD} 38 | ) 39 | -------------------------------------------------------------------------------- /thirdparty/luasec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES visibility.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | if(MONOLIBTIC) 11 | append_install_commands(INSTALL_CMD ssl.a DESTINATION ${STAGING_DIR}/lib) 12 | else() 13 | append_binary_install_command(INSTALL_CMD ssl.so DESTINATION common) 14 | endif() 15 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/src/ssl.lua DESTINATION common) 16 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/src/https.lua DESTINATION common/ssl) 17 | 18 | external_project( 19 | DOWNLOAD GIT v1.3.2 20 | https://github.com/brunoos/luasec 21 | PATCH_OVERLAY overlay 22 | PATCH_FILES ${PATCH_FILES} 23 | CMAKE_ARGS ${CMAKE_ARGS} 24 | BUILD_COMMAND ${BUILD_CMD} 25 | INSTALL_COMMAND ${INSTALL_CMD} 26 | ) 27 | -------------------------------------------------------------------------------- /thirdparty/luasec/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(luasec LANGUAGES C) 3 | 4 | find_package(OpenSSL REQUIRED) 5 | find_package(PkgConfig REQUIRED) 6 | pkg_check_modules(LuaJIT luajit REQUIRED IMPORTED_TARGET) 7 | 8 | if(BUILD_SHARED_LIBS) 9 | add_library(ssl MODULE) 10 | else() 11 | add_library(ssl STATIC) 12 | endif() 13 | set_target_properties(ssl PROPERTIES C_VISIBILITY_PRESET hidden PREFIX "") 14 | target_compile_definitions(ssl PRIVATE -DWITH_LUASOCKET) 15 | target_include_directories(ssl PRIVATE ${CMAKE_INSTALL_PREFIX}/include) 16 | target_link_libraries(ssl PRIVATE 17 | ${CMAKE_INSTALL_PREFIX}/lib/libluasocket.a 18 | OpenSSL::Crypto OpenSSL::SSL 19 | PkgConfig::LuaJIT 20 | ) 21 | target_sources(ssl PRIVATE 22 | src/options.c 23 | src/x509.c 24 | src/context.c 25 | src/ssl.c 26 | src/config.c 27 | src/ec.c 28 | ) 29 | -------------------------------------------------------------------------------- /thirdparty/luasec/visibility.patch: -------------------------------------------------------------------------------- 1 | --- a/src/compat.h 2 | +++ b/src/compat.h 3 | @@ -15,7 +15,7 @@ 4 | #if defined(_WIN32) 5 | #define LSEC_API __declspec(dllexport) 6 | #else 7 | -#define LSEC_API extern 8 | +#define LSEC_API extern __attribute__ ((visibility("default"))) 9 | #endif 10 | 11 | //------------------------------------------------------------------------------ 12 | -------------------------------------------------------------------------------- /thirdparty/luasocket/enforce-cloexec.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/usocket.c b/src/usocket.c 2 | index 7965db6..fc1f607 100644 3 | --- a/src/usocket.c 4 | +++ b/src/usocket.c 5 | @@ -122,8 +122,15 @@ int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, 6 | \*-------------------------------------------------------------------------*/ 7 | int socket_create(p_socket ps, int domain, int type, int protocol) { 8 | *ps = socket(domain, type, protocol); 9 | - if (*ps != SOCKET_INVALID) return IO_DONE; 10 | - else return errno; 11 | + if (*ps != SOCKET_INVALID) { 12 | + // Enforce CLOEXEC 13 | + int flags = fcntl(*ps, F_GETFD, 0); 14 | + flags |= O_CLOEXEC; 15 | + fcntl(*ps, F_SETFD, flags); 16 | + return IO_DONE; 17 | + } else { 18 | + return errno; 19 | + } 20 | } 21 | 22 | /*-------------------------------------------------------------------------*\ 23 | -------------------------------------------------------------------------------- /thirdparty/luasocket/luajit-compat.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/compat.h b/src/compat.h 2 | --- a/src/compat.h 3 | +++ b/src/compat.h 4 | @@ -1,3 +1,4 @@ 5 | +#if 0 // not necessary for luajit 6 | #ifndef COMPAT_H 7 | #define COMPAT_H 8 | 9 | @@ -20,3 +21,4 @@ void *luasocket_testudata ( lua_State *L, int arg, const char *tname); 10 | #endif 11 | 12 | #endif 13 | +#endif 14 | -------------------------------------------------------------------------------- /thirdparty/luasocket/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(luasocket LANGUAGES C) 3 | 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(LuaJIT luajit REQUIRED IMPORTED_TARGET) 6 | 7 | add_library(luasocket STATIC) 8 | set_target_properties(luasocket PROPERTIES C_VISIBILITY_PRESET hidden) 9 | target_sources(luasocket PRIVATE 10 | src/auxiliar.c 11 | src/buffer.c 12 | src/compat.c 13 | src/except.c 14 | src/inet.c 15 | src/io.c 16 | src/options.c 17 | src/select.c 18 | src/tcp.c 19 | src/timeout.c 20 | src/udp.c 21 | ) 22 | if(APPLE) 23 | target_sources(luasocket PRIVATE src/usocket.c) 24 | elseif(LINUX) 25 | target_sources(luasocket PRIVATE src/usocket.c) 26 | elseif(WIN32) 27 | # TODO 28 | message(FATAL_ERROR "Windows is not supported") 29 | endif() 30 | target_link_libraries(luasocket PRIVATE PkgConfig::LuaJIT) 31 | 32 | foreach(MOD mcore score) 33 | if(BUILD_SHARED_LIBS) 34 | add_library(${MOD} MODULE) 35 | else() 36 | add_library(${MOD} STATIC) 37 | endif() 38 | set_target_properties(${MOD} PROPERTIES C_VISIBILITY_PRESET hidden PREFIX "") 39 | target_link_libraries(${MOD} PRIVATE luasocket PkgConfig::LuaJIT) 40 | endforeach() 41 | target_sources(mcore PRIVATE src/mime.c) 42 | target_sources(score PRIVATE src/luasocket.c) 43 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | cmake_tweaks.patch 3 | extended.patch 4 | ) 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | -DBUILD_SHARED_LIBS=$> 9 | # Project options. 10 | -DXTENDED_DIR=${CMAKE_CURRENT_SOURCE_DIR}/xtended 11 | ) 12 | 13 | list(APPEND BUILD_CMD COMMAND ninja) 14 | 15 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 16 | 17 | if(NOT MONOLIBTIC) 18 | append_shared_lib_install_commands(INSTALL_CMD lunasvg) 19 | endif() 20 | 21 | external_project( 22 | DOWNLOAD GIT 59d6f6ba835c1b7c7a0f9d4ea540ec3981777885 23 | https://github.com/sammycage/lunasvg.git 24 | PATCH_FILES ${PATCH_FILES} 25 | CMAKE_ARGS ${CMAKE_ARGS} 26 | BUILD_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/xtended/* 27 | BUILD_COMMAND ${BUILD_CMD} 28 | INSTALL_COMMAND ${INSTALL_CMD} 29 | ) 30 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -1,4 +1,4 @@ 4 | -cmake_minimum_required(VERSION 3.3) 5 | +cmake_minimum_required(VERSION 3.17.5) 6 | 7 | project(lunasvg VERSION 2.3.8 LANGUAGES CXX C) 8 | 9 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(lunasvg PRIVATE 2 | "${CMAKE_CURRENT_LIST_DIR}/ximageelement.cpp" 3 | "${CMAKE_CURRENT_LIST_DIR}/xtextelement.cpp" 4 | "${CMAKE_CURRENT_LIST_DIR}/xtspanelement.cpp" 5 | ) 6 | 7 | target_include_directories(lunasvg PRIVATE "${CMAKE_CURRENT_LIST_DIR}") 8 | 9 | install(FILES xlunasvg.h DESTINATION ${LUNASVG_INCDIR}) 10 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/ximageelement.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGEELEMENT_H 2 | #define IMAGEELEMENT_H 3 | 4 | #include "graphicselement.h" 5 | #include "layoutcontext.h" 6 | 7 | namespace lunasvg { 8 | 9 | class ImageElement : public GraphicsElement 10 | { 11 | public: 12 | ImageElement(); 13 | 14 | void layout(LayoutContext* context, LayoutContainer* current) const override; 15 | 16 | std::unique_ptr clone() const override; 17 | }; 18 | 19 | class LayoutImage : public LayoutObject 20 | { 21 | public: 22 | LayoutImage(); 23 | 24 | void render(RenderState& state) const; 25 | Rect map(const Rect& rect) const; 26 | const Rect& fillBoundingBox() const; 27 | const Rect& strokeBoundingBox() const; 28 | 29 | public: 30 | external_context_t * external_context; 31 | std::string href; 32 | double x; 33 | double y; 34 | double width; 35 | double height; 36 | PreserveAspectRatio preserveAspectRatio; 37 | Transform transform; 38 | FillData fillData; 39 | StrokeData strokeData; 40 | Visibility visibility; 41 | WindRule clipRule; 42 | double opacity; 43 | const LayoutMask* masker; 44 | const LayoutClipPath* clipper; 45 | 46 | private: 47 | mutable Rect m_fillBoundingBox{Rect::Invalid}; 48 | mutable Rect m_strokeBoundingBox{Rect::Invalid}; 49 | }; 50 | 51 | } // namespace lunasvg 52 | 53 | #endif // IMAGEELEMENT_H 54 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/xtextelement.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXTELEMENT_H 2 | #define TEXTELEMENT_H 3 | 4 | #include "graphicselement.h" 5 | 6 | namespace lunasvg { 7 | 8 | class TextElement : public GraphicsElement 9 | { 10 | public: 11 | TextElement(); 12 | 13 | void layout(LayoutContext* context, LayoutContainer* current) const override; 14 | 15 | std::unique_ptr clone() const override; 16 | }; 17 | 18 | } // namespace lunasvg 19 | 20 | #endif // TEXTELEMENT_H 21 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/xtspanelement.h: -------------------------------------------------------------------------------- 1 | #ifndef TSPANELEMENT_H 2 | #define TSPANELEMENT_H 3 | 4 | #include "geometryelement.h" 5 | #include "layoutcontext.h" 6 | 7 | namespace lunasvg { 8 | 9 | enum class TextAnchor 10 | { 11 | Start, 12 | Middle, 13 | End, 14 | }; 15 | 16 | enum class LengthAdjust 17 | { 18 | None, 19 | Spacing, 20 | SpacingAndGlyphs, 21 | }; 22 | 23 | // Text drawing state, passed from to/by all sub- 24 | typedef struct { 25 | double cursor_x; 26 | double cursor_y; 27 | double current_start_x; 28 | double current_start_y; 29 | double current_end_x; 30 | double current_end_y; 31 | bool current_started; 32 | bool last_was_space; 33 | bool is_pre; 34 | bool is_vertical_rl; 35 | TextAnchor text_anchor; 36 | TextAnchor current_text_anchor; 37 | LengthAdjust current_length_adjust; 38 | double current_adjust_text_length; 39 | std::unique_ptr current_group; 40 | } text_state_t; 41 | 42 | class TSpanElement : public GeometryElement 43 | { 44 | public: 45 | // Limited support for , that we make just a special kind of with TSpanElement(ElementID::TextPath) 46 | TSpanElement(ElementID id=ElementID::TSpan); 47 | 48 | static void addCurrentGroup(LayoutGroup* parent, text_state_t &text_state); 49 | 50 | void layoutText(LayoutContext* context, LayoutGroup* parent, text_state_t &text_state) const; 51 | 52 | void layout(LayoutContext* context, LayoutContainer* current) const override; // not used 53 | 54 | Path path() const override { return Path{}; } // not used 55 | 56 | std::unique_ptr clone() const override; 57 | }; 58 | 59 | } // namespace lunasvg 60 | 61 | #endif // TSPANELEMENT_H 62 | -------------------------------------------------------------------------------- /thirdparty/md4c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=FALSE 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 11 | 12 | external_project( 13 | DOWNLOAD URL 8ead909cfe31884295e81e2eee32bac9 14 | https://github.com/mity/md4c/archive/refs/tags/release-0.5.2.tar.gz 15 | PATCH_FILES ${PATCH_FILES} 16 | CMAKE_ARGS ${CMAKE_ARGS} 17 | BUILD_COMMAND ${BUILD_CMD} 18 | INSTALL_COMMAND ${INSTALL_CMD} 19 | ) 20 | -------------------------------------------------------------------------------- /thirdparty/md4c/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -1,5 +1,5 @@ 4 | 5 | -cmake_minimum_required(VERSION 3.5) 6 | +cmake_minimum_required(VERSION 3.17.5) 7 | project(MD4C C) 8 | 9 | set(MD_VERSION_MAJOR 0) 10 | -------------------------------------------------------------------------------- /thirdparty/minizip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 2 | 3 | list(APPEND BUILD_CMD COMMAND ninja) 4 | 5 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 6 | 7 | external_project( 8 | # NOTE: 53a657318af1fccc4bac7ed230729302b2391d1d is the tip 9 | # of the 1.2 branch. The fcrypt API we need is gone in master. 10 | # FIXME: Even then, something in said branch seems to upset MuPDF 11 | # with our custom patch as-is, so keep using the current code... 12 | DOWNLOAD GIT 0b46a2b4ca317b80bc53594688883f7188ac4d08 13 | https://github.com/nmoinvaz/minizip 14 | PATCH_OVERLAY overlay 15 | CMAKE_ARGS ${CMAKE_ARGS} 16 | BUILD_COMMAND ${BUILD_CMD} 17 | INSTALL_COMMAND ${INSTALL_CMD} 18 | ) 19 | -------------------------------------------------------------------------------- /thirdparty/minizip/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(minizip LANGUAGES C) 3 | 4 | file(GLOB AES_SRC aes/*.c) 5 | file(GLOB AES_HDR aes/*.h) 6 | 7 | add_library(aes STATIC ${AES_SRC}) 8 | target_compile_definitions(aes PRIVATE -DHAVE_AES) 9 | target_compile_options(aes PRIVATE -Wno-error=implicit-function-declaration) 10 | 11 | install(TARGETS aes) 12 | install(FILES ${AES_HDR} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/aes) 13 | -------------------------------------------------------------------------------- /thirdparty/mupdf/free-html-doc-fonts-on-close.patch: -------------------------------------------------------------------------------- 1 | diff --git a/source/html/html-doc.c b/source/html/html-doc.c 2 | index 4bfa1f325..5c0ea1637 100644 3 | --- a/source/html/html-doc.c 4 | +++ b/source/html/html-doc.c 5 | @@ -49,6 +49,11 @@ static void 6 | htdoc_drop_document(fz_context *ctx, fz_document *doc_) 7 | { 8 | html_document *doc = (html_document*)doc_; 9 | + /* Purge glyph cache so fonts can be freed. */ 10 | + fz_try(ctx) 11 | + fz_purge_glyph_cache(ctx); 12 | + fz_catch(ctx) 13 | + { /* Swallow error, but continue dropping */ } 14 | fz_drop_archive(ctx, doc->zip); 15 | fz_drop_html(ctx, doc->html); 16 | fz_drop_html_font_set(ctx, doc->set); 17 | -------------------------------------------------------------------------------- /thirdparty/mupdf/honor_cflags.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makerules b/Makerules 2 | index ba4df2189..bd4d6c217 100644 3 | --- a/Makerules 4 | +++ b/Makerules 5 | @@ -148,10 +148,10 @@ else 6 | endif 7 | 8 | ifeq ($(build),debug) 9 | - CFLAGS += -pipe -g 10 | + CFLAGS += -g 11 | LDFLAGS += -g 12 | else ifeq ($(build),release) 13 | - CFLAGS += -pipe -O2 -DNDEBUG 14 | + CFLAGS += -DNDEBUG 15 | LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s 16 | else ifeq ($(build),small) 17 | CFLAGS += -pipe -Os -DNDEBUG 18 | -------------------------------------------------------------------------------- /thirdparty/mupdf/no_arm_asm.patch: -------------------------------------------------------------------------------- 1 | diff --git a/include/mupdf/fitz/system.h b/include/mupdf/fitz/system.h 2 | index 3f2c13ccc..65fb15609 100644 3 | --- a/include/mupdf/fitz/system.h 4 | +++ b/include/mupdf/fitz/system.h 5 | @@ -84,11 +84,13 @@ typedef unsigned __int64 uint64_t; 6 | */ 7 | 8 | /* ARCH_ARM is only used for 32bit ARM stuff. */ 9 | +#if 0 10 | #if defined(__arm__) || defined(__thumb__) 11 | #ifndef ARCH_ARM 12 | #define ARCH_ARM 13 | #endif 14 | #endif 15 | +#endif 16 | 17 | /* Detect NEON */ 18 | #ifndef ARCH_HAS_NEON 19 | -------------------------------------------------------------------------------- /thirdparty/mupdf/relink_on_xlibs_change.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makefile b/Makefile 2 | index 1e760280f..10732a6a7 100644 3 | --- a/Makefile 4 | +++ b/Makefile 5 | @@ -299,7 +299,7 @@ generate: source/html/css-properties.h 6 | # --- Library --- 7 | 8 | ifeq ($(shared),yes) 9 | - $(OUT)/libmupdf.$(SO)$(SO_VERSION): $(MUPDF_OBJ) $(THIRD_OBJ) 10 | + $(OUT)/libmupdf.$(SO)$(SO_VERSION): $(MUPDF_OBJ) $(THIRD_OBJ) $(XLIBS) 11 | $(LINK_SO_CMD) $(THIRD_LIBS) $(LIBCRYPTO_LIBS) $(LIBS) 12 | ifeq ($(OS),OpenBSD) 13 | # should never create symlink 14 | -------------------------------------------------------------------------------- /thirdparty/nanosvg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands( 5 | INSTALL_CMD 6 | src/nanosvg.h src/nanosvgrast.h 7 | ${THIRDPARTY_DIR}/nanosvg/stb_image_write.h 8 | DESTINATION ${STAGING_DIR}/include 9 | ) 10 | 11 | external_project( 12 | DOWNLOAD GIT ea6a6aca009422bba0dbad4c80df6e6ba0c82183 13 | https://github.com/memononen/nanosvg.git 14 | INSTALL_COMMAND ${INSTALL_CMD} 15 | ) 16 | -------------------------------------------------------------------------------- /thirdparty/openlipclua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | if(MONOLIBTIC) 9 | append_install_commands(INSTALL_CMD liblipc.so libopenlipclua.a DESTINATION ${STAGING_DIR}/lib) 10 | else() 11 | append_binary_install_command(INSTALL_CMD libopenlipclua.so DESTINATION common) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD GIT 96c2d16696a482664b4e84eb3b6d851f807a44d1 16 | https://github.com/notmarek/openlipclua.git 17 | CMAKE_ARGS ${CMAKE_ARGS} 18 | BUILD_COMMAND ${BUILD_CMD} 19 | INSTALL_COMMAND ${INSTALL_CMD} 20 | ) 21 | -------------------------------------------------------------------------------- /thirdparty/openssh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT APPLE AND MONOLIBTIC) 2 | # Need `-pthread` for static OpenSSL's crypto library. 3 | string(APPEND LDFLAGS " -pthread") 4 | endif() 5 | list(APPEND CFG_CMD COMMAND env) 6 | if(LEGACY OR POCKETBOOK) 7 | # Avoid pulling-in `utimensat@@GLIBC_2.6` in `sftp-server`. 8 | list(APPEND CFG_CMD ac_cv_func_utimensat=no) 9 | endif() 10 | append_autotools_vars(CFG_CMD) 11 | list(APPEND CFG_CMD 12 | ${SOURCE_DIR}/configure --host=${CHOST} 13 | --disable-etc-default-login 14 | --disable-lastlog 15 | --with-md5-passwords 16 | --without-hardening 17 | --without-openssl 18 | --without-stackprotect 19 | --without-zlib 20 | ) 21 | 22 | set(PROGRAMS sftp-server) 23 | 24 | list(APPEND BUILD_CMD COMMAND make ${PROGRAMS}) 25 | 26 | append_binary_install_command(INSTALL_CMD ${PROGRAMS}) 27 | 28 | external_project( 29 | DOWNLOAD URL 689148621a2eaa734497b12bed1c5202 30 | https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.0p1.tar.gz 31 | https://mirror.edgecast.com/pub/OpenBSD/OpenSSH/portable/openssh-10.0p1.tar.gz 32 | CONFIGURE_COMMAND ${CFG_CMD} 33 | BUILD_COMMAND ${BUILD_CMD} 34 | INSTALL_COMMAND ${INSTALL_CMD} 35 | ) 36 | -------------------------------------------------------------------------------- /thirdparty/popen-noshell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(LEGACY) 2 | # Revert 8d7a98d on legacy devices, pipe2 was introduced in Linux 2.6.27 & glibc 2.9 3 | list(APPEND PATCH_FILES kindle_legacy.patch) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 11 | 12 | external_project( 13 | # NOTE: As of right now (1f9eaf4eeef348d1efe0f3c7fe8ab670653cfbb1), 14 | # wait until stuff settles down before bumping this. 15 | DOWNLOAD GIT e715396a4951ee91c40a98d2824a130f158268bb 16 | https://github.com/famzah/popen-noshell.git 17 | PATCH_OVERLAY overlay 18 | PATCH_FILES ${PATCH_FILES} 19 | CMAKE_ARGS ${CMAKE_ARGS} 20 | BUILD_COMMAND ${BUILD_CMD} 21 | INSTALL_COMMAND ${INSTALL_CMD} 22 | ) 23 | -------------------------------------------------------------------------------- /thirdparty/popen-noshell/kindle_legacy.patch: -------------------------------------------------------------------------------- 1 | diff --git a/popen_noshell.c b/popen_noshell.c 2 | index 61e0eff..8da4145 100644 3 | --- a/popen_noshell.c 4 | +++ b/popen_noshell.c 5 | @@ -334,7 +334,7 @@ FILE *popen_noshell(const char *file, const char * const *argv, const char *type 6 | // issue #7: O_CLOEXEC, so that child processes don't inherit and hold opened the 7 | // file descriptors of the parent. 8 | // The child process turns this off for its fd of the pipe. 9 | - if (pipe2(pipefd, O_CLOEXEC) != 0) return NULL; 10 | + if (pipe(pipefd) != 0) return NULL; 11 | 12 | if (_popen_noshell_fork_mode) { // use fork() 13 | -------------------------------------------------------------------------------- /thirdparty/popen-noshell/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(popen-noshell LANGUAGES C) 3 | 4 | add_library(popen_noshell STATIC popen_noshell.c) 5 | 6 | install(TARGETS popen_noshell) 7 | install(FILES popen_noshell.h TYPE INCLUDE) 8 | -------------------------------------------------------------------------------- /thirdparty/proxy-libintl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(proxy-libintl LANGUAGES) 2 | 3 | list(APPEND CFG_CMD COMMAND 4 | ${MESON_SETUP} --default-library=static 5 | "${SOURCE_DIR}" 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | list(APPEND BUILD_CMD COMMAND ${MESON_INSTALL}) 11 | 12 | external_project( 13 | DOWNLOAD URL 7cc93d2fec98a5b9820888135d2e8844 14 | https://github.com/frida/proxy-libintl/archive/refs/tags/0.4.tar.gz 15 | CONFIGURE_COMMAND ${CFG_CMD} 16 | BUILD_COMMAND ${BUILD_CMD} 17 | ) 18 | -------------------------------------------------------------------------------- /thirdparty/sdcv/compat_with_newer_glib.patch: -------------------------------------------------------------------------------- 1 | --- i/src/stardict_lib.cpp 2 | +++ w/src/stardict_lib.cpp 3 | @@ -1047,9 +1047,9 @@ 4 | } 5 | // Upper the first character and lower others. 6 | if (!bFound) { 7 | - gchar *nextchar = g_utf8_next_char(sWord); 8 | - gchar *firstchar = g_utf8_strup(sWord, nextchar - sWord); 9 | - nextchar = g_utf8_strdown(nextchar, -1); 10 | + size_t nextchar_pos = g_utf8_next_char(sWord) - sWord; 11 | + gchar *firstchar = g_utf8_strup(sWord, nextchar_pos); 12 | + gchar *nextchar = g_utf8_strdown(sWord + nextchar_pos, -1); 13 | casestr = g_strdup_printf("%s%s", firstchar, nextchar); 14 | g_free(firstchar); 15 | g_free(nextchar); 16 | 17 | -------------------------------------------------------------------------------- /thirdparty/sdcv/sdcv-no-unknown-dict-warning.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/sdcv.cpp b/src/sdcv.cpp 2 | index 3a10e3c..46db492 100644 3 | --- a/src/sdcv.cpp 4 | +++ b/src/sdcv.cpp 5 | @@ -190,8 +190,6 @@ try { 6 | auto it = bookname_to_ifo.find(*p); 7 | if (it != bookname_to_ifo.end()) { 8 | order_list.push_back(it->second); 9 | - } else { 10 | - fprintf(stderr, _("Unknown dictionary: %s\n"), *p); 11 | } 12 | } 13 | } else { 14 | @@ -207,8 +205,6 @@ try { 15 | auto it = bookname_to_ifo.find(line); 16 | if (it != bookname_to_ifo.end()) { 17 | order_list.push_back(it->second); 18 | - } else { 19 | - fprintf(stderr, _("Unknown dictionary: %s\n"), line.c_str()); 20 | } 21 | } 22 | fclose(ordering_file); 23 | -------------------------------------------------------------------------------- /thirdparty/sdl2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | cmake_tweaks.patch 3 | # Remove workarounds for standalone applications and add 4 | # a couple of actions to be used from the osx main menu. 5 | cocoa.patch 6 | ) 7 | if(APPIMAGE) 8 | # Tweak pkg-config search path (allow system packages), 9 | # help stupid cmake find system libraries, and fail if 10 | # required features / subsystems can't be enabled. 11 | list(APPEND PATCH_FILES appimage.patch) 12 | endif() 13 | 14 | list(APPEND CMAKE_ARGS 15 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 16 | # Project options. 17 | -DSDL2_DISABLE_SDL2MAIN=ON 18 | -DSDL_CMAKE_DEBUG_POSTFIX= # Remove 'd' suffix for the debug build library. 19 | -DSDL_SHARED=ON 20 | -DSDL_STATIC=OFF 21 | -DSDL_TEST=OFF 22 | # We don't need audio support. 23 | -DSDL_AUDIO=OFF 24 | -DSDL_LIBSAMPLERATE=OFF 25 | ) 26 | if(APPIMAGE) 27 | list(APPEND CMAKE_ARGS 28 | # Miscellaneous video features/subsystems we don't care about. 29 | -DSDL_DIRECTFB=OFF 30 | -DSDL_KMSDRM=OFF 31 | -DSDL_RPI=OFF 32 | # No libdecor-0-dev package in Ubuntu Focal. 33 | -DSDL_WAYLAND_LIBDECOR=OFF 34 | ) 35 | endif() 36 | 37 | list(APPEND BUILD_CMD COMMAND ninja) 38 | 39 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 40 | 41 | append_shared_lib_install_commands(INSTALL_CMD SDL2-2.0 VERSION 0) 42 | 43 | external_project( 44 | DOWNLOAD URL 4decfd2da9ea8534df73ce26f17f2c95 45 | https://github.com/libsdl-org/SDL/releases/download/release-2.32.4/SDL2-2.32.4.tar.gz 46 | PATCH_FILES ${PATCH_FILES} 47 | CMAKE_ARGS ${CMAKE_ARGS} 48 | BUILD_COMMAND ${BUILD_CMD} 49 | INSTALL_COMMAND ${INSTALL_CMD} 50 | ) 51 | -------------------------------------------------------------------------------- /thirdparty/sdl2/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -5,7 +5,7 @@ 4 | # MSVC runtime library flags are selected by an abstraction. 5 | set(CMAKE_POLICY_DEFAULT_CMP0091 NEW) 6 | 7 | -cmake_minimum_required(VERSION 3.0.0...3.10) 8 | +cmake_minimum_required(VERSION 3.17.5) 9 | project(SDL2 C) 10 | 11 | if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) 12 | -------------------------------------------------------------------------------- /thirdparty/spec/busted/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/busted-2.2.0-1.src.rock 3 | 85aa90d2d9d0213fcd8528bc489a3519 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/cluacov/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/luarocks/cluacov-0.1.4-1.src.rock 3 | 076273d593b0aa95666f1d3238d6549e 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/lua-term/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://github.com/hoelzro/lua-term/archive/0.08.tar.gz 3 | 672b60c1e856129891fe29e23632c032 4 | ROCKSPEC lua-term-0.8-1.rockspec 5 | ) 6 | -------------------------------------------------------------------------------- /thirdparty/spec/lua_cliargs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/lua_cliargs-3.0-2.src.rock 3 | cca85e869fac1b42252692693aed0333 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luacov/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/hisham/luacov-0.15.0-1.src.rock 3 | 5a3bc7c5b5ee85eb06cc8c4cc5cc3d94 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luafilesystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/hisham/luafilesystem-1.8.0-1.src.rock 3 | 93bd2cbd66d6fc25ff89920ef9293c6e 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luassert/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/luassert-1.9.0-1.src.rock 3 | 0df52010a5a5f728da0b9b7615a82da6 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luasystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/luasystem-0.6.0-1.src.rock 3 | 654a98c400b44bad51de61e42534ebe5 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/mediator_lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://github.com/Olivine-Labs/mediator_lua/archive/v1.1.2-0.tar.gz 3 | 3ef01fc6ced99f6e4c2a229e91c459bf 4 | ROCKSPEC mediator_lua-1.1.2-0.rockspec 5 | ) 6 | -------------------------------------------------------------------------------- /thirdparty/spec/penlight/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/tieske/penlight-1.14.0-2.src.rock 3 | ab64b4b635e2514db64b4eabfd9d2220 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/say/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/say-1.4.1-3.src.rock 3 | 3b776612edf1e659b2a1e95698597e44 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/sqlite/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD sqlite3 VERSION 0) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD URL c095d92a7514c8afed560756af2b7263 16 | https://sqlite.org/2025/sqlite-amalgamation-3500000.zip 17 | PATCH_OVERLAY overlay 18 | CMAKE_ARGS ${CMAKE_ARGS} 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /thirdparty/srell/license.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** 3 | ** SRELL (std::regex-like library) version 3.018 4 | ** 5 | ** Copyright (c) 2012-2023, Nozomu Katoo. All rights reserved. 6 | ** 7 | ** Redistribution and use in source and binary forms, with or without 8 | ** modification, are permitted provided that the following conditions are 9 | ** met: 10 | ** 11 | ** 1. Redistributions of source code must retain the above copyright notice, 12 | ** this list of conditions and the following disclaimer. 13 | ** 14 | ** 2. Redistributions in binary form must reproduce the above copyright 15 | ** notice, this list of conditions and the following disclaimer in the 16 | ** documentation and/or other materials provided with the distribution. 17 | ** 18 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS 19 | ** IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | ** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | ** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | ** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ** 30 | ****************************************************************************** 31 | **/ 32 | 33 | -------------------------------------------------------------------------------- /thirdparty/srell/readme_en.txt: -------------------------------------------------------------------------------- 1 | How to Use 2 | 3 | Put the following three files in one directory, and include srell.hpp. 4 | 1. srell.hpp 5 | 2. srell_ucfdata2.hpp (data for case folding) 6 | 3. srell_updata.hpp (data for Unicode properties) 7 | 8 | The files in the following directories are supplements. As SRELL does not use 9 | them, it is safe to remove them. 10 | 11 | * misc 12 | Contains a source code file for a simple test and benchmark program. 13 | 14 | * single-header 15 | Contains a standalone version of srell.hpp into which srell_ucfdata2.hpp 16 | and srell_updata.hpp have been merged. 17 | 18 | * unicode 19 | Contains source code files for programs that generate srell_ucfdata.hpp and 20 | srell_update.hpp from latest Unicode data text files. 21 | 22 | -------------------------------------------------------------------------------- /thirdparty/srell/readme_ja.txt: -------------------------------------------------------------------------------- 1 | ■使用法 2 | 3 | 次のファイルを同じディレクトリに置き、srell.hppをincludeするだけです。 4 | ・srell.hpp 5 | ・srell_ucfdata2.hpp(case folding用データ) 6 | ・srell_updata.hpp(Unicode property用データ) 7 | 8 | ■付属物 9 | 以下のディレクトリ内にあるものはおまけのようなものです。 10 | SRELL側からは参照していませんので、削除してしまってもライブラリの動作に 11 | 影響はありません。 12 | 13 | ・misc 14 | 簡単なテスト及びベンチマークプログラムのソースが入っています。 15 | 16 | ・single-header 17 | srell.hppの中にsrell_ucfdata2.hppとsrell_updata.hppとを統合してしまい、 18 | これ単体で使用できるようにしたstandalone版が入っています。 19 | 20 | ・unicode 21 | 最新のUnicodeデータからsrell_ucfdata.hpp及びsrell_updata.hppを作るため 22 | のプログラムのソースが入っています。 23 | 24 | -------------------------------------------------------------------------------- /thirdparty/tar/tar-1.33-remove-o_path-usage.patch: -------------------------------------------------------------------------------- 1 | diff -Nuarp tar-1.33-ori/gnu/fchmodat.c tar-1.33/gnu/fchmodat.c 2 | --- tar-1.33-ori/gnu/fchmodat.c 2021-01-07 15:29:44.000000000 +0100 3 | +++ tar-1.33/gnu/fchmodat.c 2021-01-16 00:41:39.414012004 +0100 4 | @@ -68,7 +68,7 @@ fchmodat (int dir, char const *file, mod 5 | { 6 | struct stat st; 7 | 8 | -# if defined O_PATH && defined AT_EMPTY_PATH 9 | +# if defined NOPE_PATH && defined AT_EMPTY_PATH 10 | /* Open a file descriptor with O_NOFOLLOW, to make sure we don't 11 | follow symbolic links, if /proc is mounted. O_PATH is used to 12 | avoid a failure if the file is not readable. 13 | diff -Nuarp tar-1.33-ori/gnu/lchmod.c tar-1.33/gnu/lchmod.c 14 | --- tar-1.33-ori/gnu/lchmod.c 2021-01-07 15:28:45.000000000 +0100 15 | +++ tar-1.33/gnu/lchmod.c 2021-01-16 00:41:28.708012124 +0100 16 | @@ -45,7 +45,7 @@ 17 | int 18 | lchmod (char const *file, mode_t mode) 19 | { 20 | -#if defined O_PATH && defined AT_EMPTY_PATH 21 | +#if defined NOPE_PATH && defined AT_EMPTY_PATH 22 | /* Open a file descriptor with O_NOFOLLOW, to make sure we don't 23 | follow symbolic links, if /proc is mounted. O_PATH is used to 24 | avoid a failure if the file is not readable. 25 | -------------------------------------------------------------------------------- /thirdparty/tesseract/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | k2pdfopt.patch 3 | cmake_tweaks.patch 4 | fix-old-tc-build.patch 5 | no_debug_fonts.patch 6 | ) 7 | 8 | list(APPEND CMAKE_ARGS 9 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 10 | # Project options. 11 | -DANDROID=${ANDROID} 12 | -DBUILD_TRAINING_TOOLS=FALSE 13 | -DDISABLE_ARCHIVE=TRUE 14 | -DDISABLE_CURL=TRUE 15 | -DDISABLE_TIFF=TRUE 16 | -DGRAPHICS_DISABLED=TRUE 17 | -DINSTALL_CONFIGS=FALSE 18 | ) 19 | 20 | list(APPEND BUILD_CMD COMMAND ninja) 21 | 22 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 23 | 24 | external_project( 25 | DOWNLOAD URL 17a6d7b78793ff587686449b29d51894 26 | https://github.com/tesseract-ocr/tesseract/archive/refs/tags/5.5.0.tar.gz 27 | PATCH_FILES ${PATCH_FILES} 28 | CMAKE_ARGS ${CMAKE_ARGS} 29 | BUILD_COMMAND ${BUILD_CMD} 30 | INSTALL_COMMAND ${INSTALL_CMD} 31 | ) 32 | -------------------------------------------------------------------------------- /thirdparty/tesseract/no_debug_fonts.patch: -------------------------------------------------------------------------------- 1 | --- i/src/ccstruct/debugpixa.h 2 | +++ w/src/ccstruct/debugpixa.h 3 | @@ -14,7 +14,7 @@ 4 | // TODO(rays) add another constructor with size control. 5 | DebugPixa() { 6 | pixa_ = pixaCreate(0); 7 | -#ifdef TESSERACT_DISABLE_DEBUG_FONTS 8 | +#if 1//def TESSERACT_DISABLE_DEBUG_FONTS 9 | fonts_ = NULL; 10 | #else 11 | fonts_ = bmfCreate(nullptr, 14); 12 | -------------------------------------------------------------------------------- /thirdparty/turbo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | # Drop duplicate cdefs, make sure turbo find its 3 | # libtffi_wrap library, and pull in upstream fixes. 4 | turbo.patch 5 | d7a8a247a4a2689b0f207162eb804141c87c4899.patch 6 | ) 7 | 8 | # Remove the 7 years-old copy of a CA bundle that turbo doesn't actually use. 9 | list(APPEND PATCH_CMD COMMAND rm turbo/ca-certificates.crt) 10 | # Some of the LUA files are executables for no good reason. 11 | list(APPEND PATCH_CMD COMMAND chmod a-x turbo/platform.lua turbo/socket_ffi.lua turbo/syscall.lua) 12 | 13 | list(APPEND CMAKE_ARGS 14 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 15 | -DBUILD_SHARED_LIBS=$> 16 | ) 17 | 18 | list(APPEND BUILD_CMD COMMAND ninja) 19 | 20 | if(MONOLIBTIC) 21 | append_install_commands(INSTALL_CMD libtffi_wrap.a DESTINATION ${STAGING_DIR}/lib) 22 | else() 23 | append_binary_install_command(INSTALL_CMD libtffi_wrap${LIB_EXT} DESTINATION libs) 24 | endif() 25 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/turbo.lua ${SOURCE_DIR}/turbovisor.lua DESTINATION common) 26 | append_tree_install_commands(INSTALL_CMD ${SOURCE_DIR}/turbo common/turbo) 27 | 28 | external_project( 29 | DOWNLOAD GIT v2.1.3 30 | https://github.com/kernelsauce/turbo 31 | PATCH_OVERLAY overlay 32 | PATCH_FILES ${PATCH_FILES} 33 | PATCH_COMMAND ${PATCH_CMD} 34 | CMAKE_ARGS ${CMAKE_ARGS} 35 | BUILD_COMMAND ${BUILD_CMD} 36 | INSTALL_COMMAND ${INSTALL_CMD} 37 | ) 38 | -------------------------------------------------------------------------------- /thirdparty/turbo/d7a8a247a4a2689b0f207162eb804141c87c4899.patch: -------------------------------------------------------------------------------- 1 | From d7a8a247a4a2689b0f207162eb804141c87c4899 Mon Sep 17 00:00:00 2001 2 | From: John Abrahamsen 3 | Date: Thu, 15 Jun 2023 21:58:50 +0200 4 | Subject: [PATCH] Fix bug, where memory would/could be free'd while being used 5 | in HTTP parser. 6 | 7 | --- 8 | turbo/httputil.lua | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/turbo/httputil.lua b/turbo/httputil.lua 12 | index 4f86508c..cf7f326c 100644 13 | --- a/turbo/httputil.lua 14 | +++ b/turbo/httputil.lua 15 | @@ -136,8 +136,8 @@ function httputil.HTTPParser:parse_url(url) 16 | if htpurl == nil then 17 | error("Could not allocate memory") 18 | end 19 | - ffi.gc(htpurl, ffi.C.free) 20 | self.http_parser_url = ffi.cast("struct http_parser_url *", htpurl) 21 | + ffi.gc(self.http_parser_url, ffi.C.free) 22 | local rc = libturbo_parser.http_parser_parse_url( 23 | url, 24 | url:len(), 25 | -------------------------------------------------------------------------------- /thirdparty/turbo/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(turbo LANGUAGES C) 3 | 4 | find_package(OpenSSL REQUIRED) 5 | 6 | add_library(tffi_wrap) 7 | target_include_directories(tffi_wrap PRIVATE deps/http-parser) 8 | target_link_libraries(tffi_wrap PRIVATE OpenSSL::Crypto OpenSSL::SSL) 9 | target_sources(tffi_wrap PRIVATE deps/http-parser/http_parser.c deps/turbo_ffi_wrap.c) 10 | -------------------------------------------------------------------------------- /thirdparty/utf8proc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD utf8proc VERSION 3) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD URL faa0bbe8f5763da45f2dfb5f863f0400 16 | https://github.com/JuliaStrings/utf8proc/archive/refs/tags/v2.10.0.tar.gz 17 | CMAKE_ARGS ${CMAKE_ARGS} 18 | BUILD_COMMAND ${BUILD_CMD} 19 | INSTALL_COMMAND ${INSTALL_CMD} 20 | ) 21 | -------------------------------------------------------------------------------- /thirdparty/xz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # We don't care about tests. 2 | list(APPEND PATCH_CMD COMMAND rm -rf tests) 3 | 4 | set(FILTERS lzma1 lzma2 delta) 5 | # if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") 6 | # list(APPEND FILTERS arm64) 7 | # elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") 8 | # list(APPEND FILTERS arm armthumb) 9 | # elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") 10 | # list(APPEND FILTERS x86) 11 | # endif() 12 | list(JOIN FILTERS $ FILTERS) 13 | 14 | list(APPEND CMAKE_ARGS 15 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 16 | -DBUILD_SHARED_LIBS=$> 17 | # Project options. 18 | -DXZ_DOC=FALSE 19 | # We can't disable the encoder completely, 20 | # or libarchive' setup will fail to enable 21 | # LZMA support. 22 | -DXZ_ENCODERS=${FILTERS} 23 | -DXZ_MICROLZMA_ENCODER=FALSE 24 | # Reduce decoder support to the bare minimum 25 | # needed for use by android-luajit-launcher. 26 | -DXZ_DECODERS=${FILTERS} 27 | -DXZ_LZIP_DECODER=FALSE 28 | -DXZ_MICROLZMA_DECODER=FALSE 29 | # Disable NLS support. 30 | -DCMAKE_DISABLE_FIND_PACKAGE_Gettext=TRUE 31 | -DCMAKE_DISABLE_FIND_PACKAGE_Intl=TRUE 32 | -DXZ_NLS=FALSE 33 | # We don't need the tools. 34 | -DXZ_SANDBOX=no 35 | -DXZ_TOOL_LZMADEC=FALSE 36 | -DXZ_TOOL_LZMAINFO=FALSE 37 | -DXZ_TOOL_XZ=FALSE 38 | -DXZ_TOOL_XZDEC=FALSE 39 | ) 40 | 41 | list(APPEND BUILD_CMD COMMAND ninja) 42 | 43 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 44 | 45 | if(NOT MONOLIBTIC) 46 | append_shared_lib_install_commands(INSTALL_CMD lzma VERSION 5) 47 | endif() 48 | 49 | external_project( 50 | DOWNLOAD URL cf5e1feb023d22c6bdaa30e84ef3abe3 51 | https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1.tar.xz 52 | PATCH_COMMAND ${PATCH_CMD} 53 | CMAKE_ARGS ${CMAKE_ARGS} 54 | BUILD_COMMAND ${BUILD_CMD} 55 | INSTALL_COMMAND ${INSTALL_CMD} 56 | ) 57 | -------------------------------------------------------------------------------- /thirdparty/zlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Pre-emptively rename `zconf.h`: this is normaly done 2 | # by `CMakeLists.txt` at configure time, and wreaks havoc 3 | # with `build.d` generation. Since the later is done before 4 | # configuring, a missing `zconf.h` would endlessly trigger 5 | # a new zlib build. 6 | list(APPEND PATCH_CMD COMMAND mv zconf.h zconf.h.included) 7 | 8 | list(APPEND CMAKE_ARGS 9 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 10 | # Project options. 11 | -DINSTALL_PKGCONFIG_DIR=${STAGING_DIR}/lib/pkgconfig 12 | ) 13 | 14 | list(APPEND BUILD_CMD COMMAND ninja zlib zlibstatic) 15 | 16 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 17 | 18 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/contrib/minizip/crypt.h DESTINATION ${STAGING_DIR}/include/contrib/minizip) 19 | if(MONOLIBTIC) 20 | # The CMake build system does not support building & installing only 21 | # a static / shared library, so we have to manually cleanup after the 22 | # install step. 23 | list(APPEND INSTALL_CMD COMMAND sh -c "rm -v \"$1\"*" -- ${STAGING_DIR}/lib/libz${LIB_EXT}) 24 | else() 25 | append_shared_lib_install_commands(INSTALL_CMD z VERSION 1) 26 | endif() 27 | 28 | external_project( 29 | DOWNLOAD URL 5e6af153311327e516690d300527ec9e 30 | https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.xz 31 | PATCH_COMMAND ${PATCH_CMD} 32 | CMAKE_ARGS ${CMAKE_ARGS} 33 | BUILD_COMMAND ${BUILD_CMD} 34 | INSTALL_COMMAND ${INSTALL_CMD} 35 | ) 36 | -------------------------------------------------------------------------------- /thirdparty/zstd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(GLIBC_VERSION_MAX AND GLIBC_VERSION_MAX VERSION_LESS "2.8") 2 | list(APPEND PATCH_FILES no_qsort_r.patch) 3 | endif() 4 | 5 | list(APPEND CMAKE_ARGS 6 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 7 | # Project options. 8 | -DZSTD_BUILD_PROGRAMS=FALSE 9 | -DZSTD_BUILD_SHARED=$> 10 | -DZSTD_BUILD_STATIC=$ 11 | -DZSTD_LEGACY_SUPPORT=FALSE 12 | -DZSTD_MULTITHREAD_SUPPORT=FALSE 13 | ) 14 | 15 | list(APPEND BUILD_CMD COMMAND ninja) 16 | 17 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 18 | 19 | if(NOT MONOLIBTIC) 20 | append_shared_lib_install_commands(INSTALL_CMD zstd VERSION 1) 21 | endif() 22 | 23 | external_project( 24 | DOWNLOAD URL 780fc1896922b1bc52a4e90980cdda48 25 | https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz 26 | PATCH_FILES ${PATCH_FILES} 27 | SOURCE_SUBDIR build/cmake 28 | CMAKE_ARGS ${CMAKE_ARGS} 29 | BUILD_COMMAND ${BUILD_CMD} 30 | INSTALL_COMMAND ${INSTALL_CMD} 31 | ) 32 | -------------------------------------------------------------------------------- /thirdparty/zstd/no_qsort_r.patch: -------------------------------------------------------------------------------- 1 | --- a/lib/dictBuilder/cover.c 2 | +++ b/lib/dictBuilder/cover.c 3 | @@ -241,7 +241,7 @@ 4 | unsigned d; 5 | } COVER_ctx_t; 6 | 7 | -#if !defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(_MSC_VER) 8 | +#if 1 9 | /* C90 only offers qsort() that needs a global context. */ 10 | static COVER_ctx_t *g_coverCtx = NULL; 11 | #endif 12 | @@ -290,7 +290,7 @@ 13 | */ 14 | #if (defined(_WIN32) && defined(_MSC_VER)) || defined(__APPLE__) 15 | static int WIN_CDECL COVER_strict_cmp(void* g_coverCtx, const void* lp, const void* rp) { 16 | -#elif defined(_GNU_SOURCE) 17 | +#elif 0 18 | static int COVER_strict_cmp(const void *lp, const void *rp, void *g_coverCtx) { 19 | #else /* C90 fallback.*/ 20 | static int COVER_strict_cmp(const void *lp, const void *rp) { 21 | @@ -306,7 +306,7 @@ 22 | */ 23 | #if (defined(_WIN32) && defined(_MSC_VER)) || defined(__APPLE__) 24 | static int WIN_CDECL COVER_strict_cmp8(void* g_coverCtx, const void* lp, const void* rp) { 25 | -#elif defined(_GNU_SOURCE) 26 | +#elif 0 27 | static int COVER_strict_cmp8(const void *lp, const void *rp, void *g_coverCtx) { 28 | #else /* C90 fallback.*/ 29 | static int COVER_strict_cmp8(const void *lp, const void *rp) { 30 | @@ -328,7 +328,7 @@ 31 | qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32), 32 | ctx, 33 | (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp)); 34 | -#elif defined(_GNU_SOURCE) 35 | +#elif 0 36 | qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32), 37 | (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp), 38 | ctx); 39 | -------------------------------------------------------------------------------- /thirdparty/zsync2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DOPENSSL_USE_STATIC_LIBS=$ 6 | # Options. 7 | -DBUILD_CPR_TESTS=FALSE 8 | -DBUILD_TESTING=FALSE 9 | -DCPR_FORCE_OPENSSL_BACKEND=TRUE 10 | -DUSE_SYSTEM_CURL=TRUE 11 | ) 12 | 13 | list(APPEND BUILD_CMD COMMAND ninja zsync2) 14 | 15 | append_binary_install_command(INSTALL_CMD src/zsync2) 16 | 17 | # NOTE: We're currently using our own fork instead of upstream's (https://github.com/AppImage/zsync2): 18 | ## * Enable range requests optimizations on the CLI 19 | ## * Re-implement the -u flag for compatibility w/ the old zsync CLI 20 | ## * Minor CLI output cleanup 21 | ## * Squish all the warnings 22 | ## * Prevent passing a malformed referer URL 23 | ## * Don't print seven billion progress bars 24 | ## * Rebase against zsync master (c.f., rebase-zsync-libs branch) 25 | ## * Rebase against zlib 1.3.0.1 (c.f., rebase-zlib branch) 26 | ## * Workaround potential download loops, like what happened w/ the 2019.12 -> 2020.01 update. 27 | ## * Mangle logging to play nice w/ FBInk 28 | ## * Plug memory leaks 29 | # c.f., https://github.com/NiLuJe/zsync2 for more details. 30 | 31 | external_project( 32 | DOWNLOAD GIT e281e1eb4466ff6b3866c25dbe62a3e150fa5bfd 33 | https://github.com/NiLuJe/zsync2.git 34 | PATCH_FILES ${PATCH_FILES} 35 | CMAKE_ARGS ${CMAKE_ARGS} 36 | BUILD_COMMAND ${BUILD_CMD} 37 | INSTALL_COMMAND ${INSTALL_CMD} 38 | ) 39 | -------------------------------------------------------------------------------- /toolchain/Makefile: -------------------------------------------------------------------------------- 1 | .DELETE_ON_ERROR: 2 | .ONESHELL: 3 | 4 | SHELL := /bin/bash 5 | .SHELLFLAGS := -xec 6 | 7 | TOOLCHAIN_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) 8 | 9 | # Sdk tools 26.1.1 10 | SDK_TARBALL = commandlinetools-linux-10406996_latest.zip 11 | SDK_DL_URL = https://dl.google.com/android/repository/$(SDK_TARBALL) 12 | 13 | .SECONDARY: $(SDK_TARBALL) 14 | 15 | SDK_SUM = 87b485c7283cba69e41c10f05bf832d2fd691552 16 | SDK_DIR = android-sdk-linux 17 | 18 | WGET ?= wget --progress=dot:giga 19 | 20 | android-sdk: $(TOOLCHAIN_DIR)/$(SDK_DIR) 21 | 22 | $(SDK_TARBALL): 23 | $(WGET) '$(SDK_DL_URL)' 24 | echo '$(SDK_SUM) $(SDK_TARBALL)' | sha1sum -c - 25 | 26 | $(TOOLCHAIN_DIR)/$(SDK_DIR): $(SDK_TARBALL) 27 | mkdir -p $(SDK_DIR)/cmdline-tools 28 | cd $(SDK_DIR)/cmdline-tools 29 | unzip $(TOOLCHAIN_DIR)/$(SDK_TARBALL) 30 | mv cmdline-tools latest 31 | cd latest/bin 32 | yes | ./sdkmanager --update 33 | yes | ./sdkmanager --licenses 34 | ./sdkmanager 'platform-tools' 'build-tools;34.0.0' 'platforms;android-30' 35 | ./sdkmanager --uninstall 'emulator' # Installed automatically but we don't need it. 36 | rm -f $(TOOLCHAIN_DIR)/$(SDK_TARBALL) 37 | 38 | # NDK r15c 39 | NDK_DIR = android-ndk-r23c 40 | NDK_TARBALL = $(NDK_DIR)-linux.zip 41 | NDK_DL_URL = https://dl.google.com/android/repository/$(NDK_TARBALL) 42 | NDK_SUM = e5053c126a47e84726d9f7173a04686a71f9a67a 43 | 44 | .SECONDARY: $(NDK_TARBALL) 45 | 46 | android-ndk: $(TOOLCHAIN_DIR)/$(NDK_DIR) 47 | 48 | $(NDK_TARBALL): 49 | $(WGET) '$(NDK_DL_URL)' 50 | echo '$(NDK_SUM) $(NDK_TARBALL)' | sha1sum -c - 51 | 52 | $(TOOLCHAIN_DIR)/$(NDK_DIR): $(NDK_TARBALL) 53 | unzip $(NDK_TARBALL) 54 | # Trim the fat. 55 | rm -vrf $(NDK_DIR)/toolchains/renderscript 56 | rm -vrf $(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/bin/*1[67]-clang* 57 | rm -vrf $(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/*/1[67] 58 | if which hardlink; then 59 | hardlink $(NDK_DIR) 60 | fi 61 | rm -f $(NDK_TARBALL) 62 | 63 | android: android-sdk android-ndk 64 | -------------------------------------------------------------------------------- /utils/bincheck/libinkview.c: -------------------------------------------------------------------------------- 1 | #include "stub.h" 2 | STUB(ClearTimer) 3 | STUB(GetCurrentTask) 4 | STUB(GetTouchInfo) 5 | STUB(InkViewMain) 6 | STUB(LeaveInkViewMain) 7 | STUB(SendEventTo) 8 | STUB(SetHardTimer) 9 | STUB(SetPanelType) 10 | STUB(SetWeakTimer) 11 | STUB(iv_sleepmode) 12 | -------------------------------------------------------------------------------- /utils/bincheck/liblipc.c: -------------------------------------------------------------------------------- 1 | #include "stub.h" 2 | STUB(LipcHasharrayKeys) 3 | STUB(LipcHasharrayGetInt) 4 | STUB(LipcHasharrayNew) 5 | STUB(LipcClose) 6 | STUB(LipcSetIntProperty) 7 | STUB(LipcHasharrayPutInt) 8 | STUB(LipcOpenNoName) 9 | STUB(LipcFreeString) 10 | STUB(LipcHasharrayDestroy) 11 | STUB(LipcSetStringProperty) 12 | STUB(LipcGetStringProperty) 13 | STUB(LipcHasharrayAddHash) 14 | STUB(LipcHasharrayGetHashCount) 15 | STUB(LipcHasharrayPutString) 16 | STUB(LipcOpenEx) 17 | STUB(LipcGetErrorString) 18 | STUB(LipcGetIntProperty) 19 | STUB(LipcGetServiceName) 20 | STUB(LipcHasharrayToString) 21 | STUB(LipcHasharrayGetString) 22 | STUB(LipcAccessHasharrayProperty) 23 | STUB(LipcHasharrayCheckKey) 24 | -------------------------------------------------------------------------------- /utils/bincheck/stub.h: -------------------------------------------------------------------------------- 1 | #define STUB(FuncName) void FuncName(void) {} 2 | -------------------------------------------------------------------------------- /utils/binfind.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import platform 5 | import sys 6 | 7 | 8 | def iself(path): 9 | if path.endswith('.dbg'): 10 | return False 11 | with open(path, 'rb') as fp: 12 | return fp.read(4) == b'\x7FELF' 13 | 14 | def ismacho(path): 15 | if path.endswith('.dSYM'): 16 | return False 17 | if path.endswith('.tbd'): 18 | return True 19 | with open(path, 'rb') as fp: 20 | # NOTE: check for 64-bits little endian binaries only. 21 | return fp.read(4) in b'\xcf\xfa\xed\xfe' 22 | 23 | def any_darwin_bin(paths): 24 | return any( 25 | p.endswith('.dylib') or p.endswith('.tbd') 26 | or (os.path.isfile(p) and ismacho(p)) 27 | for p in paths 28 | ) 29 | 30 | def binfind(pathlist, darwin=None): 31 | if darwin is None: 32 | darwin = platform.system() == 'Darwin' 33 | isbin = ismacho if darwin else iself 34 | for path in pathlist: 35 | if not os.path.isdir(path): 36 | assert os.path.isfile(path), path 37 | if isbin(path): 38 | yield path 39 | for dirpath, _dirnames, filenames in os.walk(path): 40 | for entry in filenames: 41 | entry = os.path.join(dirpath, entry) 42 | if os.access(entry, os.X_OK) and isbin(entry): 43 | yield entry 44 | 45 | 46 | def main(args, darwin=None): 47 | if darwin is None: 48 | darwin = platform.system() == 'Darwin' or any_darwin_bin(args) 49 | print('\n'.join(sorted(binfind(args, darwin=darwin)))) 50 | 51 | if __name__ == '__main__': 52 | sys.exit(main(sys.argv[1:])) 53 | -------------------------------------------------------------------------------- /utils/fake_tty.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os, pty, sys 4 | 5 | os.environ['TERM'] = 'xterm-256color' 6 | status = pty.spawn(sys.argv[1:]) 7 | if os.WIFEXITED(status): 8 | exit(os.WEXITSTATUS(status)) 9 | if os.WIFSIGNALED(status): 10 | exit(-os.WTERMSIG(status)) 11 | raise ValueError(status) 12 | -------------------------------------------------------------------------------- /xtext.h: -------------------------------------------------------------------------------- 1 | // xtext.cpp 2 | // Lua interface to wrap a utf8 string into a XText object 3 | // that provides various text shaping and layout methods 4 | // with the help of Fribidi, Harfbuzz and libunibreak. 5 | 6 | #ifndef _XTEXT_H 7 | #define _XTEXT_H 8 | 9 | extern "C" 10 | { 11 | #include 12 | #include 13 | #include 14 | } 15 | 16 | // Symbol visibility 17 | #define DLL_PUBLIC __attribute__((visibility("default"))) 18 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 19 | 20 | DLL_PUBLIC int luaopen_xtext(lua_State *L); 21 | #endif 22 | --------------------------------------------------------------------------------