kodev code quality

pull/2008/head
Frans de Jonge 8 years ago
parent 389f492610
commit 6e9208ac50

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}"

Loading…
Cancel
Save