Merge pull request #2008 from Frenzie/master

kodev code quality
pull/2018/head
Qingping Hou 8 years ago
commit cc72fcafd1

64
kodev

@ -3,16 +3,16 @@
CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function assert_ret_zero {
if [ $1 -ne 0 ]; then
if [ "$1" -ne 0 ]; then
if [ ! -z "$2" ]; then
echo $2
echo "$2"
fi
exit 1
fi
}
function setup_env {
files=`ls -d ./koreader-emulator-*/koreader`
files=$(ls -d ./koreader-emulator-*/koreader)
assert_ret_zero $? "Emulator not found, please build it first."
export EMU_DIR=${files[0]}
}
@ -44,8 +44,8 @@ TARGET:
${SUPPORTED_TARGETS}"
while [[ $1 == '-'* ]]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
PARAM=$(echo "$1" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in
-v | --verbose)
export VERBOSE=1
@ -77,7 +77,7 @@ ${SUPPORTED_TARGETS}"
assert_ret_zero $?
;;
android)
if [ ! -d ${CURDIR}/base/toolchain/android-toolchain ]; then
if [ ! -d "${CURDIR}/base/toolchain/android-toolchain" ]; then
make android-toolchain
assert_ret_zero $?
fi
@ -85,7 +85,7 @@ ${SUPPORTED_TARGETS}"
assert_ret_zero $?
;;
pocketbook)
if [ ! -d ${CURDIR}/base/toolchain/pocketbook-toolchain ]; then
if [ ! -d "${CURDIR}/base/toolchain/pocketbook-toolchain" ]; then
make pocketbook-toolchain
assert_ret_zero $?
fi
@ -131,7 +131,7 @@ ${SUPPORTED_TARGETS}"
;;
android)
make TARGET=android clean
rm -f *.apk
rm -f ./*.apk
;;
pocketbook)
make TARGET=pocketbook clean
@ -203,7 +203,7 @@ ${SUPPORTED_RELEASE_TARGETS}"
function kodev-wbuilder {
kodev-build
echo "[*] Running wbuilder.lua..."
pushd ${EMU_DIR}
pushd "${EMU_DIR}"
EMULATE_READER_W=540 EMULATE_READER_H=720 ./luajit ./utils/wbuilder.lua
popd
}
@ -222,8 +222,8 @@ OPTIONS:
screen_width=540
screen_height=720
while [[ $1 == '-'* ]]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
PARAM=$(echo "$1" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in
--disable-touch)
export DISABLE_TOUCH=1
@ -257,18 +257,18 @@ OPTIONS:
setup_env
fi
if [ ! -d ${EMU_DIR} ]; then
if [ ! -d "${EMU_DIR}" ]; then
echo "Failed to find emulator directory! Please try build command first."
exit 1
fi
echo "[*] Running KOReader with arguments: $@..."
pushd ${EMU_DIR}
echo "[*] Running KOReader with arguments: $*..."
pushd "${EMU_DIR}"
if [ $# -lt 1 ]; then
args=${CURDIR}/test
else
args="$@"
args="$*"
[[ $args != /* ]] && args="${CURDIR}/${args}"
fi
@ -288,8 +288,8 @@ OPTIONS:
--tags=TAGS only run tests with given tags
"
while [[ $1 == '-'* ]]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
PARAM=$(echo "$1" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in
--tags)
opts="--tags=${VALUE}"
@ -313,19 +313,19 @@ OPTIONS:
fi
setup_env
make ${EMU_DIR}/.busted
pushd ${EMU_DIR}
make "${EMU_DIR}/.busted"
pushd "${EMU_DIR}"
test_path=./spec/$1/unit
test_path="./spec/$1/unit"
if [ ! -z $2 ]; then
if [ ! -z "$2" ]; then
test_path="${test_path}/$2"
fi
busted --lua=./luajit ${opts} \
busted --lua="./luajit ${opts}" \
--no-auto-insulate \
--lazy \
-o ./spec/$1/unit/verbose_print \
--exclude-tags=notest ${test_path}
-o "./spec/$1/unit/verbose_print" \
--exclude-tags=notest "${test_path}"
popd
}
@ -388,38 +388,38 @@ case $1 in
activate)
echo "adding ${CURDIR} to \$PATH..."
export PATH="${PATH}:${CURDIR}"
eval $(luarocks path bin)
exec ${SHELL}
eval "$(luarocks path bin)"
exec "${SHELL}"
;;
fetch-thirdparty)
kodev-fetch-thirdparty
;;
clean)
shift 1
kodev-clean $@
kodev-clean "$@"
;;
build)
shift 1
kodev-build $@
kodev-build "$@"
;;
release)
shift 1
kodev-release $@
kodev-release "$@"
;;
wbuilder)
kodev-wbuilder
;;
run)
shift 1
kodev-run $@
kodev-run "$@"
;;
test)
shift 1
kodev-test $@
kodev-test "$@"
;;
log)
shift 1
kodev-log $@
kodev-log "$@"
;;
--help | -h)
echo "${HELP_MSG}"

@ -35,7 +35,7 @@ if pkill -0 nickel ; then
FROM_NICKEL="true"
fi
if [ "${FROM_NICKEL}" == "true" ] ; then
if [ "${FROM_NICKEL}" = "true" ] ; then
# Detect if we were started from KFMon
FROM_KFMON="false"
if pkill -0 kfmon ; then
@ -45,7 +45,7 @@ if [ "${FROM_NICKEL}" == "true" ] ; then
fi
fi
if [ "${FROM_KFMON}" == "true" ] ; then
if [ "${FROM_KFMON}" = "true" ] ; then
# Siphon nickel's full environment, since KFMon inherits such a minimal one, and that apparently confuses the hell out of Nickel for some reason if we decide to restart it without a reboot...
for env in $(xargs -n 1 -0 < /proc/$(pidof nickel)/environ) ; do
export ${env}
@ -75,7 +75,7 @@ fi
if [ "$#" -eq 0 ] ; then
args="/mnt/onboard"
else
args="$@"
args="$*"
fi
# check whether PLATFORM & PRODUCT have a value assigned by rcS
@ -93,7 +93,7 @@ if [ ! -n "${PLATFORM}" ] ; then
PLATFORM="${CPU}-ntx"
fi
if [ "${PLATFORM}" == "freescale" ] ; then
if [ "${PLATFORM}" = "freescale" ] ; then
if [ ! -s "/lib/firmware/imx/epdc_E60_V220.fw" ] ; then
mkdir -p "/lib/firmware/imx"
dd if="/dev/mmcblk0" bs=512K skip=10 count=1 | zcat > "/lib/firmware/imx/epdc_E60_V220.fw"
@ -113,7 +113,7 @@ fi
./reader.lua "${args}" > crash.log 2>&1
if [ "${FROM_NICKEL}" == "true" ] ; then
if [ "${FROM_NICKEL}" = "true" ] ; then
if [ "${FROM_KFMON}" != "true" ] ; then
# start kobo software because it was running before koreader
./nickel.sh &

Loading…
Cancel
Save