Merge pull request #924 from chrox/win32-port

add win32 port of Koreader
pull/928/head
HW 10 years ago
commit 5925e762fc

1
.gitignore vendored

@ -30,5 +30,6 @@ l10n/*
koreader-arm-linux-androideabi koreader-arm-linux-androideabi
koreader-arm-linux-gnueabi koreader-arm-linux-gnueabi
koreader-arm-linux-gnueabihf koreader-arm-linux-gnueabihf
koreader-i686-w64-mingw32
koreader-x86_64-linux-gnu koreader-x86_64-linux-gnu

@ -32,7 +32,7 @@ all: $(if $(ANDROID),,$(KOR_BASE)/$(OUTPUT_DIR)/luajit)
$(MAKE) -C $(KOR_BASE) $(MAKE) -C $(KOR_BASE)
echo $(VERSION) > git-rev echo $(VERSION) > git-rev
mkdir -p $(INSTALL_DIR)/koreader mkdir -p $(INSTALL_DIR)/koreader
ifdef EMULATE_READER ifneq ($(or $(EMULATE_READER),$(WIN32)),)
cp -f $(KOR_BASE)/ev_replay.py $(INSTALL_DIR)/koreader/ cp -f $(KOR_BASE)/ev_replay.py $(INSTALL_DIR)/koreader/
# create symlink instead of copying files in development mode # create symlink instead of copying files in development mode
cd $(INSTALL_DIR)/koreader && \ cd $(INSTALL_DIR)/koreader && \
@ -51,6 +51,10 @@ endif
ifdef ANDROID ifdef ANDROID
cd $(INSTALL_DIR)/koreader && \ cd $(INSTALL_DIR)/koreader && \
ln -sf ../../$(ANDROID_DIR)/*.lua . ln -sf ../../$(ANDROID_DIR)/*.lua .
endif
ifdef WIN32
# install runtime libraries for win32
cd $(INSTALL_DIR)/koreader && cp ../../windows/*.dll .
endif endif
# install plugins # install plugins
cp -r plugins/* $(INSTALL_DIR)/koreader/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/data/tessdata
mkdir -p $(INSTALL_DIR)/koreader/fonts/host mkdir -p $(INSTALL_DIR)/koreader/fonts/host
mkdir -p $(INSTALL_DIR)/koreader/ota mkdir -p $(INSTALL_DIR)/koreader/ota
ifndef EMULATE_READER ifeq ($(or $(EMULATE_READER),$(WIN32)),)
# clean up, remove unused files for releases # clean up, remove unused files for releases
rm -rf $(INSTALL_DIR)/koreader/data/{cr3.ini,cr3skin-format.txt,desktop,devices,manual} rm -rf $(INSTALL_DIR)/koreader/data/{cr3.ini,cr3skin-format.txt,desktop,devices,manual}
rm $(INSTALL_DIR)/koreader/fonts/droid/DroidSansFallbackFull.ttc rm $(INSTALL_DIR)/koreader/fonts/droid/DroidSansFallbackFull.ttc

@ -1,9 +1,9 @@
KOReader [![Build Status][travis-icon]][travis-link] KOReader [![Build Status][travis-icon]][travis-link]
======== ========
KOReader is a document viewer application, originally created for usage on the KOReader is a document viewer application, originally created for Kindle
Kindle e-ink reader. It currently supports Kindle 5 (Touch), Kindle Paperwhite e-ink readers. It currently runs on Kindle 5 (Touch), Kindle Paperwhite,
, Kobo and Android devices. Kobo, Android(2.3+) devices.
KOReader started as the KindlePDFViewer application, but it supports much more KOReader started as the KindlePDFViewer application, but it supports much more
formats than PDF now. Among them are DJVU, FB2, EPUB, TXT, CBZ, HTML. 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 sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
# for Kobo # for Kobo
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf 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 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 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: Ubuntu users probably need to run:
``` ```
sudo apt-get install libsdl1.2-dev sudo apt-get install libsdl1.2-dev
@ -104,14 +106,19 @@ Then, build installable package for Android:
make TARGET=android clean androidupdate 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 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 To run koreader on your developing machine
(you may need to change $(MACHINE) to the arch of your machine such as 'x86_64'): (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 KOReader's build system. Before using it, you need to install a ccache in your
system. system.
* in ubuntu use:`sudo apt-get install ccache` * in Ubuntu use:`sudo apt-get install ccache`
* in fedora use:`sudo yum install ccache` * in Fedora use:`sudo yum install ccache`
* install from source: * install from source:
* get latest ccache source from http://ccache.samba.org/download.html * get latest ccache source from http://ccache.samba.org/download.html
* unarchieve the source package in a directory * unarchieve the source package in a directory
* cd to that directory and use:`./configure && make && sudo make install` * 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. * to disable ccache, use `export USE_NO_CCACHE=1` before make.
* for more detail about ccache. visit: * for more detail about ccache. visit:

@ -345,16 +345,17 @@ function Input:init()
self.event_map[10021] = "NotCharging" self.event_map[10021] = "NotCharging"
if util.isEmulated() then if util.isEmulated() then
os.remove("/tmp/emu_event") if not util.isWindows() then
os.execute("mkfifo /tmp/emu_event") os.remove("/tmp/emu_event")
input.open("/tmp/emu_event") os.execute("mkfifo /tmp/emu_event")
input.open("/tmp/emu_event")
end
-- SDL key codes -- SDL key codes
if not util.haveSDL2() then if not util.haveSDL2() then
self.event_map = self.sdl_event_map self.event_map = self.sdl_event_map
else else
self.event_map = self.sdl2_event_map self.event_map = self.sdl2_event_map
end end
else else
local dev_mod = Device:getModel() local dev_mod = Device:getModel()
if not Device:isKobo() then if not Device:isKobo() then

@ -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 JSON = require("JSON")
local DEBUG = require("dbg") local DEBUG = require("dbg")
@ -36,6 +31,12 @@ end
-- return decoded JSON table from translate server -- return decoded JSON table from translate server
--]] --]]
function Translator:loadPage(target_lang, source_lang, text) 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 request, sink = {}, {}
local query = "" local query = ""
self.trans_params.tl = target_lang self.trans_params.tl = target_lang

@ -82,11 +82,15 @@ function FileChooser:genItemTableFromPath(path)
items = items - 2 items = items - 2
end end
local istr = items .. (items > 1 and _(" items") or _(" item")) 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 end
for _, file in ipairs(files) do for _, file in ipairs(files) do
local full_path = self.path.."/"..file 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 = "" local sstr = ""
if file_size > 1024*1024 then if file_size > 1024*1024 then
sstr = string.format("%4.1f MB", file_size/1024/1024) sstr = string.format("%4.1f MB", file_size/1024/1024)
@ -95,7 +99,20 @@ function FileChooser:genItemTableFromPath(path)
else else
sstr = string.format("%d B", file_size) sstr = string.format("%d B", file_size)
end 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 end
return item_table return item_table

@ -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 JSON = require("JSON")
local DEBUG = require("dbg") local DEBUG = require("dbg")
@ -33,6 +28,12 @@ end
-- return decoded JSON table from Wikipedia -- return decoded JSON table from Wikipedia
--]] --]]
function Wikipedia:loadPage(text, lang, intro, plain) 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 request, sink = {}, {}
local query = "" local query = ""
self.wiki_params.exintro = intro and "" or nil self.wiki_params.exintro = intro and "" or nil

@ -1 +1 @@
Subproject commit 75f049855b2ee6f1b5c8306131d2710becc27bba Subproject commit 5700663bca390540c1e9e0a613ef8fe295dd3f0b

@ -3,7 +3,17 @@
require "defaults" require "defaults"
pcall(dofile, "defaults.persistent.lua") pcall(dofile, "defaults.persistent.lua")
package.path = "?.lua;common/?.lua;frontend/?.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 DocSettings = require("docsettings")
local _ = require("gettext") local _ = require("gettext")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save