diff --git a/Makefile b/Makefile index d5d30b5ba..ad88a53d3 100644 --- a/Makefile +++ b/Makefile @@ -287,6 +287,8 @@ androidupdate: all update: ifeq ($(TARGET), kindle) make kindleupdate +else ifeq ($(TARGET), kindle-legacy) + make kindleupdate else ifeq ($(TARGET), kobo) make koboupdate else ifeq ($(TARGET), pocketbook) diff --git a/README.md b/README.md index dff7a617f..3a637a9db 100644 --- a/README.md +++ b/README.md @@ -112,44 +112,35 @@ Getting the source ``` git clone https://github.com/koreader/koreader.git -cd koreader && make fetchthirdparty +cd koreader && ./kodev fetch-thirdparty ``` Building, Running and Testing ============================= -For EReader devices (kindle, kobo, pocketbook) +For EReader devices (kindle, kobo, pocketbook, ubuntu-touch) --------------------- To build installable package for Kindle: ``` -make TARGET=kindle clean update +./kodev release kindle ``` To build installable package for Kobo: ``` -make TARGET=kobo clean update +./kodev release kobo ``` -To build installable package for PocketBook you need first to obtain the SDK -from PocketBook: +To build installable package for PocketBook: ``` -make pocketbook-toolchain -``` -then similarly with Kindle and Kobo building run this command: -``` -make TARGET=pocketbook clean update +./kodev release pocketbook ``` To build installable package for Ubuntu Touch ``` -make TARGET=ubuntu-touch clean update +./kodev release ubuntu-touch ``` -To run, you must call the script `reader.lua`. Run it without arguments to see -usage notes. Note that the script and the `luajit` binary must be in the same -directory. - You may checkout our [nightlybuild script][nb-script] to see how to build a package from scratch. @@ -159,15 +150,9 @@ For Android devices Make sure the "android" and "ndk-build" tools are in your PATH variable and the NDK variable points to the root directory of the Android NDK. -First, run this command to make a standalone android cross compiling toolchain -from NDK: -``` -make android-toolchain -``` - -Then, build installable package for Android: +Then, run this command to build installable package for Android: ``` -make TARGET=android clean androidupdate +./kodev release android ``` For emulating KOReader on Linux and Windows @@ -175,21 +160,20 @@ For emulating KOReader on Linux and Windows To build an emulator on current Linux machine just run: ``` -make clean && make +./kodev build ``` If you want to compile the emulator for Windows you need to run: ``` -make TARGET=win32 clean && make TARGET=win32 +./kodev build win32 ``` To run Koreader on your developing machine -(you may need to change $(MACHINE) to the arch of your machine such as 'x86_64'): ``` -cd koreader-emulator-$(MACHINE)/koreader && ./reader.lua -d ../../test +./kodev run ./test ``` -To run unit tests in KOReader: +To run unit tests: ``` make test ``` diff --git a/kodev b/kodev new file mode 100755 index 000000000..0a4274ddd --- /dev/null +++ b/kodev @@ -0,0 +1,272 @@ +#!/bin/bash + +CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function setup_env { + files=("./koreader-emulator-*/koreader") + export EMU_DIR=${files[0]} +} + +function kodev-fetch-thirdparty { + make fetchthirdparty +} + +SUPPORTED_TARGETS=" + kindle For kindle with touch support + kindle-legacy For kindle2/3/4/DXG + kobo + android + pocketbook + ubuntu-touch + emu (*default) If no TARGET is given, assume emulator + win32 +" + +function kodev-build { + BUILD_HELP_MSG=" +usage: build + +TARGET: +${SUPPORTED_TARGETS}" + + case $1 in + -h | --help) + echo "${BUILD_HELP_MSG}" + exit 0 + ;; + kindle) + make TARGET=kindle + ;; + kobo) + make TARGET=kobo + ;; + kindle-legacy) + make TARGET=kindle-legacy + ;; + android) + if [ ! -d ${CURDIR}/base/toolchain/android-toolchain ]; then + make android-toolchain + fi + make TARGET=android + ;; + pocketbook) + if [ ! -d ${CURDIR}/base/toolchain/pocketbook-toolchain ]; then + make pocketbook-toolchain + fi + make TARGET=pocketbook + ;; + ubuntu-touch) + make TARGET=ubuntu-touch + ;; + win32) + make TARGET=win32 + ;; + *) + make + setup_env + ;; + esac +} + +function kodev-clean { + CLEAN_HELP_MSG=" +usage: clean + +TARGET: +${SUPPORTED_TARGETS}" + + case $1 in + -h | --help) + echo "${CLEAN_HELP_MSG}" + exit 0 + ;; + kindle) + make TARGET=kindle clean + ;; + kobo) + make TARGET=kobo clean + ;; + kindle-legacy) + make TARGET=kindle-legacy clean + ;; + android) + make TARGET=android clean + ;; + pocketbook) + make TARGET=pocketbook clean + ;; + ubuntu-touch) + make TARGET=ubuntu-touch clean + ;; + win32) + make TARGET=win32 clean + ;; + *) + make clean + ;; + esac +} + +function kodev-release { + # SUPPORTED_RELEASE_TARGETS=$(echo ${SUPPORTED_TARGETS} | sed 's/win32//') + SUPPORTED_RELEASE_TARGETS="${SUPPORTED_TARGETS/emu*/""}" + RELEASE_HELP_MSG=" +usage: release + +TARGET: +${SUPPORTED_RELEASE_TARGETS}" + + if [ $# -lt 1 ]; then + echo "${RELEASE_HELP_MSG}" + exit 1 + fi + + case $1 in + -h | --help) + echo "${RELEASE_HELP_MSG}" + exit 0 + ;; + kindle) + kodev-build kindle + make TARGET=kindle update + ;; + kobo) + kodev-build kobo + make TARGET=kobo update + ;; + kindle-legacy) + kodev-build kindle-legacy + make TARGET=kindle-legacy update + ;; + android) + kodev-build android + make TARGET=android update + ;; + pocketbook) + kodev-build pocketbook + make TARGET=pocketbook update + ;; + ubuntu-touch) + kodev-build pocketbook + make TARGET=ubuntu-touch update + ;; + *) + echo "Unsupported target for release: $1." + echo "${RELEASE_HELP_MSG}" + exit 1 + ;; + esac +} + + +function kodev-wbuilder { + kodev-build + echo "[*] Running wbuilder.lua..." + pushd ${EMU_DIR} + EMULATE_READER_W=540 EMULATE_READER_H=720 ./luajit ./utils/wbuilder.lua + popd +} + +function kodev-run { + RUN_HELP_MSG=" +usage: run + +OPTIONS: + + --no-build run reader without rebuilding + --disable-touch use this if you want to simulate keyboard only devices + " + while [[ $1 == '--'* ]]; do + PARAM=`echo $1 | awk -F= '{print $1}'` + VALUE=`echo $1 | awk -F= '{print $2}'` + case $PARAM in + --disable-touch) + export DISABLE_TOUCH=1 + ;; + --no-build) + no_build=true + ;; + -h | --help) + echo "${RUN_HELP_MSG}" + exit 0 + ;; + *) + echo "ERROR: unknown option \"$PARAM\"" + echo "${RUN_HELP_MSG}" + exit 1 + ;; + esac + shift + done + + if [ ! ${no_build} ]; then + echo "[*] Building KOReader..." + kodev-build + else + setup_env + fi + + echo "[*] Running KOReader..." + pushd ${EMU_DIR} + + if [ $# -lt 1 ]; then + args=${CURDIR}/test + else + args="$1" + [[ $args != /* ]] && args="${CURDIR}/$1" + fi + + EMULATE_READER_W=540 EMULATE_READER_H=720 ./reader.lua -d $args + popd +} + +HELP_MSG=" +usage: $0 COMMAND + +Supported commands: + + build Build KOReader + clean Clean KOReader build + run Run KOReader + wbuilder Run wbuilder.lua script (useful for building new UI widget) +" + +if [ $# -lt 1 ]; then + echo "Missing command." + echo "${HELP_MSG}" + exit 1 +fi + +case $1 in + fetch-thirdparty) + kodev-fetch-thirdparty + ;; + clean) + shift 1 + kodev-clean $@ + ;; + build) + shift 1 + kodev-build $@ + ;; + release) + shift 1 + kodev-release $@ + ;; + wbuilder) + kodev-wbuilder + ;; + run) + shift 1 + kodev-run $@ + ;; + --help | -h) + echo "${HELP_MSG}" + exit 0 + ;; + *) + echo "Unknown command: $1." + echo "${HELP_MSG}" + exit 1 + ;; +esac diff --git a/utils/wtest.lua b/utils/wbuilder.lua similarity index 100% rename from utils/wtest.lua rename to utils/wbuilder.lua