Skip to content

Commit

Permalink
Merge pull request #451 from koreader/chrox-master
Browse files Browse the repository at this point in the history
add CI build array for kindle, kobo and android
  • Loading branch information
houqp committed Aug 14, 2016
2 parents 5ad2478 + 6757073 commit cacbaea
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 48 deletions.
22 changes: 22 additions & 0 deletions .ci/android_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# install 32 bit libz package for NDK build
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install zlib1g:i386 libc6-dev-i386 linux-libc-dev:i386

if [ "$NDKREV" = "r9c" ]; then
curl -L http://dl.google.com/android/ndk/android-ndk-${NDKREV}-linux-x86_64.tar.bz2 -O
echo "extracting android ndk"
bzip2 -dc android-ndk-${NDKREV}-linux-x86_64.tar.bz2 | tar xf -
fi

if [ "$NDKREV" = "r11c" ]; then
curl -L http://dl.google.com/android/repository/android-ndk-${NDKREV}-linux-x86_64.zip -O
echo "extracting android ndk"
unzip -q android-ndk-${NDKREV}-linux-x86_64.zip
fi

export NDK=`pwd`/android-ndk-${NDKREV}
export PATH=$PATH:${NDK}
make android-toolchain
13 changes: 13 additions & 0 deletions .ci/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# don't do this for clang
if [ "$CXX" = "g++" ];
then export CXX="g++-4.8" CC="gcc-4.8";
fi
# in case anything ignores the environment variables, override through PATH
mkdir bin
ln -s $(which gcc-4.8) bin/cc
ln -s $(which gcc-4.8) bin/gcc
ln -s $(which c++-4.8) bin/c++
ln -s $(which g++-4.8) bin/g++
export PATH=$PWD/bin:$PATH
7 changes: 7 additions & 0 deletions .ci/build_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${CI_DIR}/common.sh"

travis_retry make fetchthirdparty
make all
59 changes: 59 additions & 0 deletions .ci/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
set -e
set -o pipefail

ANSI_RED="\033[31;1m"
ANSI_GREEN="\033[32;1m"
ANSI_RESET="\033[0m"
ANSI_CLEAR="\033[0K"

travis_retry() {
local result=0
local count=1
set +e

while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
}
"$@"
result=$?
[ $result -eq 0 ] && break
count=$(($count + 1))
sleep 1
done

[ $count -gt 3 ] && {
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
}

set -e
return $result
}

retry_cmd() {
local result=0
local count=1
set +e

retry_cnt=$1
shift 1

while [ $count -le ${retry_cnt} ]; do
[ $result -ne 0 ] && {
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of ${retry_cnt}${ANSI_RESET}\n" >&2
}
"$@"
result=$?
[ $result -eq 0 ] && break
count=$(($count + 1))
sleep 1
done

[ $count -gt ${retry_cnt} ] && {
echo -e "\n${ANSI_RED}The command \"$@\" failed ${retry_cnt} times.${ANSI_RESET}\n" >&2
}

set -e
return $result
}

17 changes: 17 additions & 0 deletions .ci/emulator_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${CI_DIR}/common.sh"

mkdir $HOME/.luarocks
cp /etc/luarocks/config.lua $HOME/.luarocks/config.lua
echo "wrap_bin_scripts = false" >> $HOME/.luarocks/config.lua
# recent versions of busted may cause some weird segmentation faults
# - git clone https://github.com/Olivine-Labs/busted/
# - cd busted && git checkout v1.10.0 && luarocks --local make busted-1.10.0-0.rockspec && cd ..
travis_retry luarocks --local install busted 2.0.rc12-1
# for verbose_print module
travis_retry luarocks --local install ansicolors
eval $(luarocks path --bin)
export PATH=$PATH:$HOME/.luarocks/bin

7 changes: 7 additions & 0 deletions .ci/kindle_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6-dev-i386 linux-libc-dev:i386

sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
7 changes: 7 additions & 0 deletions .ci/kobo_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6-dev-i386 linux-libc-dev:i386

sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
18 changes: 18 additions & 0 deletions .ci/test_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${CI_DIR}/common.sh"

