kodev(minor): style clean up & fixes

pull/2279/head
Qingping Hou 8 years ago
parent abbb72b6d3
commit 8ff9a916da

@ -134,6 +134,9 @@ clean:
rm -rf $(INSTALL_DIR) rm -rf $(INSTALL_DIR)
$(Q:@=@echo 'MAKE -C base clean'; &> /dev/null) \ $(Q:@=@echo 'MAKE -C base clean'; &> /dev/null) \
$(MAKE) -C $(KOR_BASE) clean $(MAKE) -C $(KOR_BASE) clean
ifeq ($(TARGET), android)
$(MAKE) -C $(CURDIR)/platform/android/luajit-launcher clean
endif
dist-clean: clean dist-clean: clean
rm -rf $(INSTALL_DIR) rm -rf $(INSTALL_DIR)

271
kodev

@ -12,9 +12,7 @@ function assert_ret_zero {
} }
function check_submodules { function check_submodules {
if [ -n "`git submodule status | grep -E '^\-'`" ]; then [ -n "`git submodule status | grep -E '^\-'`" ] && kodev-fetch-thirdparty
kodev-fetch-thirdparty
fi
} }
function setup_env { function setup_env {
@ -54,64 +52,46 @@ ${SUPPORTED_TARGETS}"
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 ;;
;;
-h | --help) -h | --help)
echo "${BUILD_HELP_MSG}" echo "${BUILD_HELP_MSG}"; exit 0 ;;
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${BUILD_HELP_MSG}" echo "${BUILD_HELP_MSG}"
exit 1 exit 1 ;;
;;
esac esac
shift 1 shift 1
done done
check_submodules
case $1 in case $1 in
kindle) kindle)
make TARGET=kindle make TARGET=kindle; assert_ret_zero $? ;;
assert_ret_zero $?
;;
kobo) kobo)
make TARGET=kobo make TARGET=kobo; assert_ret_zero $? ;;
assert_ret_zero $?
;;
kindle-legacy) kindle-legacy)
make TARGET=kindle-legacy make TARGET=kindle-legacy; assert_ret_zero $? ;;
assert_ret_zero $?
;;
android) android)
if [ ! -d "${CURDIR}/base/toolchain/android-toolchain" ]; then [[ -v NDK ]] || export NDK="${CURDIR}/base/toolchain/android-ndk-r12b"
make android-toolchain [ -e ${CURDIR}/base/toolchain/android-toolchain/bin/arm-linux-androideabi-gcc ] || { \
assert_ret_zero $? { [ -e ${NDK} ] || make -C ${CURDIR}/base/toolchain android-ndk; }; \
fi make android-toolchain; assert_ret_zero $?; \
make TARGET=android }
assert_ret_zero $? echo "Using NDK: ${NDK}..."
;; make TARGET=android; 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
make TARGET=pocketbook make TARGET=pocketbook; assert_ret_zero $? ;;
assert_ret_zero $?
;;
ubuntu-touch) ubuntu-touch)
make TARGET=ubuntu-touch make TARGET=ubuntu-touch; assert_ret_zero $? ;;
assert_ret_zero $?
;;
win32) win32)
make TARGET=win32 make TARGET=win32; assert_ret_zero $? ;;
assert_ret_zero $?
;;
*) *)
check_submodules
make make
assert_ret_zero $? "Failed to build emulator! Try run with -v for more information." assert_ret_zero $? "Failed to build emulator! Try run with -v for more information."
setup_env setup_env ;;
;;
esac esac
} }
@ -124,34 +104,24 @@ ${SUPPORTED_TARGETS}"
case $1 in case $1 in
-h | --help) -h | --help)
echo "${CLEAN_HELP_MSG}" echo "${CLEAN_HELP_MSG}"; exit 0 ;;
exit 0
;;
kindle) kindle)
make TARGET=kindle clean make TARGET=kindle clean ;;
;;
kobo) kobo)
make TARGET=kobo clean make TARGET=kobo clean ;;
;;
kindle-legacy) kindle-legacy)
make TARGET=kindle-legacy clean make TARGET=kindle-legacy clean ;;
;;
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 ;;
;;
ubuntu-touch) ubuntu-touch)
make TARGET=ubuntu-touch clean make TARGET=ubuntu-touch clean ;;
;;
win32) win32)
make TARGET=win32 clean make TARGET=win32 clean ;;
;;
*) *)
make clean make clean ;;
;;
esac esac
} }
@ -163,46 +133,38 @@ usage: release <TARGET>
TARGET: TARGET:
${SUPPORTED_RELEASE_TARGETS}" ${SUPPORTED_RELEASE_TARGETS}"
[ $# -lt 1 ] && { echo "${RELEASE_HELP_MSG}"; exit 1; }
if [ $# -lt 1 ]; then
echo "${RELEASE_HELP_MSG}"
exit 1
fi
case $1 in case $1 in
-h | --help) -h | --help)
echo "${RELEASE_HELP_MSG}" echo "${RELEASE_HELP_MSG}"; exit 0 ;;
exit 0
;;
kindle) kindle)
kodev-build kindle kodev-build kindle
make TARGET=kindle update make TARGET=kindle update ;;
;;
kobo) kobo)
kodev-build kobo kodev-build kobo
make TARGET=kobo update make TARGET=kobo update ;;
;;
kindle-legacy) kindle-legacy)
kodev-build kindle-legacy kodev-build kindle-legacy
make TARGET=kindle-legacy update make TARGET=kindle-legacy update ;;
;;
android) android)
kodev-build android kodev-build android
make TARGET=android update export PATH=$PATH:${CURDIR}/base/toolchain/android-sdk-linux/tools
;; which android &> /dev/null || { \
make -C ${CURDIR}/base/toolchain android-sdk; \
}
export ANDROID_HOME=`dirname $(dirname $(which android))`
export PATH=$PATH:${NDK}
make TARGET=android update ;;
pocketbook) pocketbook)
kodev-build pocketbook kodev-build pocketbook
make TARGET=pocketbook update make TARGET=pocketbook update ;;
;;
ubuntu-touch) ubuntu-touch)
kodev-build pocketbook kodev-build pocketbook
make TARGET=ubuntu-touch update make TARGET=ubuntu-touch update ;;
;;
*) *)
echo "Unsupported target for release: $1." echo "Unsupported target for release: $1."
echo "${RELEASE_HELP_MSG}" echo "${RELEASE_HELP_MSG}"; exit 1 ;;
exit 1
;;
esac esac
} }
@ -211,7 +173,7 @@ 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
} }
@ -233,26 +195,18 @@ OPTIONS:
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 ;;
;;
--no-build) --no-build)
no_build=true no_build=true ;;
;;
-w | --screen-width) -w | --screen-width)
screen_width=${VALUE} screen_width=${VALUE} ;;
;;
-h | --screen-height) -h | --screen-height)
screen_height=${VALUE} screen_height=${VALUE} ;;
;;
-h | --help) -h | --help)
echo "${RUN_HELP_MSG}" echo "${RUN_HELP_MSG}"; exit 0 ;;
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${RUN_HELP_MSG}" echo "${RUN_HELP_MSG}"; exit 1 ;;
exit 1
;;
esac esac
shift shift
done done
@ -271,16 +225,15 @@ OPTIONS:
echo "[*] Running KOReader with arguments: $*..." echo "[*] Running KOReader with arguments: $*..."
pushd "${EMU_DIR}" pushd "${EMU_DIR}"
if [ $# -lt 1 ]; then
args=${CURDIR}/test
else
args="$*"
[[ $args != /* ]] && args="${CURDIR}/${args}"
fi
if [ $# -lt 1 ]; then EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} \
args=${CURDIR}/test ./reader.lua -d "$args"
else
args="$*"
[[ $args != /* ]] && args="${CURDIR}/${args}"
fi
EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} \
./reader.lua -d "$args"
popd popd
} }
@ -299,45 +252,34 @@ OPTIONS:
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}" ;;
;;
-h | --help) -h | --help)
echo "${TEST_HELP_MSG}" echo "${TEST_HELP_MSG}"; exit 0 ;;
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${TEST_HELP_MSG}" echo "${TEST_HELP_MSG}"; exit 1 ;;
exit 1
;;
esac esac
shift shift
done done
if [ $# -lt 1 ]; then [ $# -lt 1 ] && { echo "${TEST_HELP_MSG}"; exit 1; }
echo "${TEST_HELP_MSG}"
exit 1
fi
check_submodules check_submodules && make
make
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
test_path="${test_path}/$2"
if [ ! -z "$2" ]; then fi
test_path="${test_path}/$2"
fi
echo "Runing tests in" ${test_path}
busted --lua="./luajit" ${opts} \
--no-auto-insulate \
--lazy \
-o "./spec/$1/unit/verbose_print" \
--exclude-tags=notest "${test_path}"
echo "Runing tests in" ${test_path}
busted --lua="./luajit" ${opts} \
--no-auto-insulate \
--lazy \
-o "./spec/$1/unit/verbose_print" \
--exclude-tags=notest "${test_path}"
popd popd
} }
@ -349,25 +291,16 @@ TARGET:
android android
" "
[ $# -lt 1 ] && { echo "${LOG_HELP_MSG}"; exit 1; }
if [ $# -lt 1 ]; then
echo "${LOG_HELP_MSG}"
exit 1
fi
case $1 in case $1 in
-h | --help) -h | --help)
echo "${LOG_HELP_MSG}" echo "${LOG_HELP_MSG}"; exit 0 ;;
exit 0
;;
android) android)
adb logcat 'luajit-launcher:D KOReader:D *:S' adb logcat 'luajit-launcher:D KOReader:D *:S' ;;
;;
*) *)
echo "Unsupported target: $1." echo "Unsupported target: $1."
echo "${LOG_HELP_MSG}" echo "${LOG_HELP_MSG}"; exit 1 ;;
exit 1
;;
esac esac
} }
@ -388,57 +321,33 @@ Supported commands:
test Run tests test Run tests
wbuilder Run wbuilder.lua script (useful for building new UI widget) wbuilder Run wbuilder.lua script (useful for building new UI widget)
" "
[ $# -lt 1 ] && { echo "Missing command."; echo "${HELP_MSG}"; exit 1; }
if [ $# -lt 1 ]; then
echo "Missing command."
echo "${HELP_MSG}"
exit 1
fi
case $1 in 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}"; exit 0 ;;
exit 0
;;
*) *)
echo "Unknown command: $1." echo "Unknown command: $1."
echo "${HELP_MSG}" echo "${HELP_MSG}"; exit 1 ;;
exit 1
;;
esac esac

Loading…
Cancel
Save