build: add kodev script

pull/1783/head
Qingping Hou 8 years ago
parent 5a3b9c6856
commit b480145134

@ -287,6 +287,8 @@ androidupdate: all
update: update:
ifeq ($(TARGET), kindle) ifeq ($(TARGET), kindle)
make kindleupdate make kindleupdate
else ifeq ($(TARGET), kindle-legacy)
make kindleupdate
else ifeq ($(TARGET), kobo) else ifeq ($(TARGET), kobo)
make koboupdate make koboupdate
else ifeq ($(TARGET), pocketbook) else ifeq ($(TARGET), pocketbook)

@ -112,44 +112,35 @@ Getting the source
``` ```
git clone https://github.com/koreader/koreader.git git clone https://github.com/koreader/koreader.git
cd koreader && make fetchthirdparty cd koreader && ./kodev fetch-thirdparty
``` ```
Building, Running and Testing Building, Running and Testing
============================= =============================
For EReader devices (kindle, kobo, pocketbook) For EReader devices (kindle, kobo, pocketbook, ubuntu-touch)
--------------------- ---------------------
To build installable package for Kindle: To build installable package for Kindle:
``` ```
make TARGET=kindle clean update ./kodev release kindle
``` ```
To build installable package for Kobo: 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 To build installable package for PocketBook:
from PocketBook:
``` ```
make pocketbook-toolchain ./kodev release pocketbook
```
then similarly with Kindle and Kobo building run this command:
```
make TARGET=pocketbook clean update
``` ```
To build installable package for Ubuntu Touch 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 You may checkout our [nightlybuild script][nb-script] to see how to build a
package from scratch. package from scratch.
@ -159,15 +150,9 @@ For Android devices
Make sure the "android" and "ndk-build" tools are in your PATH variable 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. 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 Then, run this command to build installable package for Android:
from NDK:
```
make android-toolchain
```
Then, build installable package for Android:
``` ```
make TARGET=android clean androidupdate ./kodev release android
``` ```
For emulating KOReader on Linux and Windows 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: 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: 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 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 make test
``` ```

272
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>
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>
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>
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> <ARGS>
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 <ARGS>
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
Loading…
Cancel
Save