cp build/*/luajit $HOME/.luarocks/bin
# install tesseract trained language data for testing OCR functionality
travis_retry wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz
tar zxf tesseract-ocr-3.02.eng.tar.gz
cd build/* && export TESSDATA_PREFIX=`pwd`/data && mkdir -p data/tessdata
mv ../../tesseract-ocr/tessdata/* data/tessdata/ && cd ../../
# fetch font for base test
travis_retry wget https://github.com/koreader/koreader/raw/master/resources/fonts/droid/DroidSansMono.ttf
export OUTPUT_DIR=`ls -d ./build/x86_64-*linux-gnu`
mkdir -p ${OUTPUT_DIR}/fonts/droid/
cp DroidSansMono.ttf ${OUTPUT_DIR}/fonts/droid/DroidSansMono.ttf
# finally make test
travis_retry make test
59 changes: 14 additions & 45 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Travis-CI Build for koreader-base
# see travis-ci.org for details

language: c

dist: trusty
sudo: required
# sudo: false
Expand All @@ -12,17 +10,16 @@ cache:
directories:
- $HOME/.ccache

compiler:
- gcc
- clang

env:
- EMULATE_READER=1
- EMULATE_READER=1 CC=gcc
- EMULATE_READER=1 CC=clang
- TARGET=kindle
- TARGET=kobo
- TARGET=android NDKREV=r9c
- TARGET=android NDKREV=r11c

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- libsdl1.2-dev
Expand All @@ -33,43 +30,15 @@ addons:
# OpenSSL likes this (package contains makedepend)
- xutils-dev

before_install:
# don't do this for clang
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
# in case anything ignores the environment variables, override through PATH
- mkdir bin
- ln -s $(which gcc-4.8) bin/cc
- ln -s $(which gcc-4.8) bin/gcc
- ln -s $(which c++-4.8) bin/c++
- ln -s $(which g++-4.8) bin/g++
- export PATH=$PWD/bin:$PATH
before_install: source .ci/before_install.sh

install:
- mkdir $HOME/.luarocks
- cp /etc/luarocks/config.lua $HOME/.luarocks/config.lua
- echo "wrap_bin_scripts = false" >> $HOME/.luarocks/config.lua
# recent versions of busted may cause some weird segmentation faults
# - git clone https://github.com/Olivine-Labs/busted/
# - cd busted && git checkout v1.10.0 && luarocks --local make busted-1.10.0-0.rockspec && cd ..
- travis_retry luarocks --local install busted 2.0.rc12-1
# for verbose_print module
- travis_retry luarocks --local install ansicolors
- eval $(luarocks path --bin)
- export PATH=$PATH:$HOME/.luarocks/bin
- if [ "$EMULATE_READER" = 1 ]; then source .ci/emulator_install.sh; fi
- if [ "$TARGET" = kindle ]; then .ci/kindle_install.sh; fi
- if [ "$TARGET" = kobo ]; then .ci/kobo_install.sh; fi
- if [ "$TARGET" = android ]; then source .ci/android_install.sh; fi

script:
- travis_retry make fetchthirdparty
- make all
- cp build/*/luajit $HOME/.luarocks/bin
# install tesseract trained language data for testing OCR functionality
- travis_retry wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz
- tar zxf tesseract-ocr-3.02.eng.tar.gz
- cd build/* && export TESSDATA_PREFIX=`pwd`/data && mkdir -p data/tessdata
- mv ../../tesseract-ocr/tessdata/* data/tessdata/ && cd ../../
# fetch font for base test
- travis_retry wget https://github.com/koreader/koreader/raw/master/resources/fonts/droid/DroidSansMono.ttf
- export OUTPUT_DIR=`ls -d ./build/x86_64-*linux-gnu`
- mkdir -p ${OUTPUT_DIR}/fonts/droid/
- cp DroidSansMono.ttf ${OUTPUT_DIR}/fonts/droid/DroidSansMono.ttf
# finally make test
- travis_retry make test
- .ci/build_script.sh
- if [ "$EMULATE_READER" = 1 ]; then source .ci/test_script.sh; fi

1 change: 1 addition & 0 deletions Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ $(LIBGETTEXT): $(LIBICONV) $(THIRDPARTY_DIR)/gettext/CMakeLists.txt
$(CMAKE) -DCC="$(CC) -std=gnu89" -DLIBICONV_PREFIX=$(LIBICONV_DIR) \
-DCHOST_OPTS="$(if $(EMULATE_READER),,--host=$(if $(ANDROID),arm-linux,$(CHOST)))" \
$(if $(ANDROID),-DIS_ANDROID:BOOL=on,) \
$(if $(ANDROID),-DNDK=$(NDK),) \
$(CURDIR)/thirdparty/gettext && \
$(MAKE)

Expand Down
4 changes: 2 additions & 2 deletions ffi/SDL2_0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function S.open()

-- set up screen (window)
S.screen = SDL.SDL_CreateWindow("KOReader",
SDL.SDL_WINDOWPOS_UNDEFINED,
SDL.SDL_WINDOWPOS_UNDEFINED,
tonumber(os.getenv("KOREADER_WINDOW_POS_X")) or SDL.SDL_WINDOWPOS_UNDEFINED,
tonumber(os.getenv("KOREADER_WINDOW_POS_Y")) or SDL.SDL_WINDOWPOS_UNDEFINED,
S.w, S.h, full_screen and 1 or 0)

S.renderer = SDL.SDL_CreateRenderer(S.screen, -1, 0)
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/gettext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ ep_get_binary_dir(BINARY_DIR)

set(CFG_ENV_VAR "CC=\"${CC}\"")
if(${IS_ANDROID})
set(CFG_ENV_VAR "${CFG_ENV_VAR} LDFLAGS=-lc")
# workaround of 'undefined reference to getdtablesize' for NDK-r11c
set(CFG_ENV_VAR "${CFG_ENV_VAR} LDFLAGS=-lc LIBS=${NDK}/platforms/android-9/arch-arm/usr/lib/libc.a")
endif()
set(CFG_OPTS "--with-threads=none --prefix=${BINARY_DIR} --with-libiconv-prefix=${LIBICONV_PREFIX} --enable-shared=false --enable-static=true ${CHOST_OPTS}")
set(CFG_CMD sh -c "${CFG_ENV_VAR} ${SOURCE_DIR}/configure ${CFG_OPTS}")
Expand Down

0 comments on commit cacbaea

Please sign in to comment.