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

@ -35,7 +35,7 @@ if pkill -0 nickel ; then
FROM_NICKEL="true" FROM_NICKEL="true"
fi fi
if [ "${FROM_NICKEL}" == "true" ] ; then if [ "${FROM_NICKEL}" = "true" ] ; then
# Detect if we were started from KFMon # Detect if we were started from KFMon
FROM_KFMON="false" FROM_KFMON="false"
if pkill -0 kfmon ; then if pkill -0 kfmon ; then
@ -45,7 +45,7 @@ if [ "${FROM_NICKEL}" == "true" ] ; then
fi fi
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... # 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 for env in $(xargs -n 1 -0 < /proc/$(pidof nickel)/environ) ; do
export ${env} export ${env}
@ -75,7 +75,7 @@ fi
if [ "$#" -eq 0 ] ; then if [ "$#" -eq 0 ] ; then
args="/mnt/onboard" args="/mnt/onboard"
else else
args="$@" args="$*"
fi fi
# check whether PLATFORM & PRODUCT have a value assigned by rcS # check whether PLATFORM & PRODUCT have a value assigned by rcS
@ -93,7 +93,7 @@ if [ ! -n "${PLATFORM}" ] ; then
PLATFORM="${CPU}-ntx" PLATFORM="${CPU}-ntx"
fi fi
if [ "${PLATFORM}" == "freescale" ] ; then if [ "${PLATFORM}" = "freescale" ] ; then
if [ ! -s "/lib/firmware/imx/epdc_E60_V220.fw" ] ; then if [ ! -s "/lib/firmware/imx/epdc_E60_V220.fw" ] ; then
mkdir -p "/lib/firmware/imx" mkdir -p "/lib/firmware/imx"
dd if="/dev/mmcblk0" bs=512K skip=10 count=1 | zcat > "/lib/firmware/imx/epdc_E60_V220.fw" 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 ./reader.lua "${args}" > crash.log 2>&1
if [ "${FROM_NICKEL}" == "true" ] ; then if [ "${FROM_NICKEL}" = "true" ] ; then
if [ "${FROM_KFMON}" != "true" ] ; then if [ "${FROM_KFMON}" != "true" ] ; then
# start kobo software because it was running before koreader # start kobo software because it was running before koreader
./nickel.sh & ./nickel.sh &

Loading…
Cancel
Save