diff --git a/.gitignore b/.gitignore index 046af69cf..d7fe4be24 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,6 @@ l10n/* koreader-arm-linux-androideabi koreader-arm-linux-gnueabi koreader-arm-linux-gnueabihf +koreader-i686-w64-mingw32 koreader-x86_64-linux-gnu diff --git a/Makefile b/Makefile index 62878b56e..f82da93e9 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ all: $(if $(ANDROID),,$(KOR_BASE)/$(OUTPUT_DIR)/luajit) $(MAKE) -C $(KOR_BASE) echo $(VERSION) > git-rev mkdir -p $(INSTALL_DIR)/koreader -ifdef EMULATE_READER +ifneq ($(or $(EMULATE_READER),$(WIN32)),) cp -f $(KOR_BASE)/ev_replay.py $(INSTALL_DIR)/koreader/ # create symlink instead of copying files in development mode cd $(INSTALL_DIR)/koreader && \ @@ -51,6 +51,10 @@ endif ifdef ANDROID cd $(INSTALL_DIR)/koreader && \ ln -sf ../../$(ANDROID_DIR)/*.lua . +endif +ifdef WIN32 + # install runtime libraries for win32 + cd $(INSTALL_DIR)/koreader && cp ../../windows/*.dll . endif # install plugins cp -r plugins/* $(INSTALL_DIR)/koreader/plugins/ @@ -60,7 +64,7 @@ endif mkdir -p $(INSTALL_DIR)/koreader/data/tessdata mkdir -p $(INSTALL_DIR)/koreader/fonts/host mkdir -p $(INSTALL_DIR)/koreader/ota -ifndef EMULATE_READER +ifeq ($(or $(EMULATE_READER),$(WIN32)),) # clean up, remove unused files for releases rm -rf $(INSTALL_DIR)/koreader/data/{cr3.ini,cr3skin-format.txt,desktop,devices,manual} rm $(INSTALL_DIR)/koreader/fonts/droid/DroidSansFallbackFull.ttc diff --git a/README.md b/README.md index d4fbdd520..fea2fd372 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ KOReader [![Build Status][travis-icon]][travis-link] ======== -KOReader is a document viewer application, originally created for usage on the -Kindle e-ink reader. It currently supports Kindle 5 (Touch), Kindle Paperwhite -, Kobo and Android devices. +KOReader is a document viewer application, originally created for Kindle +e-ink readers. It currently runs on Kindle 5 (Touch), Kindle Paperwhite, +Kobo, Android(2.3+) devices. KOReader started as the KindlePDFViewer application, but it supports much more formats than PDF now. Among them are DJVU, FB2, EPUB, TXT, CBZ, HTML. @@ -40,6 +40,8 @@ Cross compile toolchains are available for Ubuntu users through these commands: sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi # for Kobo sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf +# for Win32 +sudo apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 ``` A recent version of Android SDK/NDK and `ant` are needed in order to build Koreader for Android @@ -49,7 +51,7 @@ sudo apt-get install ant ``` You might also need SDL library packages if you want to compile and run -Koreader on PC. Fedora users can install `SDL` and `SDL-devel`. +Koreader on your Linux PC. Fedora users can install `SDL` and `SDL-devel`. Ubuntu users probably need to run: ``` sudo apt-get install libsdl1.2-dev @@ -104,14 +106,19 @@ Then, build installable package for Android: make TARGET=android clean androidupdate ``` -For emulating +For emulating Koreader on Linux and Windows ------------- -To build an emulator on current machine just run: +To build an emulator on current Linux machine just run: ``` make clean && make ``` +If you want to compile the emulator for Windows you need to run: +``` +make TARGET=win32 clean && make TARGET=win32 +``` + To run koreader on your developing machine (you may need to change $(MACHINE) to the arch of your machine such as 'x86_64'): ``` @@ -162,13 +169,12 @@ build time when the source have been built. Ccache support has been added to KOReader's build system. Before using it, you need to install a ccache in your system. -* in ubuntu use:`sudo apt-get install ccache` -* in fedora use:`sudo yum install ccache` +* in Ubuntu use:`sudo apt-get install ccache` +* in Fedora use:`sudo yum install ccache` * install from source: * get latest ccache source from http://ccache.samba.org/download.html * unarchieve the source package in a directory * cd to that directory and use:`./configure && make && sudo make install` -* after using ccache, make a clean build will only take 15sec. Enjoy! * to disable ccache, use `export USE_NO_CCACHE=1` before make. * for more detail about ccache. visit: diff --git a/frontend/ui/input.lua b/frontend/ui/input.lua index 6ffa1e1ae..5e0c457d4 100644 --- a/frontend/ui/input.lua +++ b/frontend/ui/input.lua @@ -345,16 +345,17 @@ function Input:init() self.event_map[10021] = "NotCharging" if util.isEmulated() then - os.remove("/tmp/emu_event") - os.execute("mkfifo /tmp/emu_event") - input.open("/tmp/emu_event") + if not util.isWindows() then + os.remove("/tmp/emu_event") + os.execute("mkfifo /tmp/emu_event") + input.open("/tmp/emu_event") + end -- SDL key codes if not util.haveSDL2() then self.event_map = self.sdl_event_map else self.event_map = self.sdl2_event_map end - else local dev_mod = Device:getModel() if not Device:isKobo() then diff --git a/frontend/ui/translator.lua b/frontend/ui/translator.lua index 13299d438..90a6bf4ee 100644 --- a/frontend/ui/translator.lua +++ b/frontend/ui/translator.lua @@ -1,8 +1,3 @@ -local socket = require('socket') -local url = require('socket.url') -local http = require('socket.http') -local https = require('ssl.https') -local ltn12 = require('ltn12') local JSON = require("JSON") local DEBUG = require("dbg") @@ -36,6 +31,12 @@ end -- return decoded JSON table from translate server --]] function Translator:loadPage(target_lang, source_lang, text) + local socket = require('socket') + local url = require('socket.url') + local http = require('socket.http') + local https = require('ssl.https') + local ltn12 = require('ltn12') + local request, sink = {}, {} local query = "" self.trans_params.tl = target_lang diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index 1afde8e8b..1a2bde4d5 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -82,11 +82,15 @@ function FileChooser:genItemTableFromPath(path) items = items - 2 end local istr = items .. (items > 1 and _(" items") or _(" item")) - table.insert(item_table, { text = dir.."/", mandatory = istr, path = path}) + table.insert(item_table, { + text = dir.."/", + mandatory = istr, + path = path + }) end for _, file in ipairs(files) do local full_path = self.path.."/"..file - local file_size = lfs.attributes(full_path, "size") + local file_size = lfs.attributes(full_path, "size") or 0 local sstr = "" if file_size > 1024*1024 then sstr = string.format("%4.1f MB", file_size/1024/1024) @@ -95,7 +99,20 @@ function FileChooser:genItemTableFromPath(path) else sstr = string.format("%d B", file_size) end - table.insert(item_table, { text = file, mandatory = sstr, path = full_path }) + table.insert(item_table, { + text = file, + mandatory = sstr, + path = full_path + }) + end + -- lfs.dir iterated node string may be encoded with some weird codepage on Windows + -- we need to encode them to utf-8 + if ffi.os == "Windows" then + for k, v in pairs(item_table) do + if v.text then + v.text = util.multiByteToUTF8(v.text) or "" + end + end end return item_table diff --git a/frontend/ui/wikipedia.lua b/frontend/ui/wikipedia.lua index b75bd9c05..baa98c7af 100644 --- a/frontend/ui/wikipedia.lua +++ b/frontend/ui/wikipedia.lua @@ -1,8 +1,3 @@ -local socket = require('socket') -local url = require('socket.url') -local http = require('socket.http') -local https = require('ssl.https') -local ltn12 = require('ltn12') local JSON = require("JSON") local DEBUG = require("dbg") @@ -33,6 +28,12 @@ end -- return decoded JSON table from Wikipedia --]] function Wikipedia:loadPage(text, lang, intro, plain) + local socket = require('socket') + local url = require('socket.url') + local http = require('socket.http') + local https = require('ssl.https') + local ltn12 = require('ltn12') + local request, sink = {}, {} local query = "" self.wiki_params.exintro = intro and "" or nil diff --git a/koreader-base b/koreader-base index 75f049855..5700663bc 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit 75f049855b2ee6f1b5c8306131d2710becc27bba +Subproject commit 5700663bca390540c1e9e0a613ef8fe295dd3f0b diff --git a/reader.lua b/reader.lua index a13fd11c4..ef59703fd 100755 --- a/reader.lua +++ b/reader.lua @@ -3,7 +3,17 @@ require "defaults" pcall(dofile, "defaults.persistent.lua") package.path = "?.lua;common/?.lua;frontend/?.lua" -package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so" +package.cpath = "?.so;common/?.so;common/?.dll;/usr/lib/lua/?.so" + +local ffi = require("ffi") +if ffi.os == "Windows" then + ffi.cdef[[ + int _putenv(const char *envvar); + ]] + ffi.C._putenv("PATH=libs;common;") + --ffi.C._putenv("EMULATE_READER_W=480") + --ffi.C._putenv("EMULATE_READER_H=600") +end local DocSettings = require("docsettings") local _ = require("gettext") diff --git a/windows/SDL2.dll b/windows/SDL2.dll new file mode 100755 index 000000000..18d707f48 Binary files /dev/null and b/windows/SDL2.dll differ diff --git a/windows/libgcc_s_sjlj-1.dll b/windows/libgcc_s_sjlj-1.dll new file mode 100644 index 000000000..94c697de7 Binary files /dev/null and b/windows/libgcc_s_sjlj-1.dll differ diff --git a/windows/libstdc++-6.dll b/windows/libstdc++-6.dll new file mode 100644 index 000000000..73dda516a Binary files /dev/null and b/windows/libstdc++-6.dll differ diff --git a/windows/libwinpthread-1.dll b/windows/libwinpthread-1.dll new file mode 100644 index 000000000..5e2fed4bd Binary files /dev/null and b/windows/libwinpthread-1.dll differ